I am a newbie in node.js and socket.io. So I made a small project and tested some things with a small real-time chat, which works very nice. But I ask me, what's the best way to manage multiple games with node.js and socket.io?
Let's say, I want to create a website with some simple multiplayer card games. Each game should be a window with its own chat/room, a list of the players and a history for the game updates.
Is it better to set up all functions of each game in one big server.js file or run each game on its own process on the server (game1.js, game2.js...)?
The best practice in this case would be to store the game data in a database, and use an authentication method (like cookies/JWT) to know what data to serve to which player at any time. This design pattern allows for much less overhead because the game's logic is completely disconnected from the game's data, which means it can easily scale, and if a crash or a disconnection occurs, nothing is lost. It also removes the dependency to individual connections.