Description
I am using "colyseus.js": "^0.14.13".
When the player disconnects from the network, execute room.send(...)
console will log "WebSocket is already in CLOSING or CLOSED" error.
For catching this error and close game. I have tried to use room.onError
, room.connection.events.onclose
and window.onerror
, they're not working.
I found that error occurred in src/transport/WebSocketTransport.ts
const _send = ws.send;
ws.send = function (data: ArrayBuffer) {
if (ws.readyState == 1) {
bytesSent += data.byteLength;
}
_send.call(ws, data);
}
Then I found this issue close not called if a client disconnects due to network failure in websockets.
So I have to check websockets.readyState
before room.send
everytime.
I found ws object is exposed in WebSocketTransport
, but ITransport
interface not define this type.
Please update ITransport
interface for checking ws connection status.
PS: I am not a native English speaker. If there are any grammar errors, please forgive me