Reputation: 10224
Ok, so I am developing a multiplayer game using: Node.js, Sockets.io & Redis
Anyway players are able to create a game, then start a game, now the game logic needs to be updated about once every 10 seconds, so this is done via calling a method, that will call itself each x seconds via setTimeout.
My concern is, that when a connected client connects, creates a game (starts the setTimeout cycle) and then disconnects, this will stop any setTimeout's, therefore killing the game for all other players. Even if the setTimeout keeps being fired when a user has disconnected, I would still like to ideally run this seperately to a users socket.io connection.
Is there a simple way to start a seperate process/thread in node.js? (from a connected socket.io connection)
Upvotes: 0
Views: 454
Reputation: 35011
Depending on your purposes, maybe. For instance there's this:
http://nodejs.org/api/child_process.html
if that's not it, you might want to look at node fibers
Upvotes: 1