概览
用于游戏控制操作的 GCKCastChannel 子类。
如需查看委托协议,请参阅 GCKGameManagerChannelDelegate。
- Deprecated:
- 游戏管理器 API 不再受支持,并且将在未来的版本中移除。
继承 GCKCastChannel。
实例方法摘要 | |
(instancetype) | - initWithSessionID: |
指定初始化程序。更多… | |
(instancetype) | - init |
默认初始化程序不可用。更多… | |
(NSInteger) | - sendPlayerAvailableRequest: |
向接收方发送请求,以将此发送方上最后使用的播放器置于 GCKPlayerStateAvailable 状态。更多… | |
(NSInteger) | - sendPlayerAvailableRequest:playerID: |
向接收器发送请求,以将播放器置于 GCKPlayerStateAvailable 状态。更多… | |
(NSInteger) | - sendPlayerReadyRequest: |
向接收方发送请求,以将此发送方上最后使用的播放器置于 GCKPlayerStateReady 状态。更多… | |
(NSInteger) | - sendPlayerReadyRequest:playerID: |
向接收器发送请求,以将播放器置于 GCKPlayerStateReady 状态。更多… | |
(NSInteger) | - sendPlayerPlayingRequest: |
向接收方发送请求,以将此发送方上最后使用的播放器置于 GCKPlayerStatePlaying 状态。更多… | |
(NSInteger) | - sendPlayerPlayingRequest:playerID: |
向接收器发送请求,以将播放器置于 GCKPlayerStatePlaying 状态。更多… | |
(NSInteger) | - sendPlayerIdleRequest: |
向接收方发送请求,以将此发送方上最后使用的播放器置于 GCKPlayerStateIdle 状态。更多… | |
(NSInteger) | - sendPlayerIdleRequest:playerID: |
向接收器发送请求,以将播放器置于 GCKPlayerStateIdle 状态。更多… | |
(NSInteger) | - sendPlayerQuitRequest: |
向接收方发送请求,以将此发送方上最后使用的播放器置于 GCKPlayerStateQuit 状态。更多… | |
(NSInteger) | - sendPlayerQuitRequest:playerID: |
向接收器发送请求,以将播放器置于 GCKPlayerStateQuit 状态。更多… | |
(NSInteger) | - sendGameRequest: |
向接收者发送特定于游戏的消息。更多… | |
(NSInteger) | - sendGameRequest:playerID: |
向接收者发送特定于游戏的消息。更多… | |
(void) | - sendGameMessage: |
向接收者发送特定于游戏的消息。更多… | |
(void) | - sendGameMessage:playerID: |
向接收者发送特定于游戏的消息。更多… | |
(instancetype) | - initWithNamespace: |
指定初始化程序。更多… | |
(void) | - didReceiveTextMessage: |
当在此渠道上收到短信时调用。更多… | |
(BOOL) | - sendTextMessage: |
在此渠道上发送短信。更多… | |
(BOOL) | - sendTextMessage:error: |
在此渠道上发送短信。更多… | |
(NSInteger) | - generateRequestID |
为新消息生成请求 ID。更多… | |
(NSNumber *__nullable) | - generateRequestNumber |
一种便捷方法,用于将 generateRequestID 的结果封装在 NSNumber 中。更多… | |
(void) | - didConnect |
当此渠道已连接时调用,表示现在可以通过此渠道与 Cast 设备交换消息。更多… | |
(void) | - didDisconnect |
当此渠道已断开连接时调用,表示无法再通过此渠道与 Cast 设备交换消息。更多… | |
房源摘要 | |
id< GCKGameManagerChannelDelegate > | delegate |
用于接收来自 GCKGameManagerChannel 的通知的委托。更多… | |
GCKGameManagerState * | currentState |
游戏管理器的当前状态。更多… | |
NSString * | lastUsedPlayerID |
相应会话中使用的最后一个可控玩家 ID。更多… | |
BOOL | isInitialConnectionEstablished |
相应渠道是否已与接收方的游戏管理器连接,以及我们是否已准备好与之互动。更多… | |
NSString * | protocolNamespace |
频道的命名空间。更多… | |
BOOL | isConnected |
一个标志,用于指示相应渠道当前是否已连接。更多… | |
GCKDeviceManager * | deviceManager |
相应渠道注册到的设备管理器(如果有)。更多… | |
方法详细信息
- (instancetype) initWithSessionID: | (NSString *) | castSessionID |
指定初始化程序。
自动连接到接收者的游戏管理器。
- Parameters
-
castSessionID The Session ID corresponding to the currently connected Game Manager.
- (instancetype) init |
默认初始化程序不可用。
实现了 GCKCastChannel。
- (NSInteger) sendPlayerAvailableRequest: | (id __nullable) | extraData |
向接收方发送请求,以将此发送方上最后使用的播放器置于 GCKPlayerStateAvailable 状态。
如果此转换对相应播放器无效,则会在 GCKGameManagerChannelDelegate 中触发错误。如果没有上次使用的播放器,则当接收器响应此请求时,系统会注册一个新播放器,并将其播放器 ID 设置为上次使用的播放器 ID。此方法仅应在 gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) 委托回调收到消息后调用。如果 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 尚未连接到接收方的游戏管理器,则向 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 委托回调发送消息。GCKGameManagerChannel
- 另请参阅
- lastUsedPlayerID
- Parameters
-
extraData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil
.
- 返回
- 请求 ID;如果无法发送请求,则返回 kGCKInvalidRequestID。
- (NSInteger) sendPlayerAvailableRequest: | (id __nullable) | extraData | |
playerID: | (NSString *) | playerID | |
向接收器发送请求,以将播放器置于 GCKPlayerStateAvailable 状态。
如果此转换对相应播放器无效,则会在 GCKGameManagerChannelDelegate 中触发错误。如果玩家 ID 为 nil
,则系统会注册新玩家,并在接收方响应此请求时将其玩家 ID 设置为上次使用的玩家 ID。此方法仅应在 gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) 委托回调收到消息后调用。如果 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 尚未连接到接收方的游戏管理器,则向 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 委托回调发送消息。GCKGameManagerChannel
- Parameters
-
extraData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil
.playerID The player ID of the player whose state is to be changed.
- 返回
- 请求 ID;如果无法发送请求,则返回 kGCKInvalidRequestID。
- (NSInteger) sendPlayerReadyRequest: | (id __nullable) | extraData |
向接收方发送请求,以将此发送方上最后使用的播放器置于 GCKPlayerStateReady 状态。
如果该过渡状态对相应玩家无效,或者没有上次使用的玩家 ID,则会在 GCKGameManagerChannelDelegate 中触发错误。此方法仅应在 gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) 委托回调收到消息后调用。如果 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 尚未连接到接收方的游戏管理器,则向 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 委托回调发送消息。GCKGameManagerChannel
- 另请参阅
- lastUsedPlayerID
- Parameters
-
extraData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil
.
- 返回
- 请求 ID;如果无法发送请求,则返回 kGCKInvalidRequestID。
- (NSInteger) sendPlayerReadyRequest: | (id __nullable) | extraData | |
playerID: | (NSString *) | playerID | |
向接收器发送请求,以将播放器置于 GCKPlayerStateReady 状态。
如果该过渡状态对相应玩家无效,或者没有上次使用的玩家 ID,则会在 GCKGameManagerChannelDelegate 中触发错误。此方法仅应在 gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) 委托回调收到消息后调用。如果 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 尚未连接到接收方的游戏管理器,则向 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 委托回调发送消息。GCKGameManagerChannel
- Parameters
-
extraData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil
.playerID The player ID of the player to change the state.
- 返回
- 请求 ID;如果无法发送请求,则返回 kGCKInvalidRequestID。
- (NSInteger) sendPlayerPlayingRequest: | (id __nullable) | extraData |
向接收方发送请求,以将此发送方上最后使用的播放器置于 GCKPlayerStatePlaying 状态。
如果该过渡状态对相应玩家无效,或者没有上次使用的玩家 ID,则会在 GCKGameManagerChannelDelegate 中触发错误。此方法仅应在 gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) 委托回调收到消息后调用。如果 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 尚未连接到接收方的游戏管理器,则向 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 委托回调发送消息。GCKGameManagerChannel
- 另请参阅
- lastUsedPlayerID
- Parameters
-
extraData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil
.
- 返回
- 请求 ID;如果无法发送请求,则返回 kGCKInvalidRequestID。
- (NSInteger) sendPlayerPlayingRequest: | (id __nullable) | extraData | |
playerID: | (NSString *) | playerID | |
向接收器发送请求,以将播放器置于 GCKPlayerStatePlaying 状态。
如果该过渡状态对相应玩家无效,或者没有上次使用的玩家 ID,则会在 GCKGameManagerChannelDelegate 中触发错误。此方法仅应在 gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) 委托回调收到消息后调用。如果 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 尚未连接到接收方的游戏管理器,则向 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 委托回调发送消息。GCKGameManagerChannel
- Parameters
-
extraData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil
.playerID The player ID of the player to change the state.
- 返回
- 请求 ID;如果无法发送请求,则返回 kGCKInvalidRequestID。
- (NSInteger) sendPlayerIdleRequest: | (id __nullable) | extraData |
向接收方发送请求,以将此发送方上最后使用的播放器置于 GCKPlayerStateIdle 状态。
如果该过渡状态对相应玩家无效,或者没有上次使用的玩家 ID,则会在 GCKGameManagerChannelDelegate 中触发错误。此方法仅应在 gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) 委托回调收到消息后调用。如果 GCKGameManagerChannel 尚未连接到接收器的游戏管理器,则会向 GCKGameManagerChannel::gameManagerChannel:requestDidFailWithID:error: 委托回调发送消息。
- 另请参阅
- lastUsedPlayerID
- Parameters
-
extraData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil
.
- 返回
- 请求 ID;如果无法发送请求,则返回 kGCKInvalidRequestID。
- (NSInteger) sendPlayerIdleRequest: | (id __nullable) | extraData | |
playerID: | (NSString *) | playerID | |
向接收器发送请求,以将播放器置于 GCKPlayerStateIdle 状态。
如果该过渡状态对相应玩家无效,或者没有上次使用的玩家 ID,则会在 GCKGameManagerChannelDelegate 中触发错误。此方法仅应在 gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) 委托回调收到消息后调用。如果 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 尚未连接到接收方的游戏管理器,则向 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 委托回调发送消息。GCKGameManagerChannel
- Parameters
-
extraData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil
.playerID The player ID of the player to change the state.
- 返回
- 请求 ID;如果无法发送请求,则返回 kGCKInvalidRequestID。
- (NSInteger) sendPlayerQuitRequest: | (id __nullable) | extraData |
向接收方发送请求,以将此发送方上最后使用的播放器置于 GCKPlayerStateQuit 状态。
如果该过渡状态对相应玩家无效,或者没有上次使用的玩家 ID,则会在 GCKGameManagerChannelDelegate 中触发错误。此方法仅应在 gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) 委托回调收到消息后调用。如果 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 尚未连接到接收方的游戏管理器,则向 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 委托回调发送消息。GCKGameManagerChannel
- 另请参阅
- lastUsedPlayerID
- Parameters
-
extraData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil
.
- 返回
- 请求 ID;如果无法发送请求,则返回 kGCKInvalidRequestID。
- (NSInteger) sendPlayerQuitRequest: | (id __nullable) | extraData | |
playerID: | (NSString *) | playerID | |
向接收器发送请求,以将播放器置于 GCKPlayerStateQuit 状态。
如果该过渡状态对相应玩家无效,或者没有上次使用的玩家 ID,则会在 GCKGameManagerChannelDelegate 中触发错误。此方法仅应在 gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) 委托回调收到消息后调用。如果 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 尚未连接到接收方的游戏管理器,则向 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 委托回调发送消息。GCKGameManagerChannel
- Parameters
-
extraData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil
.playerID The player ID of the player to change the state.
- 返回
- 请求 ID;如果无法发送请求,则返回 kGCKInvalidRequestID。
- (NSInteger) sendGameRequest: | (id __nullable) | extraData |
向接收方发送特定于游戏的消息。
消息内容完全取决于应用。消息将来自 lastUsedPlayerID。接收者将通过 GCKGameManagerChannelDelegate 向此发送者发回响应。此方法仅应在 gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) 委托回调收到消息后调用。如果 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 尚未连接到接收方 GameManager,则委托回调 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p)。GCKGameManagerChannel
- Parameters
-
extraData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil
.
- 返回
- 请求 ID;如果无法发送请求,则返回 kGCKInvalidRequestID。
- (NSInteger) sendGameRequest: | (id __nullable) | extraData | |
playerID: | (NSString *) | playerID | |
向接收方发送特定于游戏的消息。
消息内容完全取决于应用。消息将来自 playerID
。如果 playerID
为 nil
,则使用 lastUsedPlayerID。接收者将通过 GCKGameManagerChannelDelegate 向此发送者发回响应。此方法仅应在 gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) 委托回调收到消息后调用。如果 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 尚未连接到接收方的游戏管理器,则向 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 委托回调发送消息。GCKGameManagerChannel
- Parameters
-
extraData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil
.playerID The id of the controllable player sending this message.
- 返回
- 请求 ID;如果无法发送请求,则返回 kGCKInvalidRequestID。
- (void) sendGameMessage: | (id __nullable) | extraData |
向接收方发送特定于游戏的消息。
消息内容完全取决于应用。消息将来自 lastUsedPlayerID。这是一种即发即弃的方法,无法保证消息已发送,并且接收者不会向此发送者发送响应。此方法仅应在 gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) 委托回调收到消息后调用。如果 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 尚未连接到接收方的游戏管理器,则向 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 委托回调发送消息。GCKGameManagerChannel
- Parameters
-
extraData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil
.
- (void) sendGameMessage: | (id __nullable) | extraData | |
playerID: | (NSString *) | playerID | |
向接收方发送特定于游戏的消息。
消息内容完全由应用决定。消息将来自指定的本地玩家 ID。这是一种“发送即忘”的方法,无法保证消息已发送,并且接收者不会向此发送者发送响应。此方法仅应在 gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) 委托回调收到消息后调用。如果 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 尚未连接到接收方的游戏管理器,则向 gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) 委托回调发送消息。GCKGameManagerChannel
- Parameters
-
extraData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil
.playerID The ID of the controllable player sending this message.
- (instancetype) initWithNamespace: | (NSString *) | protocolNamespace |
指定初始化程序。
使用给定的命名空间构造新的 GCKCastChannel。
- Parameters
-
protocolNamespace The namespace.
已在 GCKGenericChannel 中实现。
- (void) didReceiveTextMessage: | (NSString *) | message |
当在此渠道上收到短信时调用。
默认实现是一种空操作。
- Parameters
-
message The message.
- (BOOL) sendTextMessage: | (NSString *) | message |
在此渠道上发送短信。
- Parameters
-
message The message.
- 返回 成功时为
YES
,如果无法发送消息(因为渠道未连接,或者因为发送缓冲区目前过于拥挤),则为NO
。
- Deprecated:
- 使用 sendTextMessage:error:,该方法可提供详细的错误信息。
- (BOOL) sendTextMessage: | (NSString *) | message | |
error: | (GCKError *__nullable *__nullable) | error | |
在此渠道上发送短信。
- Parameters
-
message The message. error A pointer at which to store the error result. May be nil
.
- 返回 成功时为
YES
,无法发送消息时为NO
。
- (NSInteger) generateRequestID |
为新消息生成请求 ID。
- 返回
- 生成的 ID;如果渠道当前未连接,则为 kGCKInvalidRequestID。
- (NSNumber * __nullable) generateRequestNumber |
一种便捷方法,用于将 generateRequestID 的结果封装在 NSNumber 中。
- 返回
- 生成的 ID;如果渠道当前未连接,则为
nil
。
- (void) didConnect |
当此渠道已连接时调用,表示现在可以通过此渠道与 Cast 设备交换消息。
默认实现是一种空操作。
- (void) didDisconnect |
当此渠道已断开连接时调用,表示无法再通过此渠道与 Cast 设备交换消息。
默认实现是一种空操作。
媒体资源详情
|
readwritenonatomicweak |
用于接收来自 GCKGameManagerChannel 的通知的委托。
|
readnonatomicstrong |
游戏管理器的当前状态。
|
readnonatomiccopy |
|
readnonatomicassign |
相应渠道是否已与接收方的游戏管理器连接,以及我们是否已准备好与之互动。
此方法将从创建此渠道的时间点返回 NO
。
- 返回 如果此渠道已连接到接收方的游戏管理器并准备好进行互动,则为
YES
;否则为NO
。
|
readnonatomiccopyinherited |
渠道的命名空间。
|
readnonatomicassigninherited |
一个标志,用于指示相应渠道当前是否已连接。
|
readnonatomicweakinherited |
相应渠道注册到的设备管理器(如果有)。
- Deprecated:
- 如果此渠道未注册到已弃用的 GCKDeviceManager 类,则此值为
nil
。