Hello there,
I am trying to implement reconnection if say a mobile device goes to sleep and can reconnect before 60 seconds is up. Here is example of the server code:
async onLeave(client: Client, consented: boolean = false) {
console.log(
"=========PLAYER LEFT THE GAME - BEFORE session connect: ",
client.sessionId
);
// flag player as disconnected
this.state.players[client.sessionId].connected = false;
console.log(
"=========PLAYER LEFT THE GAME - after session connect: ",
client.sessionId
);
try {
if (consented) {
throw new Error("consented leave");
}
// wait for his reconnection (20 seconds)
await this.allowReconnection(client, 60);
console.log("=====PLAYER IS BACK!!!!!! ", client.sessionId);
// player is back!
this.state.players[client.sessionId].connected = true;
} catch (e) {
console.log("client left game on bad term: " + client.sessionId);
this.state.removePlayer(client.sessionId);
this.disconnect();
}
}
But I always seem to get an error even if I get a console log the player is back first: (my console logs)
=====PLAYER IS BACK!!!!!! 1F79r2PHc
Error: seat reservation expired.
I am using colyseus version 0.11. The strange thing is the server knows a player reconnected and the client says joined successfully after reconnect method. It just shows that the seat reservation expired on client side & server side.