Understanding long polling: client (android) and server (asp net)
Asked Answered
S

2

5

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:

  1. 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.

  2. 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.

Serval answered 26/10, 2012 at 0:13 Comment(1)
Check out: hanselman.com/blog/… It shows you the basic and a working demo. I also believe SignalR would be great for your purpose, and it is not hard to use!Hoxie
C
5

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

Celia answered 2/11, 2012 at 4:9 Comment(0)
F
2

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

Fugacity answered 26/10, 2012 at 12:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.