views:

39

answers:

1

If I am developing an iPad app (the "Server") which needs to communicate with up to 4 iPhone/iPod Touches (the Clients) how can I manage this? The two apps will be separate. Should I create 4 GKSessions for each of the iPhones? Should I have 1 GKSession which connects all 5 devices, and if I do, will each iPhone be able to "see" the others (Ideally, this shouldn't happen as it will keep things simple)? The apps will together be a bit like the Scrabble app for iPad (not in functionality, but in idea). How should I manage this?

Thanks in advance, and please comment if you need more information.

A: 

You should create a single session on the iPad, advertise it as a Server, and look for that session from each iPhone in client mode. The iPad should keep an array that has each peerID that is connected to it, most likely connected to or as part of some kind of array of controller or player objects. Since each iPhone is set to be a client, they only will be able to see the server session being advertised by the iPad, not the client signals coming from the other iPads.

If you want an iPhone to be able to signal another iPhone, you can pass out the array of peerIDs to each iPhone through some kind of messaging object, which will allow any particular iPhone to send a message directly to another iPhone.

I'm doing something similar with 1 or 2 iPads and up to 10 iPhones or iPad touches. With 2 iPads the game board gets expanded, and it allows more than 5 players.

fogelbaby