GCKGameManagerChannel Class

GCKGameManagerChannel Class Reference

Overview

A GCKCastChannel subclass for game control operations.

See GCKGameManagerChannelDelegate for the delegate protocol.

Deprecated:
The Game Manager API is no longer supported and will be removed in a future release.

Inherits GCKCastChannel.

Instance Method Summary

(instancetype) - initWithSessionID:
 Designated initializer. More...
 
(instancetype) - init
 Default initializer is not available. More...
 
(NSInteger) - sendPlayerAvailableRequest:
 Sends a request to the receiver to put the last used player on this sender into the GCKPlayerStateAvailable state. More...
 
(NSInteger) - sendPlayerAvailableRequest:playerID:
 Sends a request to the receiver to put the player into the GCKPlayerStateAvailable state. More...
 
(NSInteger) - sendPlayerReadyRequest:
 Sends a request to the receiver to put the last used player on this sender into the GCKPlayerStateReady state. More...
 
(NSInteger) - sendPlayerReadyRequest:playerID:
 Sends a request to the receiver to put the player into the GCKPlayerStateReady state. More...
 
(NSInteger) - sendPlayerPlayingRequest:
 Sends a request to the receiver to put the last used player on this sender into the GCKPlayerStatePlaying state. More...
 
(NSInteger) - sendPlayerPlayingRequest:playerID:
 Sends a request to the receiver to put the player into the GCKPlayerStatePlaying state. More...
 
(NSInteger) - sendPlayerIdleRequest:
 Sends a request to the receiver to put the last used player on this sender into the GCKPlayerStateIdle state. More...
 
(NSInteger) - sendPlayerIdleRequest:playerID:
 Sends a request to the receiver to put the player into the GCKPlayerStateIdle state. More...
 
(NSInteger) - sendPlayerQuitRequest:
 Sends a request to the receiver to put the last used player on this sender into the GCKPlayerStateQuit state. More...
 
(NSInteger) - sendPlayerQuitRequest:playerID:
 Sends a request to the receiver to put the player into the GCKPlayerStateQuit state. More...
 
(NSInteger) - sendGameRequest:
 Sends a game-specific message to the receiver. More...
 
(NSInteger) - sendGameRequest:playerID:
 Sends a game-specific message to the receiver. More...
 
(void) - sendGameMessage:
 Sends a game-specific message to the receiver. More...
 
(void) - sendGameMessage:playerID:
 Sends a game-specific message to the receiver. More...
 
(instancetype) - initWithNamespace:
 Designated initializer. More...
 
(void) - didReceiveTextMessage:
 Called when a text message has been received on this channel. More...
 
(BOOL) - sendTextMessage:
 Sends a text message on this channel. More...
 
(BOOL) - sendTextMessage:error:
 Sends a text message on this channel. More...
 
(NSInteger) - generateRequestID
 Generates a request ID for a new message. More...
 
(NSNumber *__nullable) - generateRequestNumber
 A convenience method which wraps the result of generateRequestID in an NSNumber. More...
 
(void) - didConnect
 Called when this channel has been connected, indicating that messages can now be exchanged with the Cast device over this channel. More...
 
(void) - didDisconnect
 Called when this channel has been disconnected, indicating that messages can no longer be exchanged with the Cast device over this channel. More...
 

Property Summary

id< GCKGameManagerChannelDelegatedelegate
 The delegate for receiving notifications from the GCKGameManagerChannel. More...
 
GCKGameManagerStatecurrentState
 The current state of the game manager. More...
 
NSString * lastUsedPlayerID
 The last controllable player ID used in this session. More...
 
BOOL isInitialConnectionEstablished
 Whether this channel is connected with the receiver's Game Manager and we are ready to interact with it. More...
 
NSString * protocolNamespace
 The channel's namespace. More...
 
BOOL isConnected
 A flag indicating whether this channel is currently connected. More...
 
GCKDeviceManagerdeviceManager
 The device manager with which this channel is registered, if any. More...
 

Method Detail

