GCKCastChannel Class
-
GCKCastChannel is a virtual communication channel for exchanging messages between a Cast sender and receiver.
-
Each channel has a unique namespace, allowing multiple channels on a single connection.
-
Channels must be registered with a GCKCastSession to be used and will connect automatically when the session is established.
-
Subclasses should implement didReceiveTextMessage to process incoming messages and may add methods for sending namespace-specific messages.
-
The channel provides methods to send text messages and track its connected and writable states.
A virtual communication channel for exchanging messages between a Cast sender and a Cast receiver.
Each channel is tagged with a unique namespace, so multiple channels may be multiplexed over a single network connection between a sender and a receiver.
A channel must be registered with a GCKCastSession before it can be used. When the associated session is established, the channel will be connected automatically and can then send and receive messages.
Subclasses should implement the didReceiveTextMessage: (GCKCastChannel) method to process incoming messages, and will typically provide additional methods for sending messages that are specific to a given namespace.
Inherits NSObject.
Inherited by GCKGenericChannel.
Instance Method Summary | |
| (instancetype) | - initWithNamespace: |
| Designated initializer. More... | |
| (instancetype) | - init |
| Default initializer is not available. More... | |
| (void) | - didReceiveTextMessage: |
| Called when a text message has been received 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... | |
| (nullable NSNumber *) | - 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... | |
| (void) | - didChangeWritableState: |
| Called when the writable state of this channel has changed. More... | |
Property Summary | |
| NSString * | protocolNamespace |
| The channel's namespace. More... | |
| BOOL | isConnected |
| A flag indicating whether this channel is currently connected. More... | |
| BOOL | isWritable |
| A flag indicating whether this channel is currently writable. More... | |
| - (instancetype) initWithNamespace: | (NSString *) | protocolNamespace |
Designated initializer.
Constructs a new GCKCastChannel with the given namespace.
- Parameters
-
protocolNamespace The namespace.
Implemented in GCKGenericChannel.
Default initializer is not available.
| - (void) didReceiveTextMessage: | (NSString *) | message |
Called when a text message has been received on this channel.
The default implementation is a no-op.
- Parameters
| - (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
YESon success orNOif 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.
| - (nullable NSNumber *) generateRequestNumber |
A convenience method which wraps the result of generateRequestID in an NSNumber.
- Returns
- The generated ID, or
nilif the channel is not currently connected.
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.
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.
| - (void) didChangeWritableState: | (BOOL) | isWritable |
Called when the writable state of this channel has changed.
The default implementation is a no-op.
- Parameters
-
isWritable Whether the channel is now writable.
- Since
- 4.0
|
- (NSString*) protocolNamespace |
readnonatomiccopy |
The channel's namespace.
A flag indicating whether this channel is currently connected.
A flag indicating whether this channel is currently writable.
- Since
- 4.0