GCKSessionManager Class Reference

A class that manages sessions. More...

#import <GCKSessionManager.h>

+ Inheritance diagram for GCKSessionManager:

Instance Methods

(instancetype) - NS_UNAVAILABLE
 Default initializer is not available. More...
 
(BOOL) - startSessionWithDevice:
 Starts a new session with the given device, using the default session options that were registered for the device category, if any. More...
 
(BOOL) - startSessionWithDevice:sessionOptions:
 Starts a new session with the given device and options. More...
 
(BOOL) - startSessionWithOpenURLOptions:sessionOptions:
 Attempts to join or start a session with options that were supplied to the UIApplicationDelegate::application:openURL:options: method. 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) - setDefaultSessionOptions:forDeviceCategory:
 Sets the default session options for the given device category.The session options are passed to the createSessionForDevice:sessionID:sessionOptions: (GCKDeviceProvider) method when the user selects a device from the Cast dialog. More...
 
(GCKSessionOptions *GCK_NULLABLE_TYPE) - defaultSessionOptionsForDeviceCategory:
 Gets the dfault session options for a given device category. More...
 
(void) - addListener:
 Adds a listener for receiving notifications. More...
 
(void) - removeListener:
 Removes a listener that was previously added with addListener:. More...
 

Properties

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

Detailed Description

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

Method Documentation

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

Adds a listener for receiving notifications.

Parameters
listenerThe listener to add.
- (GCKSessionOptions * GCK_NULLABLE_TYPE) defaultSessionOptionsForDeviceCategory: (NSString *)  category

Gets the dfault session options for a given device category.

Parameters
categoryThe device category.
Returns
The default session options, or nil if none.
Since
4.0
- (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) 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.

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

- (instancetype) NS_UNAVAILABLE

Default initializer is not available.

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

Removes a listener that was previously added with addListener:.

Parameters
listenerThe listener to remove.
- (void) setDefaultSessionOptions: (GCKSessionOptions *GCK_NULLABLE_TYPE)  sessionOptions
forDeviceCategory: (NSString *)  category 

Sets the default session options for the given device category.The session options are passed to the createSessionForDevice:sessionID:sessionOptions: (GCKDeviceProvider) method when the user selects a device from the Cast dialog.

For Cast sessions, the session options can specify which receiver application to launch.

Parameters
sessionOptionsThe session options. May be nil to remove any previously set options.
categoryThe device category.
Since
4.0
- (BOOL) startSessionWithDevice: (GCKDevice *)  device

Starts a new session with the given device, using the default session options that were registered for the device category, if any.

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) startSessionWithDevice: (GCKDevice *)  device
sessionOptions: (GCKSessionOptions *GCK_NULLABLE_TYPE)  options 

Starts a new session with the given device and options.

This is an asynchronous operation.

Parameters
deviceThe device to use for this session.
optionsThe options for this session, if any. May be nil.
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.
Since
4.0
- (BOOL) startSessionWithOpenURLOptions: (GCKOpenURLOptions *)  openURLOptions
sessionOptions: (GCKSessionOptions *GCK_NULLABLE_TYPE)  sessionOptions 

Attempts to join or start a session with options that were supplied to the UIApplicationDelegate::application:openURL:options: method.

Typically this is a request to join an existing Cast session on a particular device that was initiated by another app.

Parameters
openURLOptionsThe options that were extracted from the URL.
sessionOptionsThe options for this session, if any. May be nil.
Returns
YES if the operation has been started successfully, NO if there is a session currently established, or the openURL options do not contain the required Cast options.
Since
4.0
- (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.

Property Documentation

- (GCKConnectionState) connectionState
readnonatomicassign

The current session connection state.

- (GCKCastSession*) currentCastSession
readnonatomicstrong

The current Cast session, if any.

- (GCKSession*) currentSession
readnonatomicstrong

The current session, if any.


The documentation for this class was generated from the following file: