Is there a way to disconnect a client by id from the server?
-
I want to know if is there a way to do something like the following:
const server = new colyseus.Server({ ... }); // Somewhere on a room: ... async onJoin(client) { if (someLogin) { // This disconnects a client based on id this.server.disconnect(anotherClientId); } } ...
I would like such a feature, to be able to make a client only join a single room at a time, for example. Or if an account is logged in two computers, disconnect the older connection.
-
... let playerList=new Map();//store player client info async onAuth(Client client,options){ if(validate(options.token){ //if already joined if(playerList.get(options.token)){ //disconnect old clients this.clients.foreach(oldClient){ if(client.id==playerList.get(options.token)) oldClient.discontent(); } } playerList.set(options.token,client.id,) } } ...
-
This won't work in a
@colyseus/proxy
so it's not really a good solution.