1

Original question: The iOS Developer Library mentions in the Game Kit Programming Guide that

The maximum size of a client-server game is 16 players.

Does this limitation also apply to P2P GKsessions?

This was already kind-of asked here (but from a different angle).

Updated question:Is GKSession reliable when more than 4 peers are connected?

note:The question was updated based on the response by saulobrito below.

Reference: One example of an app that uses a large group of peers connected is Seedio. You will notie that they are not using GKSession as bluetooth is not an option for connectivity (with GKSession, you can't even chose bluetooth or wi-fi.. GKSession does that for you.) Check out their FAQ for some interesting information about why they chose Wi-fi rather than bluetooth.

Community
  • 1
  • 1
abbood
  • 23,101
  • 16
  • 132
  • 246
  • Bump. The documentation is unclear if the limit of 16 applies to the client-server version, or to that AND the peer-to-peer version. Is peer-to-peer just two client-server schemes put together, or is the peer-to-peer version excepted from the limitation? – Jeff Sep 01 '12 at 07:43
  • I would like to know the answer to that my self too! – abbood Oct 23 '12 at 06:46

2 Answers2

3

What I can assure you is that GKSession is very unstable and you should not trust these docs. In fact, Apple recently decided to remove the documentation altogether.

I did a lot of testing and I would suggest that the practical limit is 4 connected devices (one acting as a server and 3 clients). Of course it's better that you do your own testing scenario.

I also couldn't find any game that allows more than 4 players. The only that I knew was Apple own Texas Hold'em - which allowed 8 players, but they decided to remove it.

And last, but not least, Game Center imposes a 4 player limit to peer-to-peer games.

Yes I'm developing a game that should support 10 players but, in our tests, it became unstable/unusable when there were more than 4 devices. By unstable I mean: sometimes you can't find a peer and connection drops in less than a minute. To make matters worse, updating to iOS 6 brought some strange behaviors like freezing (no error, no stack trace, no nothing) while trying to send a message. Other odd thing: when a player loses connection, all other players get disconnected.

EDIT: did a lot of testing since that response and have more information to share:

Using iOS 6 I was able to play reliably with 9 devices using either wi-fi or bluetooth. There's stil a huge issue although: You can't connect devices using iOS 6 with devices using iOS 5 cause you will face unexplainable freezing-with-no-stack-trace time to time if any of the devices is with its wi-fi enabled. You either set iOS 6 as the minimum supported version for your App or you will have to ask users to disable their wi-fi and use bluetooth.

Pedro Andrade
  • 4,556
  • 1
  • 25
  • 24
  • very interesting.. i'm kind of reaching the same conclusion myself.. So can you say that using bonjour would give more reliable results? and can you tell me a little more about your testing? are you testing a game in real time? and when you say unreliable.. is it in the form of connecting a device to another or too many dropped packets or losing connection half way etc? – abbood Oct 23 '12 at 06:45
  • I'm not an expert but I'd suggest that yes. You can use DNS-SD for advertise/discovery and build a socket server to keep the conversation going on. Isn't straightforward as GKSession but it's probably a safer bet. Here's a good answer about it: http://stackoverflow.com/questions/3844189/bonjour-over-bluetooth-without-gamekit. – Pedro Andrade Oct 23 '12 at 14:54
  • Thanks for your important findings.. i'll actually change the title and question to reflect your answer, as your findings are more important than what i was asking for.. +1 – abbood Oct 24 '12 at 04:57
3

On iOS 6.0 I can confirm that GKSession allows at least 6 players. I have found that you must make sure not to send messages to a peer until the state changes to connected though.

Overall, I think GKSession is a wonderful and simple API. It will use bluetooth or WiFi, meaning that you don't even have to think about whether the phone is connected to a WiFi network. The latency is nice and low ( I measured it at 4ms for unreliable and around 10ms for reliable networking ).

My main caveats are:

  1. Use unreliable messaging if you can.
  2. Make sure you set .available to NO on application exit ( if you're terminated while advertising, you may leave phantom sessions open ).
  3. Do not try and send messages to a peer until the peer in question changes to the connected state.
  4. Don't try to re-use a gksession once you've been disconnected.
  5. You may need to retry a connection attempt ( I automatically retry 3 times if a connection attempt fails ). My timeout is 10 seconds.
  6. Throttle your reliable messaging. I haven't quite figured out what the limit is, but eventually it seems like you will blow a transmission buffer and then your latency will balloon. Again, this just isn't a problem when you use unreliable messaging.
Mark Pauley
  • 1,445
  • 12
  • 11