On Fri, Sep 30, 2011 at 9:00 AM, Andrew McNabb <[email protected]> wrote: > On Fri, Sep 30, 2011 at 11:44:27AM -0400, Matthew Gardner wrote: >> >> How does the server notify players >> when it is their turn, with the updated state? > > I think in these cases that people usually write Javascript code on the > client that performs a request and waits for a response. The server > waits to respond to the request until the appropriate condition is met. > This may increase the load on the server because it has to keep > connections open even when nothing is happening, but I don't think > there's really any other way to do it (other than polling which is > arguably worse).
I think polling usually means to check once every x seconds to see if there is a new message. If there is something new, return it; if there is nothing new, return nothing. A different technique is to check for a new message and avoid returning anything until there is something to return. If the connection times out, open a new connection. This avoids opening and closing lots of connections but it also ties up a connection the whole time the app is running. The tradeoffs between these depend in part on how the server handles new messages. If each connection (long or short) goes to an app, there might be overhead involved in starting up the app lots of times. If short polls go to a static location that some worker process populates, or if they go to an app that remains running, this significantly reduces the overhead involved in terms of server load. Wikipedia has a good introduction and references to these and some other techniques: http://en.wikipedia.org/wiki/Comet_(programming) -- Peter Henderson [email protected] -------------------- BYU Unix Users Group http://uug.byu.edu/ The opinions expressed in this message are the responsibility of their author. They are not endorsed by BYU, the BYU CS Department or BYU-UUG. ___________________________________________________________________ List Info (unsubscribe here): http://uug.byu.edu/mailman/listinfo/uug-list
