Solve it. Need to check for sessionId also. Thanks for help ! cheers !
Posts made by Soh Sea Kiat
Hi I tried to remove the previous login client at requestJoin part by matching client Id and I can successfully remove the previous login client. But If the client is the last person in the room, the room will get disposed and new room will be created for the second login client. And this will cause a remoteroom call promised error. Is there better way for kick out first login client instead of detecting at requestJoin? Please advise please.
requestJoin (options) {
console.log("request join!", options);
for(var id in this.clients)
{
if(options.clientId == this.clients[id].id)
{
this.clients[id].close();
}
}
return true;
}
Hi @endel I already used client.Rejoin() to get reconnect back from client side, and I can successfully reconnect back to server with a new coroutine, just that after the reconnection, I couldn't recieve any update from server side but still can room.send() data to the server.
@endel Yup, after Rejoin,
anything in try block still can pass back to client, but when client send message to the room, or any update on roomstate, client won't listen any changes anymore, seems to me server is not casting data back to reconnected client
code block
async onLeave (client, options) {
console.log(client.id+ " Leaving...");
// inactivateclient
this.state.deactivateClient(client);
this.broadcast({isDeactivated: client.id});
try {
// allow disconnected client to rejoin into this room until 20 seconds
await this.allowReconnection(client, 300);
// client returned! let's re-activate it.
console.log(client.id + " reconnect back !");
this.state.activateClient(client);
// push updated roominfo to reconnect client
this.broadcast({isActivated: client.id});
} catch (e) {
// 20 seconds expired. let's remove the client.
this.state.removePlayer(client);
}
}
onMessage (client, data) {
if(data.isInit != undefined){
this.state.changePlayerReady(client, data.color, data.isReady);
this.broadcast({test: "message"});
}
}
After reconnect client, if there is any state changes, the unity client room listener won't pick up any update on room state.
The reconnected client can send signal to server, but server update on roomstate, or broadcast, or send message to client all failed. The client stop receive any feedback. Anyone can help me?