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) 
Designated initializer. More...
(instancetype) 
- init
Default initializer is not available. More...
(NSInteger) 
Sends a request to the receiver to put the last used player on this sender into the GCKPlayerStateAvailable state. More...
Sends a request to the receiver to put the player into the GCKPlayerStateAvailable state. More...
(NSInteger) 
Sends a request to the receiver to put the last used player on this sender into the GCKPlayerStateReady state. More...
Sends a request to the receiver to put the player into the GCKPlayerStateReady state. More...
(NSInteger) 
Sends a request to the receiver to put the last used player on this sender into the GCKPlayerStatePlaying state. More...
Sends a request to the receiver to put the player into the GCKPlayerStatePlaying state. More...
(NSInteger) 
Sends a request to the receiver to put the last used player on this sender into the GCKPlayerStateIdle state. More...
Sends a request to the receiver to put the player into the GCKPlayerStateIdle state. More...
(NSInteger) 
Sends a request to the receiver to put the last used player on this sender into the GCKPlayerStateQuit state. More...
Sends a request to the receiver to put the player into the GCKPlayerStateQuit state. More...
(NSInteger) 
Sends a game-specific message to the receiver. More...
(NSInteger) 
Sends a game-specific message to the receiver. More...
(void) 
Sends a game-specific message to the receiver. More...
Sends a game-specific message to the receiver. More...
(instancetype) 
Designated initializer. More...
Called when a text message has been received on this channel. More...
(BOOL) 
Sends a text message on this channel. More...
Sends a text message on this channel. More...
(NSInteger) 
Generates a request ID for a new message. More...
(NSNumber *__nullable) 
A convenience method which wraps the result of generateRequestID in an NSNumber . More...
(void) 
Called when this channel has been connected, indicating that messages can now be exchanged with the Cast device over this channel. More...
(void) 
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

The delegate for receiving notifications from the GCKGameManagerChannel . More...
The current state of the game manager. More...
NSString * 
The last controllable player ID used in this session. More...
Whether this channel is connected with the receiver's Game Manager and we are ready to interact with it. More...
NSString * 
The channel's namespace. More...
BOOL 
A flag indicating whether this channel is currently connected. More...
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
castSessionID
The 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
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 .
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
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.
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
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 .
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
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.
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
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 .
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
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.
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
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 .
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
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.
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
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 .
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
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.
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
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 .
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
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.
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
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

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

Designated initializer.

Constructs a new GCKCastChannel with the given namespace.

Parameters
protocolNamespace
The 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
message
The message.
- (BOOL) sendTextMessage: (NSString *)  message

Sends a text message on this channel.

Parameters
message
The 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
message The message.
error A 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

read write nonatomic weak

The delegate for receiving notifications from the GCKGameManagerChannel .

- ( GCKGameManagerState *) currentState
read nonatomic strong

The current state of the game manager.

- (NSString*) lastUsedPlayerID
read nonatomic copy

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
read nonatomic assign

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
read nonatomic copy inherited

The channel's namespace.

- (BOOL) isConnected
read nonatomic assign inherited

A flag indicating whether this channel is currently connected.

- ( GCKDeviceManager *) deviceManager
read nonatomic weak inherited

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 .
Create a Mobile Website
View Site in Mobile | Classic
Share by: