mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-18 02:48:50 +00:00
add websocket error handling
This commit is contained in:
@@ -131,6 +131,11 @@ export class GameServer {
|
||||
(c) => c.clientID != client.clientID,
|
||||
);
|
||||
});
|
||||
client.ws.on("error", (error: Error) => {
|
||||
if ((error as any).code === "WS_ERR_UNEXPECTED_RSV_1") {
|
||||
client.ws.close(1002);
|
||||
}
|
||||
});
|
||||
|
||||
// In case a client joined the game late and missed the start message.
|
||||
if (this._hasStarted) {
|
||||
|
||||
@@ -183,6 +183,11 @@ wss.on("connection", (ws, req) => {
|
||||
console.log(`errror handling websocket message: ${error}`);
|
||||
}
|
||||
});
|
||||
ws.on("error", (error: Error) => {
|
||||
if ((error as any).code === "WS_ERR_UNEXPECTED_RSV_1") {
|
||||
ws.close(1002);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function runGame() {
|
||||
|
||||
Reference in New Issue
Block a user