O'Reilly logo

Swift Game Development - Third Edition by Stephen Haney, Siddharth Shekar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the multipeer session class

First, we will create an MCSession object to create a session. The init takes three parameters:

  1. The peerID of the current device.
  2. The security identity to secure the connection (in this case, we are not going to, as we are aware who we are connecting to).
  3. The encryption preference. We can specify the required, preferred, or undesirable encryption. We will enable encryption by stating the required encryption.

Next, we will add a button for the Advertiser and the Browser.

If the device is an Advertiser, then the AdvertiseSelf function will be called. This will start the MCAdvertiserAssistant to get ready to connect to other devices.

If the device is a Browser, then the user will click the browse button to look for ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required