Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Communication between iOS app installed on different devices on the same LAN

Tags:

ios

sockets

I have just delivered a prototype for a big client, everything was fine but I'm now curious to know if the solution/architecture I've chosen was the right one or there's place for improvement in case the project will keep on.

The task was to build two iOS apps: one running on 5 different iPhones, and another running on 2 iPads. Basically the iPhone applications had to communicate information to the iPads, and occasionally they also had to send information between each other (iPhone to iPhone). All the infos where small JSON objects/chunks whose size was small, really small.

The app was not intended to reach the app store, is a working prototype to test out some ideas in a user testing environment.

I discarded bluetooth because we are talking about a peer-to-peer communication, not a one-to-one.

What I did was to use web sockets thanks to SocketIO, through a small Node.js server that was running on my mac. The server was really simple, just receiving the messages from the clients and broadcasting information to the other ones.

What do you think? Is the solution I've chosen ok, or there are better ones?

For example, this morning I've just found out these thread here on SO, and I've discovered I could have used GameKit. What do you think?

like image 811
Sr.Richie Avatar asked Jun 17 '14 09:06

Sr.Richie


1 Answers

Socket.IO is nice because it is fairly simple to implement but it has the downside of requiring a central server. If you wanted to avoid that, you could use the Multipeer Connectivity framework that was introduced in iOS 7.

It will let you create one-to-one communication channels between devices on either the same WiFi network or Bluetooth. Once the channel is created, you can send whole NSData objects (or create streams but it doesn't seem relevant to your use case).

A good read : http://nshipster.com/multipeer-connectivity/

like image 118
Taum Avatar answered Sep 22 '22 23:09

Taum