GCKGameManagerChannel Class

GCKGameManagerChannel Class Reference

Overview

A CastChannel for game control operations.

Inherits GCKCastChannel.

Instance Method Summary

(instancetype) - initWithSessionID:
 Designated initializer. 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, its contents are entirely up to the application. More...
 
(NSInteger) - sendGameRequest:playerID:
 Sends a game specific message to the receiver, its contents are entirely up to the application. More...
 
(void) - sendGameMessage:
 Sends a game specific message to the receiver, its contents are entirely up to the application. More...
 
(void) - sendGameMessage:playerID:
 Sends a game specific message to the receiver, its contents are entirely up to the application. 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 *) - generateRequestNumber
 A convenience method which wraps 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...
 

Properties

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

Parameters
castSessionIDSessionID corresponding to currently connected GCKDeviceManager.
- (NSInteger) sendPlayerAvailableRequest: (id)  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 gameManagerChannelDidConnect: delegate callback has been executed. Triggers gameManagerChannel:requestDidFailWithID:error: if GCKGameManagerChannel is not yet connected to the game manager running on the receiver.

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)  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 playerId 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 gameManagerChannelDidConnect: delegate callback has been executed. Triggers gameManagerChannel:requestDidFailWithID:error: if GCKGameManagerChannel is not yet connected to the game manager running on the receiver.

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) sendPlayerReadyRequest: (id)  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 gameManagerChannelDidConnect: delegate callback has been executed. Triggers gameManagerChannel:requestDidFailWithID:error: if GCKGameManagerChannel is not yet connected to the game manager running on the receiver.

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)  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 gameManagerChannelDidConnect: delegate callback has been executed. Triggers gameManagerChannel:requestDidFailWithID:error: if GCKGameManagerChannel is not yet connected to the game manager running on the receiver.

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)  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 gameManagerChannelDidConnect: delegate callback has been executed. Triggers gameManagerChannel:requestDidFailWithID:error: if GCKGameManagerChannel is not yet connected to the game manager running on the receiver.

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)  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 gameManagerChannelDidConnect: delegate callback has been executed. Triggers gameManagerChannel:requestDidFailWithID:error: if GCKGameManagerChannel is not yet connected to the game manager running on the receiver.

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)  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: delegate callback has been executed. Triggers gameManagerChannel:requestDidFailWithID:error: if GCKGameManagerChannel is not yet connected to the game manager running on the receiver.

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)  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 gameManagerChannelDidConnect: delegate callback has been executed. Triggers gameManagerChannel:requestDidFailWithID:error: if GCKGameManagerChannel is not yet connected to the game manager running on the receiver.

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)  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 gameManagerChannelDidConnect: delegate callback has been executed. Triggers gameManagerChannel:requestDidFailWithID:error: if GCKGameManagerChannel is not yet connected to the game manager running on the receiver.

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)  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 gameManagerChannelDidConnect: delegate callback has been executed. Triggers gameManagerChannel:requestDidFailWithID:error: if GCKGameManagerChannel is not yet connected to the game manager running on the receiver.

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

Sends a game specific message to the receiver, its 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 function should only be called after gameManagerChannelDidConnect: delegate callback has been executed. Triggers gameManagerChannel:requestDidFailWithID:error: if 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)  extraData
playerID: (NSString *)  playerID 

Sends a game specific message to the receiver, its 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 function should only be called after gameManagerChannelDidConnect: delegate callback has been executed. Triggers gameManagerChannel:requestDidFailWithID:error: if 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.
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)  extraData

Sends a game specific message to the receiver, its 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 the message is sent and the receiver won't send a response back to this sender. This function should only be called after gameManagerChannelDidConnect: delegate callback has been executed. Triggers gameManagerChannel:requestDidFailWithID:error: if 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.
- (void) sendGameMessage: (id)  extraData
playerID: (NSString *)  playerID 

Sends a game specific message to the receiver, its contents are entirely up to the application.

The message will originate from the specified local playerID. 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 function should only be called after gameManagerChannelDidConnect: delegate callback has been executed. Triggers gameManagerChannel:requestDidFailWithID:error: if 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.
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).
- (BOOL) sendTextMessage: (NSString *)  message
error: (GCKError **)  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 *) generateRequestNumber

A convenience method which wraps 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 Documentation

- (id<GCKGameManagerChannelDelegate>) delegate
readwritenonatomicweak

The delegate for receiving notifications from the GCKGameManagerChannel.

- (GCKGameManagerState*) currentState
readnonatomicassign

The current state of the game manager.

- (NSString*) lastUsedPlayerID
readnonatomicassign

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 and the GameManager and ready to interact with. 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.

Google Cast iOS Sender API Reference v 2.10.1 4691