- (instancetype) initWithSessionID: (NSString *)  castSessionID

Designated initializer.

Automatically connects to receiver's Game Manager.

Parameters
castSessionIDThe Session ID corresponding to the currently connected Game Manager.
- (instancetype) init

Default initializer is not available.

Implements GCKCastChannel.

- (NSInteger) sendPlayerAvailableRequest: (id __nullable)  extraData

Sends a request to the receiver to put the last used player on this sender into the GCKPlayerStateAvailable state.

If this is not a valid transition for that player an error will be triggered in the GCKGameManagerChannelDelegate. If there is no last used player, a new player will be registered and its player ID will be set as the last used player ID when the receiver responds to this request. This method should only be called after the gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) delegate callback has been messaged. Messages the gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) delegate callback if the GCKGameManagerChannel is not yet connected to the receiver's Game Manager.

See also
lastUsedPlayerID
Parameters
extraDataCustom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil.
Returns
The request ID, or kGCKInvalidRequestID if the request could not be sent.
- (NSInteger) sendPlayerAvailableRequest: (id __nullable)  extraData
playerID: (NSString *)  playerID 

Sends a request to the receiver to put the player into the GCKPlayerStateAvailable state.

If this is not a valid transition for that player an error will be triggered in the GCKGameManagerChannelDelegate. If the player ID is nil a new player will be registered and its player ID will be set as the last used player ID when the receiver responds to this request. This method should only be called after the gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) delegate callback has been messaged. Messages the gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) delegate callback if the GCKGameManagerChannel is not yet connected to the receiver's Game Manager.

Parameters
extraDataCustom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil.
playerIDThe player ID of the player whose state is to be changed.
Returns
The request ID, or kGCKInvalidRequestID if the request could not be sent.
- (NSInteger) sendPlayerReadyRequest: (id __nullable)  extraData

Sends a request to the receiver to put the last used player on this sender into the GCKPlayerStateReady state.

If this is not a valid transition for that player or if there is no last used player ID, an error will be triggered in the GCKGameManagerChannelDelegate. This method should only be called after the gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) delegate callback has been messaged. Messages the gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) delegate callback if the GCKGameManagerChannel is not yet connected to the receiver's Game Manager.

See also
lastUsedPlayerID
Parameters
extraDataCustom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil.
Returns
The request ID, or kGCKInvalidRequestID if the request could not be sent.
- (NSInteger) sendPlayerReadyRequest: (id __nullable)  extraData
playerID: (NSString *)  playerID 

Sends a request to the receiver to put the player into the GCKPlayerStateReady state.

If this is not a valid transition for that player or if there is no last used player ID, an error will be triggered in the GCKGameManagerChannelDelegate. This method should only be called after the gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) delegate callback has been messaged. Messages the gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) delegate callback if the GCKGameManagerChannel is not yet connected to the receiver's Game Manager.

Parameters
extraDataCustom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil.
playerIDThe player ID of the player to change the state.
Returns
The request ID, or kGCKInvalidRequestID if the request could not be sent.
- (NSInteger) sendPlayerPlayingRequest: (id __nullable)  extraData

Sends a request to the receiver to put the last used player on this sender into the GCKPlayerStatePlaying state.

If this is not a valid transition for that player or if there is no last used player ID, an error will be triggered in the GCKGameManagerChannelDelegate. This method should only be called after the gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) delegate callback has been messaged. Messages the gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) delegate callback if the GCKGameManagerChannel is not yet connected to the receiver's Game Manager.

See also
lastUsedPlayerID
Parameters
extraDataCustom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil.
Returns
The request ID, or kGCKInvalidRequestID if the request could not be sent.
- (NSInteger) sendPlayerPlayingRequest: (id __nullable)  extraData
playerID: (NSString *)  playerID 

Sends a request to the receiver to put the player into the GCKPlayerStatePlaying state.

If this is not a valid transition for that player or if there is no last used player ID, an error will be triggered in the GCKGameManagerChannelDelegate. This method should only be called after the gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) delegate callback has been messaged. Messages the gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) delegate callback if the GCKGameManagerChannel is not yet connected to the receiver's Game Manager.

Parameters
extraDataCustom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil.
playerIDThe player ID of the player to change the state.
Returns
The request ID, or kGCKInvalidRequestID if the request could not be sent.
- (NSInteger) sendPlayerIdleRequest: (id __nullable)  extraData

Sends a request to the receiver to put the last used player on this sender into the GCKPlayerStateIdle state.

If this is not a valid transition for that player or if there is no last used player ID, an error will be triggered in the GCKGameManagerChannelDelegate. This method should only be called after gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) delegate callback has been messaged. Messages the GCKGameManagerChannel::gameManagerChannel:requestDidFailWithID:error: delegate callback if the GCKGameManagerChannel is not yet connected to the receiver's Game Manager.

See also
lastUsedPlayerID
Parameters
extraDataCustom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil.
Returns
The request ID, or kGCKInvalidRequestID if the request could not be sent.
- (NSInteger) sendPlayerIdleRequest: (id __nullable)  extraData
playerID: (NSString *)  playerID 

Sends a request to the receiver to put the player into the GCKPlayerStateIdle state.

If this is not a valid transition for that player or if there is no last used player ID, an error will be triggered in the GCKGameManagerChannelDelegate. This method should only be called after the gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) delegate callback has been messaged. Messages the gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) delegate callback if the GCKGameManagerChannel is not yet connected to the receiver's Game Manager.

Parameters
extraDataCustom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil.
playerIDThe player ID of the player to change the state.
Returns
The request ID, or kGCKInvalidRequestID if the request could not be sent.
- (NSInteger) sendPlayerQuitRequest: (id __nullable)  extraData

Sends a request to the receiver to put the last used player on this sender into the GCKPlayerStateQuit state.

If this is not a valid transition for that player or if there is no last used player ID, an error will be triggered in the GCKGameManagerChannelDelegate. This method should only be called after the gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) delegate callback has been messaged. Messages the gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) delegate callback if the GCKGameManagerChannel is not yet connected to the receiver's Game Manager.

See also
lastUsedPlayerID
Parameters
extraDataCustom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil.
Returns
The request ID, or kGCKInvalidRequestID if the request could not be sent.
- (NSInteger) sendPlayerQuitRequest: (id __nullable)  extraData
playerID: (NSString *)  playerID 

Sends a request to the receiver to put the player into the GCKPlayerStateQuit state.

If this is not a valid transition for that player or if there is no last used player ID, an error will be triggered in the GCKGameManagerChannelDelegate. This method should only be called after the gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) delegate callback has been messaged. Messages the gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) delegate callback if the GCKGameManagerChannel is not yet connected to receiver's Game Manager.

Parameters
extraDataCustom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil.
playerIDThe player ID of the player to change the state.
Returns
The request ID, or kGCKInvalidRequestID if the request could not be sent.
- (NSInteger) sendGameRequest: (id __nullable)  extraData

Sends a game-specific message to the receiver.

The message contents are entirely up to the application. The message will originate from lastUsedPlayerID. The receiver will send a response back to this sender via the GCKGameManagerChannelDelegate. This method should only be called after the gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) delegate callback has been messaged. Messages the gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) delegate callback if the GCKGameManagerChannel is not yet connected to the receiver GameManager.

Parameters
extraDataCustom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil.
Returns
The request ID, or kGCKInvalidRequestID if the request could not be sent.
- (NSInteger) sendGameRequest: (id __nullable)  extraData
playerID: (NSString *)  playerID 

Sends a game-specific message to the receiver.

The message contents are entirely up to the application. The message will originate from playerID. If playerID is nil, lastUsedPlayerID will be used. The receiver will send a response back to this sender via the GCKGameManagerChannelDelegate. This method should only be called after the gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) delegate callback has been messaged. Messages the gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) delegate callback if the GCKGameManagerChannel is not yet connected to the receiver's Game Manager.

