This won't work in a @colyseus/proxy
so it's not really a good solution.
0
Reputation
3
Posts
1206
Profile views
0
Followers
0
Following
Posts made by holywyvern
RE: Is there a way to disconnect a client by id from the server?
posted in Questions & Help •
Is there a way to disconnect a client by id from the server?
posted in Questions & Help •
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.
Is there a way to use colyseus.js on a node environment in a non "hack" way ?
posted in Questions & Help •
For the moment I have found one can "hack" it using something like:
const Storage = require("dom-storage");
global.WebSocket = require("uws");
global.window = global;
global.localStorage = new Storage(null, { strict: true });
But it has many problems, like populating the global namespace.
If this is still not good enough, one may prefer to create colyseus.js/server and use that inside node. I don't believe it should be required a new package to make a node integration, mostly because a lot of the code should be the same.