2

I'm working on a multiplayer board game on Node.js/Socket.IO. The flow is the following :

  • user enters his name and is added to the lobby
  • user select a room and is added to it, then game starts when he is joined by another user.

This part is petty easy and I've done it before. However, I now need the user to be able to join multiple game rooms at the same time. pages are dynamically generated by express, and there's no issue opening many game pages, but I'm struggling with the socket implementation.

  • Can I use a single socket for multiple rooms (for the same user) or do I have to create a new socket per room?
  • I'd like the user to always be able to chat within the lobby while in game. How do I sort that out?

Thanks

1 Answer 1

3

However, I now need the user to be able to join multiple game rooms at the same time. pages are dynamically generated by express, and there's no issue opening many game pages [...] Can I use a single socket for multiple rooms (for the same user) or do I have to create a new socket per room?

Pages open separately by the user do not share any context with each other. There are some hacky ways (such as a Flash LocalConnection), but you never should rely on these. Therefore, each page requires its own connection to your server.

I'd like the user to always be able to chat within the lobby while in game. How do I sort that out?

However you want. That implementation is up to you. If you are currently using the Socket.IO "rooms" feature, I suggest not using it so you have maximum flexibility in your implementation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.