5

the gamekit over wifi documentation talks about local wifi and that it's built on top of bonjour. Does that mean it does not work over the Internet, locating user/players in a different subnet, different ISP ... etc

If I need to connect to players/users on the Internet in general I assume I need to setup a server, right ?

sam
  • 83
  • 6

2 Answers2

5

YES, Game Kit can be used to connect peers over Internet.

BUT in this case your application must respond to peerPickerController:didSelectConnectionType: and handle all your private handshake protocol to discover peers and establish communication. A web service on your server is also required (unless users type in their IP address).

Good luck Sam!


References:

Apple IOS Reference Library, Game Kit Programming Guide.

Sanford University Online Course, iPhone Development, Lecture 17: Bonjour, NSStream, GameKit (see at 48 min 28 sec).

rjobidon
  • 3,055
  • 3
  • 30
  • 36
  • That's a shame, hoped gameKit would do the heavy lifting. – sam Dec 03 '10 at 15:46
  • 1
    I've watched the Stanford video and read through the docs. What's not clear to me is, if you implement the web service to pair up users, can you still use GKSession's sendData and receiveData methods to communicate directly between connected peers over the internet, or do you need to implement the data transfer as well? – Christopher Pickslay Mar 16 '11 at 18:37
  • @ChristopherPickslay did you figure this out? I set up a service, that makes it possible to exchange peer ID's, but I would like to use GKSession to communicate. – Wim Haanstra Dec 21 '12 at 22:12
  • @WimHaanstra unfortunately no. It ended up for my purposes GameKit wasn't going to work, so we set up our own server. – Christopher Pickslay Dec 22 '12 at 00:17
  • @ChristopherPickslay I am looking for a way to connect two ios devices over the internet. Using our own server is an option, although I would prefer simpler code. Could you provide me with some pointers on where to start this whole process? Did you use CFNetwork? – Dan F Mar 22 '13 at 15:28
  • @DanF we ended up using a web server, with all peers posting and polling for events, so the communication is asynchronous, which changed the whole design of the app. I don't think GameKit is well suited to near-real time inter-device communication. – Christopher Pickslay Mar 22 '13 at 21:14
1

there are two things:

  • you can use gamekit to play with local devices using GKsessions
  • you can use gamekit to play over the internet using GKmatch

both methods are very similar, but it's not the case of just changing a flag - you will have to write code for each. if you are smart, you can make a small interface which can use both, based on a flag. I've implemented it and it works fine

Siegfried
  • 543
  • 3
  • 19