Search code examples
c#webwindows-phonecommunication

Pooling vs sockets vs something else


I have a Windows Phone game that requires support for multiplayer. The multiplayer is similar to the one in Wordament: everyone plays the same game; the client gets the game initially, then the each player plays the game on his own without any interaction with the others and when the game ends, the results from everyone are collected and displayed. The difference is: in my application, the game doesn't end after a specified period of time but rather when one of the clients signals it. So, when someone completes the game (reaches a goal), all the others have to be notified that someone won.

My initial thought is pool the server every let's say 5 seconds to see if the game state has been changed. When a client completes the game, it sends a request with that info and all the other clients, upon the next pool request, will get the new status. This, IMO, is the simplest and most convenient solution because all I need is one byte of data to tell me if the game is over or not.

Real time (as in millisecond accuracy) is not critical. As you might have noticed in the previous paragraph, a 5 seconds delay is acceptable.

However, I am asking you, experts, if a duplex channel would be more appropriate for this scenario? I found solutions like Pusher which provide the two way channel but it seems to me that such a solution is very complex and expensive (we have a very limited budget).


Solution

  • Will share my current knowledge.

    Pull(Poll)
    Simple to implement, widely used.
    Examples: Facebook.com, TeamCity web interface, .NET Client for QPID Message Broker

    Push
    Take a look at this article
    Performance of HTTP polling duplex server-side channel in Microsoft Silverlight 3
    What I've noticed for myself: need extra efforts for configuration, possible issues with scalability and performance
    The only scenario I can think of - exchange of large amount of data on constant basis
    Example: Massively multiplayer online games(huges number of events, notification time is extremely critial)

    Get changes on demand
    Typical for bussines desktop application.
    Examples: TFS(refresh grids(tasks and bugs), get locked file status on check out)

    Conclusion: Pooling for your task fits ideally