Colyseus leaving room part 3
There hasn't been made any client side communication yet and I have worked for over a month on this room leaving situation.
I really hope this isn't the way that all the other stuff is going to turn out :(
Sending 'LEAVE' to the server and let the server disconnect the client is also not reliable!
Modified SocketSys.hx to avoid crash on windows:
// Do not use (e:Error).match(Error.Custom(Error.Blocked)) ||
needClose = !(e == 'Blocking' || (Std.is(e, Error) && (
(e:Error).match(Error.Blocked))
));
New direction : Plan for failure!
Since I cannot do a steady leave room and since there can be other situations that lead to errors: I decided that the client/game needs to react on the errors.
This led to changes to the Colyseus HaXe code since some errors (websocket and connection) aren't passed to Room.onError
Connection.hx
// This does not throw onError on room .. this message cannot be detected
this.ws.onerror = function(message) {
this.onError(message); // this isn't caught in Room.onError !!!!
// Stencyl notification (import com.stencyl.behavior.Script.*;)
if(getGameAttribute("ColyseusErrorMessage") == null)setGameAttribute("ColyseusErrorMessage", ""); setGameAttribute("ColyseusErrorMessage", ""+getGameAttribute("ColyseusErrorMessage")+" : "+message); //M.E.
}
Unfortunately Mac OSX build still produces crash sometimes
[My Game] 2019-02-25 00:36:22.937 My Game[28583:2109033] -[NSPersistentUIWindowSnapshotter writeWindowSnapshot:length:width:height:bytesPerRow:toFile:inDirectory:encryptingWithKey:uuid:checksum:fd:]: 0 == ftruncate(fd, finalFileSize) failed on line 797: Bad file descriptor
[My Game] 2019-02-25 00:36:22.939 My Game[28583:2109033] -[NSPersistentUIWindowSnapshotter writeWindowSnapshot:length:width:height:bytesPerRow:toFile:inDirectory:encryptingWithKey:uuid:checksum:fd:]: 0 == ftruncate(fd, fileLength) failed on line 868: Bad file descriptor
DEBUG [Thread-17] stencyl.sw.util.net.SocketServer: _disconnected: Socket[addr=/127.0.0.1,port=49807,localport=18525]
As well as the Android build for which I am unable to get logs.
But it happens less than before.
There are also situations where there are rooms left with 0 clients in them, even when the application/game is killed. And even the Colyseus monitor
Now it is time to work on the room information like a playerlist. Hopefully this does not take much time and doesn't interfere with the current workaround.
Still, if anyone has any tips , experiences or possible things I can try relating to the (e:Error).match(Error.Custom(Error.Blocked)) ||
or the Mac OSX Bad file descriptor
I very much like to know!!