Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone p2p - Is there a way to connect to more than 1 devices?

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.

like image 802
lostInTransit Avatar asked Jul 05 '09 13:07

lostInTransit


People also ask

Does iOS support Wifi Direct?

The official list of current iOS Wi-Fi Management APIs. There is no Wi-Fi Direct type of connection available. The primary issue being that Apple does not allow programmatic setting of the Wi-Fi network SSID and password.

What is peer to peer on Iphone?

Here, the app uses Apple's Multipeer Connectivity framework, essentially a peer-to-peer feature that lets you share messages (and soon photos) with other app users nearby, regardless of whether you have an actual Wi-Fi or cellular connection.


1 Answers

There's a fairly good overview here at the following link of how to configure and use GameKit for your App.

  • GameKit Programming Guide: Peer-to-Peer Connectivity

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:GKSessionModeServer for the server/master
  • sessionMode:GKSessionModeClient for the other (multiple) clients

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]; 
like image 124
ericdagenais Avatar answered Oct 20 '22 00:10

ericdagenais