Parameters
extraDataCustom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil.
playerIDThe id of the controllable player sending this message.
Returns
The request ID, or kGCKInvalidRequestID if the request could not be sent.
- (void) sendGameMessage: (id __nullable)  extraData

Sends a game-specific message to the receiver.

The message contents are entirely up to the application. The message will originate from lastUsedPlayerID. This is a fire-and-forget method where there's no guarantee that the message has been sent and the receiver won't send a response back to this sender. This method should only be called after the gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) delegate callback has been messaged. Messages the gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) delegate callback if the GCKGameManagerChannel is not yet connected to the receiver's Game Manager.

Parameters
extraDataCustom 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 

Sends a game-specific message to the receiver.

THe message contents are entirely up to the application. The message will originate from the specified local player ID. This is a fire and forget method where there's no guarantee the message is sent and the receiver won't send a response back to this sender. This method should only be called after the gameManagerChannelDidConnect: (GCKGameManagerChannelDelegate-p) delegate callback has been messaged. Messages the gameManagerChannel:requestDidFailWithID:error: (GCKGameManagerChannelDelegate-p) delegate callback if the GCKGameManagerChannel is not yet connected to the receiver's Game Manager.

Parameters
extraDataCustom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil.
playerIDThe ID of the controllable player sending this message.
- (instancetype) initWithNamespace: (NSString *)  protocolNamespace

Designated initializer.

Constructs a new GCKCastChannel with the given namespace.

Parameters
protocolNamespaceThe namespace.

Implemented in GCKGenericChannel.

- (void) didReceiveTextMessage: (NSString *)  message

Called when a text message has been received on this channel.

The default implementation is a no-op.

Parameters
messageThe message.
- (BOOL) sendTextMessage: (NSString *)  message

Sends a text message on this channel.

Parameters
messageThe message.
Returns
YES on success or NO if the message could not be sent (because the channel is not connected, or because the send buffer is too full at the moment).
Deprecated:
Use sendTextMessage:error: which provides detailed error information.
- (BOOL) sendTextMessage: (NSString *)  message
error: (GCKError *__nullable *__nullable)  error 

Sends a text message on this channel.

Parameters
messageThe message.
errorA pointer at which to store the error result. May be nil.
Returns
YES on success or NO if the message could not be sent.
- (NSInteger) generateRequestID

Generates a request ID for a new message.

Returns
The generated ID, or kGCKInvalidRequestID if the channel is not currently connected.
- (NSNumber * __nullable) generateRequestNumber

A convenience method which wraps the result of generateRequestID in an NSNumber.

Returns
The generated ID, or nil if the channel is not currently connected.
- (void) didConnect

Called when this channel has been connected, indicating that messages can now be exchanged with the Cast device over this channel.

The default implementation is a no-op.

- (void) didDisconnect

Called when this channel has been disconnected, indicating that messages can no longer be exchanged with the Cast device over this channel.

The default implementation is a no-op.

Property Detail

- (id<GCKGameManagerChannelDelegate>) delegate
readwritenonatomicweak

The delegate for receiving notifications from the GCKGameManagerChannel.

- (GCKGameManagerState*) currentState
readnonatomicstrong

The current state of the game manager.

- (NSString*) lastUsedPlayerID
readnonatomiccopy

The last controllable player ID used in this session.

This can be nil if there is no controllable player set up with the receiver.

See also
- sendPlayerAvailableRequest:
- (BOOL) isInitialConnectionEstablished
readnonatomicassign

Whether this channel is connected with the receiver's Game Manager and we are ready to interact with it.

This method will return NO from the point of creation of this channel.

Returns
YES if this channel is connected to the receiver's Game Manager and ready to interact it; NO otherwise.
- (NSString*) protocolNamespace
readnonatomiccopyinherited

The channel's namespace.

- (BOOL) isConnected
readnonatomicassigninherited

A flag indicating whether this channel is currently connected.

- (GCKDeviceManager*) deviceManager
readnonatomicweakinherited

The device manager with which this channel is registered, if any.

Deprecated:
If this channel was not registered with the deprecated GCKDeviceManager class, this will be nil.