Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Socket.IO Rooms on different servers [closed]

My goal

I want to create a game with different playing rooms. Playing rooms are not connected in any kind. Only the one thing: I need to be able to move a player to other room.

My thought

There will be many users playing, so it will be a good thing to use many servers and many node-instances at each server.

I use

NodeJS with SocketIO. Playing rooms are SocketIO rooms. Each player is connected to only one room.

Question

But what I should do, if I need to move a user from one room at server #1 to another room at server #2?

Methods I know

I have found methods to have connection between servers by NoSQL as Redis. I can send events like this to other rooms.

But it seems to be better thing, I will send command to my client: "disconnect from server #1, connect to server #2, to room ..." (and store all possible rooms in redis client). So, it will be direct connection, not the "server #1 -> redis -> server #2". I want it to be fast.

Main question

Is there a way to transfer client connection from one server to another, fast and simple? Or may be use Redis pub-sub is not so bad by speed and it's ok to use it? What is the best solution?

Thank you.

like image 250
LevChurakov Avatar asked Feb 27 '26 04:02

LevChurakov


1 Answers

Redis is ok. It's pretty fast and easy to use.

like image 58
LevChurakov Avatar answered Mar 01 '26 19:03

LevChurakov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!