I'm developing android application where users can compete in some kind of battles. On the server side I need to receive requests from user for starting a battle, and then, using some algorithm, choose the most preferable opponent for him. During a battle I also need to send notifications to competitors about their opponent's actions.
So it seems that I need to implement long polling on my server. My questions are:
Server side. I'm using asp.net mvc server. I had a look at SignalR framework and it seems to be just what I need. However, just because I'm new to long polling, I haven't understood its internal principles of work. So I need explanations on how to use this framework, or how to implement long polling some other way.
Client side. As far as I understood, long polling requests model slightly differs from standard "request-response" model, so I'm also wondering how to implement these requests on client side.
I'm looking forward to any explanations on subjects that I've described.
This might not be the answer you are looking for, but why do you want to go for long polling. you can do the "pull"
kind of polling for this type of notifications IF you are only polling when the users are engaged in battles.
This way battery life will also be saved.
When the battle starts, start a background service, which polls the server every 2-3 seconds
(hope a latency of 2-3 seconds is acceptable). And notify the user accordingly. Then stop the service when the battle is over.
This will be far more easier to implement.
But if you need instantaneous notification, you can use Google Cloud Messaging Service(it is a form of long-polling). To know more about how it works, see this
I am not sure, if you have considered WCF.
Take a look onto this, see if it helps you. http://anthymecaillard.wordpress.com/2012/06/06/wcf-real-time-web-development-with-long-polling/
For client: Use Jquery, with progress wheel showing till our response is back from the server
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With