iPhone p2p - 有没有办法连接到多个设备? [英] iPhone p2p - Is there a way to connect to more than 1 devices?

查看:319
本文介绍了iPhone p2p - 有没有办法连接到多个设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用新的GameKit框架连接到多个设备?到目前为止,我见过的所有示例都显示了我们如何连接到1个设备。即使是默认的连接界面,用户也只能选择一个连接。

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.

谢谢。

推荐答案

这里有一个相当不错的概述,如下为你的应用程序配置和使用GameKit的链接。

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

不幸的是,你将无法使用 GKPeerPickerController 标准UI选择器,如果要支持2个以上的设备,可以为您配置GKSession实例。相反,您必须开发自己的UI元素来设置和配置主服务器和多个客户端之间的连接。

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.

这是一个简单的方法来启用GameKit以上2个设备:

Here's a simple way to enable GameKit for more than 2 devices:

使用 initWithSessionID:displayName:sessionMode 初始化GKSession实例时,请使用:

When you initialize a GKSession instance with initWithSessionID:displayName:sessionMode, use:


  • sessionMode:服务器/主服务器的GKSessionModeServer

  • sessionMode:GKSessionModeClient 其他(多个)客户

  • sessionMode:GKSessionModeServer for the server/master
  • sessionMode:GKSessionModeClient for the other (multiple) clients

sessionMode:GKSessionModePeer 是第3个可用选项,是大多数人使用的选项Apple提供的示例代码,例如GKTank演示。

sessionMode:GKSessionModePeer is the 3rd available option and is the option used in most sample code provided by Apple such as the GKTank demo.

注意:您可以使用GKSessionModePeer并且仍然拥有超过2个设备的网络,因为对等模式将设备放入服务器和客户端模式同时进行连接。将一个设备显式配置为服务器可以简化设置,这对于测试GameKit API非常有用。

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.

对于服务器:

GKSession *session = [[GKSession alloc] initWithSessionID:kTestSessionID displayName:nil sessionMode:GKSessionModeServer]; 

对于客户:

GKSession *session = [[GKSession alloc] initWithSessionID:kTestSessionID displayName:nil sessionMode:GKSessionModeClient]; 

这篇关于iPhone p2p - 有没有办法连接到多个设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