GCKSessionManager Class

GCKSessionManager Class Reference

Overview

A class that manages sessions.

The method startSessionWithDevice: (GCKSessionManager) is used to create a new session with a given GCKDevice. The session manager uses the GCKDeviceProvider for that device type to construct a new GCKSession object, to which it then delegates all session requests.

GCKSessionManager handles the automatic resumption of suspended sessions (that is, resuming sessions that were ended when the application went to the background, or in the event that the application crashed or was forcibly terminated by the user). When the application resumes or restarts, the session manager will wait for a short time for the device provider of the suspended session's device to discover that device again, and if it does, it will attempt to reconnect to that device and re-establish the session automatically.

If the application has created a GCKUICastButton without providing a target and selector, then a user tap on the button will display the default Cast dialog and it will automatically start and stop sessions based on user selection or disconnection of a device. If however the application is providing its own device selection/control dialog UI, then it should use the GCKSessionManager directly to create and control sessions.

Whether or not the application uses the GCKSessionManager to control sessions, it can attach a GCKSessionManagerListener to be notified of session events, and can also use KVO to monitor the connectionState property to track the current session lifecycle state.

Since
3.0

Inherits NSObject.

Instance Method Summary

(instancetype) - init
 Default initializer is not available. More...
 
(BOOL) - startSessionWithDevice:
 Starts a new session with the given device. More...
 
(BOOL) - suspendSessionWithReason:
 Suspends the current session. More...
 
(BOOL) - endSession
 Ends the current session. More...
 
(BOOL) - endSessionAndStopCasting:
 Ends the current session, optionally stopping casting. More...
 
(BOOL) - hasConnectedSession
 Tests if a session is currently being managed by this session manager, and it is currently connected. More...
 
(BOOL) - hasConnectedCastSession
 Tests if a Cast session is currently being managed by this session manager, and it is currently connected. More...
 
(void) - addListener:
 Adds a listener for receiving notifications. More...
 
(void) - removeListener:
 Removes a listener that was previously added with addListener:. More...
 

Property Summary

GCKSessioncurrentSession
 The current session, if any. More...
 
GCKCastSessioncurrentCastSession
 The current cast session, if any. More...
 
GCKConnectionState connectionState
 The current session connection state. More...
 

Method Detail

- (instancetype) init

Default initializer is not available.

- (BOOL) startSessionWithDevice: (GCKDevice *)  device

Starts a new session with the given device.

This is an asynchronous operation.

Parameters
deviceThe device to use for this session.
Returns
YES if the operation has been started successfully, NO if there is a session currently established or if the operation could not be started.
- (BOOL) suspendSessionWithReason: (GCKConnectionSuspendReason reason

Suspends the current session.

This is an asynchronous operation.

Parameters
reasonThe reason for the suspension.
Returns
YES if the operation has been started successfully, NO if there is no session currently established or if the operation could not be started.
- (BOOL) endSession

Ends the current session.

This is an asynchronous operation.

Returns
YES if the operation has been started successfully, NO if there is no session currently established or if the operation could not be started.
- (BOOL) endSessionAndStopCasting: (BOOL)  stopCasting

Ends the current session, optionally stopping casting.

This is an asynchronous operation.

Parameters
stopCastingWhether casting of content on the receiver should be stopped when the session is ended.
Returns
YES if the operation has been started successfully, NO if there is no session currently established or if the operation could not be started.
- (BOOL) hasConnectedSession

Tests if a session is currently being managed by this session manager, and it is currently connected.

This will be YES if the session state is GCKConnectionStateConnected.

- (BOOL) hasConnectedCastSession

Tests if a Cast session is currently being managed by this session manager, and it is currently connected.

This will be YES if the session state is GCKConnectionStateConnected and the session is a Cast session.

- (void) addListener: (id< GCKSessionManagerListener >)  listener

Adds a listener for receiving notifications.

Parameters
listenerThe listener to add.
- (void) removeListener: (id< GCKSessionManagerListener >)  listener

Removes a listener that was previously added with addListener:.

Parameters
listenerThe listener to remove.

Property Detail

- (GCKSession*) currentSession
readnonatomicstrong

The current session, if any.

- (GCKCastSession*) currentCastSession
readnonatomicstrong

The current cast session, if any.

- (GCKConnectionState) connectionState
readnonatomicassign

The current session connection state.