1

I'm looking for a best-practice for the following scenario:

A Mobile Device (iOS) sends its (Sensor-)Data to another device (iPad, Laptop, PC, whatever) over the Internet in realtime.

Sure, I need a web service but as far as my understanding is, a webservice gets "called" and returns Data or takes Data. But I require a constant exchange of sensor data between two devices in nearly realtime. I'm looking to implement something like a Multiplayer Online Game, how do they do such a thing? Or the Glympse service?

buildsucceeded
  • 4,203
  • 4
  • 34
  • 72

4 Answers4

2

"Just because it's called GameKit doesn't mean its uses are limited to games. Any data you want to pump through that connection is fair game"

How true. The name GameKit is such a terrible misnomer, which very unfortunately diminishes it's significance, there are so much in this kit that you can do to develop serious apps.

user636910
  • 21
  • 2
0

The way I'd approach it is to create a "server" out there on the net, that would run some application (like a CGI script) to collect the data (store it, in maybe a database) - then allow the remote device to query it.

This means that every device has a "well-known service" which they are connecting to - potentially "logging into" - and selecting the data from.

For example, each "client" could push their "vessel name" and GPS location. The CGI script on the server would just put these in a MySQL database - as simple table containing "Vessel name" and "Location".

Alternativiley, clients could query and "pull" GPS locations for a specific vessel name. As simple CGI script that would take "Vesel Name" as a value, and send a MySQL query to the database to return the "Location". It could send the location (and vessel name) back in XML format.

The iPhone client could user NSXMLParser - or even a JavaScript "AJAX" client could use it's own inherent XML parsing capabilites to send a request for one (or more) vessels, and receive the results.

What you don't want to do is to have each client have to speak directly to each other client. This will get you into trouble with firewall rules, and mess up when you try to scale many-to-many communications.

Brad
  • 11,262
  • 8
  • 55
  • 74
  • This approach sounds solid, but will it be fast enough so that it feels like the Data is puched in realtime? Ok, I have to give it a try! And I'm with you on that comment that I don't want both lients to get a direct connection.. –  Nov 15 '10 at 09:35
  • If you want it to be "fast enough" - you need to think of how the client pulls data from the server, and how the server feeds it out. For example, rather than the client sending occasional "poll" requests from a server who does a database query - the client may want to do a blocking request in a background thread - which the server won't respond to until it has data. So you server-side code, when a new location comes in, would check all it's outstanding sessions to see who is waiting on this data, and then immediately send the data out to it. – Brad Nov 15 '10 at 17:33
0

If your devices are both running iOS, you can use the peer-to-peer connectivity functions in GameKit for this. There's a pretty good question and answer about that here.

Just because it's called GameKit doesn't mean its uses are limited to games. Any data you want to pump through that connection is fair game (so to speak).

Community
  • 1
  • 1
Dan Ray
  • 21,623
  • 6
  • 63
  • 87
  • As far as I understand, GameKit P2P works only over luetooth or local WiFi?! I have to send the Data over the Internet because sender and receiver are not in a local network together –  Nov 15 '10 at 09:32
0

You may use XMPP protocol to send/receive any xml data in almost realtime. You will need to create chat room and every XMPP client (your app) will just need to login to that room. Message that is sent to the room will be delivered to every XMPP client.

Info on protocol and public servers can be found here: http://xmpp.org/
Good book on XMPP: http://download.cnet.com/XMPP-The-Definitive-Guide/3000-20412_4-75114351.html
Link to free iOS XMPP library can be found here: iOS messenger SDK

Community
  • 1
  • 1
Dmytro
  • 86
  • 4