Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please update ITransport interface #127

Open
passby6someone opened this issue Jun 10, 2023 · 0 comments
Open

Please update ITransport interface #127

passby6someone opened this issue Jun 10, 2023 · 0 comments

Comments

@passby6someone
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant