Colyseus.js : client.onClose , client.onError not found.
-
On migrating to Colyseus.js 0.11.x , I could not find the onClose and onError callbacks in Colyseus client. Are they deprecated ?
-
hi @shashank , yes, those doesn't exist anymore in 0.11.
-
@dpastorini : Is there any way to detect connection lost from client-side ?Currently I am not getting any error or call back , when the connection is lost or the server goes down.
-
I was asking the same :P
@endel any ideas how we could detect on the client if the server is down?
We could check if the client left the room, but that's different from a connection error, we could make an user leave the room on purpose.
Maybe we will have to look for a work around and do some checks onLeave(), like set a property in the room before leave it, and then check for that property to see if we leave it on purpose or if the server just kicked the player.room.onLeave((code) => { if(room.leaving === true) { // all good, do nothing } else { alert('connection lost'); window.location.reload(); } });
-
Hi @dpastorini @shashank,
During
onLeave
in the client-side you can check for the code being anything else than1000
to detect an abnormal disconnection:room.onLeave(code => { if (code > 1000) { // abnormal disconnection! } else { // the client has initiated the disconnection } });
I've just fixed the closing codes on version
colyseus@0.11.7
, so please upgrade. I apologize for the inconvenience! 🙈
-
:D thanks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :D
-
@endel said in Colyseus.js : client.onClose , client.onError not found.:
1000
Hi @endel : Thanks for the update. Is there any way to detect disconnection when the player has not joined a room yet?