Replies: 1 comment 3 replies
-
Hi @ibeallc, each connection and reconnection generates a new |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone,
I'm encountering an issue with the allowReconnection function in my game server code. The function works correctly for the initial reconnection attempt, but fails on subsequent attempts. Here’s the relevant part of my onLeave method:
`
async onLeave(client: Client, consented: boolean) {
let self = this;
// Find the player based on session ID
let player = this.findPlayerBySessionId(client.sessionId);
if (player) {
// Mark the player as away
player.away = true;
} else {
console.log('Player not found');
return;
}
try {
if (consented) {
// Handle consented leave
self.removePlayersInfo(client.sessionId);
this.rmPlayerFromGame(client.sessionId);
self.activePlayers--;
throw new Error('consented leave');
}
} catch (e) {
// Handle unsuccessful reconnection
console.log('Reconnection not successful', e);
self.activePlayers--;
}
}
`
Issues Observed:
Error Message:
❌ reconnection token invalid or expired. Did you miss .allowReconnection()?
👉 https://docs.colyseus.io/server/room/#allowreconnection-client-seconds
Beta Was this translation helpful? Give feedback.
All reactions