Need a static variable which will be shared to all rooms

Hi,

I am new to colyseus. I just need a global static variable which will be shared to all rooms. The need of variable is due to stop login same account from multiple devices.

Nvm I am dumb, misunderstood the question...

You can use a database to do this, or redis. But you can't just share variables between rooms as they should be treated as if they have no way to communicate with each other.

You can have global variables only if you're running the server on a single-thread. If you're running on multiple threads, you can use this.presence inside the room handler (see docs for presence api)

As @seiyria suggested, for preventing the same user for joining multiple rooms (or the same room) it would make more sense to authenticate the user, and check the database instead during onAuth. Cheers!