Hi
Is it possible to connect to more than 1 devices using the new GameKit framework? Till now all the examples I've seen show how we can connect to 1 device. Even the default connection interface lets the user select just one connect.
Thanks.
Hi
Is it possible to connect to more than 1 devices using the new GameKit framework? Till now all the examples I've seen show how we can connect to 1 device. Even the default connection interface lets the user select just one connect.
Thanks.
To the best of my knowledge, when using the GameKit framework you can only couple a pair of devices, one acting as a server and the other as a client (if both are initialized as peers, you will have to decide which one will act as a server, either arbitrarily or by selecting one randomly).
In practice, there may be many devices all running your application, but connections will always be established through paired devices.
Of course, you can write your own bonjour-based networking code over wifi and overcome this limit though it will require much more coding.
You can connect up to four devices using Gamekit. I believe that you can only do two when in Peer mode, to do more than two requires one device be set as master and the others in client mode.
I'd look for examples that demonstrate use of master/client, the client side should apply to all three.
There's a fairly good overview here at the following link of how to configure and use GameKit for your App.
Unfortunately, you will not be able to use the GKPeerPickerController standard UI picker to configure the GKSession instance for you if you want to support more than 2 devices. Instead, you must develop your own UI elements to setup and configure the connections between the master/server and the multiple clients.
Here's a simple way to enable GameKit for more than 2 devices:
When you initialize a GKSession instance with initWithSessionID:displayName:sessionMode, use:
sessionMode:GKSessionModePeer is the 3rd available option and is the option used in most sample code provided by Apple such as the GKTank demo.
Note: You can probably use GKSessionModePeer and still have a network of more than 2 devices since peer mode puts the device in server and client mode at the same time until a connection is made. Explicitly configuring one device as the server may simplify the setup which is useful for testing the GameKit API.
For the server:
GKSession *session = [[GKSession alloc] initWithSessionID:kTestSessionID displayName:nil sessionMode:GKSessionModeServer];
For the client(s):
GKSession *session = [[GKSession alloc] initWithSessionID:kTestSessionID displayName:nil sessionMode:GKSessionModeClient];