Chapter 15. Peer-to-peer connections using Game Kit

 

This chapter covers

  • Overview of Game Kit
  • Creating peer-to-peer applications using the peer picker
  • Building a multiplayer game

Networking has always been a complicated task in any programming language. It normally requires intimate knowledge of sockets, as well as a solid understanding of various network protocols such as TCP/IP and UDP. Apple has simplified this process with the release of the Game Kit framework.

In this chapter, we’ll take a tour of the Game Kit framework. Then, we’ll examine how to create peer-to-peer applications and a simple multiplayer game.

15.1. Overview of Game Kit

Game Kit is a framework that provides some simple yet powerful classes for accomplishing various networking tasks. These classes are built on top of the Bonjour protocol and do much of the heavy lifting needed for peer-to-peer interaction.

Although the Game Kit framework was primarily intended for game development, it isn’t limited to that. Many applications incorporate the Game Kit framework to accomplish network-related tasks. These tasks may be as simple as sharing photos or as complex as multiuser collaboration on a drawing board.

In Game Kit, peers communicate through objects called sessions. Each peer creates a session and uses it to discover other sessions. The sessions are also responsible for sending data to and receiving data from each peer.

15.2. Creating peer-to-peer applications using the peer picker

15.3. Example: creating a multiplayer table tennis game

15.4. Summary