Question

Well...

I am working with an mobile application and a web server.

A characteristic of my web server is that it generates different set of data randomly. In other words, I cannot predict when the server will have ready data to send to the mobile app.

On other hand, the mobile app need to receive all data that the server generates. An approach could be request multiple times to get all these data. Indeed, It isn't a good approach, because I don't know when request the data.

If the mobile app could listen the server, after one start request or keep on the connection, for example, the server could sent any set of data in any time.

The question is: What is protocol suitable to this situation? How could I use that? Examples?

Thank you!

Was it helpful?

Solution

You could create a persistent TCP/IP connection to the server and permanently listen for incoming data (using a custom protocol or propably something websocket based). However such a permanent connection might seriously affect your battery life if it's for a mobile device. You will also lose the connection if the operating system automatically shuts down your application because it's out of memory.

The default approach to this problem are Push notification / Push services, where your server sends a notification about new data to a server of the phone provider (e.g. Microsoft or Apple push server), and this server sends the notification (as well as notificaiton from other online services) to your phone. Some info for Windows Phone: http://msdn.microsoft.com/en-us/library/hh221549.aspx http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff402558%28v=vs.105%29.aspx

Depending on how often you have new data both approaches can make sense.

OTHER TIPS

WebSockets could be the answer: http://en.wikipedia.org/wiki/WebSocket

Specifically, for Windows Phone, there's a solution also: http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff402558(v=vs.105).aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top