node.js return to client waiting for event <p>I'm playing around a bit with the concept of Comet on node.js, but I'm still a bit confused and I'm wondering if anyone here can point me in the right direction.</p> <p>Think on a game app where client code should ask for it's turn to make a move (for example on a chess app). What I'm thinking here is in use something like this:</p> <p>When match starts a method on the node server is called to create an element on a matches array with the id of the match and the initial player.</p> <p>When a player makes a move a method is called to update the current player on the array element referencing this match. This method should fire an event when the change occurs.</p> <p>Before being able to make any move, client code should call a method on the server that checks if it's the turn of the user and that waits for the changing player event if wasn't it's turn.</p> <p>I'm not sure if this is a good approach within the event loop, and if it is I don't see how can I make the method to wait until event to return.</p> <p>Any suggestions?</p>