Hello
when i run unity example, i connect to my server, my server use Colyseus 0.9.24
but Unity get error "WebSocketSharp Error!An exception has occurred while receiving a message."
"WebSocketSharp Close!An exception has occurred while receiving a message.Code:1006"
what problem here?
Please help
Posts made by jack1604
i think you need send options max client to server
Example:
1.client
client.join("chat", {max_client:max_client});
2.server
onInit(options) {
var max_client = options.max_client;
this.maxClients= max_client;
}
Hello,
i want to create some room instance on server, how to?
i dont want to create room when client call join event, i only want to join room with room id by get list available room
thanks
@endel said in listen event disconnect on client and server:
Hi @jack1604, that's a good question, the
client
reference you're using onthis.send()
is the one that has been disconnected. The new - reconnected - client will be returned from theallowReconnection()
method.Example:
try { const reconnectedClient = await this.allowReconnection(client, 20); this.send(reconnectedClient, reconnectedClient.sessionId + ' rejoined'); } catch (e) { console.log(e); }
Hope this helps! Cheers!
hello,
if client disconnect or leave room , it will receive event on room.leave(), how to detect it is disconnect or leave room? because if client is disconnected, client will rejoin. if client leave room, client will not rejoin.
@endel said in listen event disconnect on client and server:
Hi @jack1604,
From client-side: http://colyseus.io/docs/client-room/#onleave
From server-side: http://colyseus.io/docs/api-room/#onleave-client-consentedCheers!
thanks,
when client rejoin success full, server will send a message, but if server send broadcast client will receive, if server send by method send, client will not receive
what the problem?
this is my code:
async onLeave (client, consented) {
var room = this;
console.log(new Date()," onLeave client.sessionId:", client.sessionId, ' consented:', consented);
this.broadcast(${ client.sessionId } left.
);
if(!consented){
client.active = false;
try {
await this.allowReconnection(client, 20);
client.active = true;
this.broadcast(client.sessionId + ' rejoined');// client will receive
this.send(client, client.sessionId + ' rejoined'); // client not receive
} catch (e) {
console.log(e);
}
}
}
Hello,
How to to listen event disconnect on client and server?
hello,
i want to close old connection when 1 user login on 2 device
My mean is:
onAuth (options){
return true;
}
requestJoin (options: any, isNew: boolean) {
return true;
}
onJoin (client) {
if(userId in this.players){
var old_client = this.players[userId];
old_client.close();
}
this.players[userId] = client;
}
How to do this?
@anubiscode
This is my log:
+Client 1 join by room "chat":
onJoin - clientId:77PVXQ9YI ssId:b9qJ3wBfy
+Client 2 join by room id which created by client 1:
onJoin - clientId:77PVXQ9YI ssId:undefined
hello,
i have 2 client, client 1 join use code: client.join("chat");
client 2 get available room, client 2 join use code: client.join(room_id);
client 1 have session id on server, but client dont have a session id
how to fix?
thanks