GCKSessionManager.h
1 // Copyright 2015 Google Inc.
2 
3 #import <GoogleCast/GCKCommon.h>
4 #import <GoogleCast/GCKDefines.h>
5 #import <GoogleCast/GCKSessionOptions.h>
6 
7 #import <Foundation/Foundation.h>
8 
9 @class GCKCastSession;
10 @class GCKDevice;
11 @class GCKOpenURLOptions;
12 @class GCKSession;
13 @protocol GCKSessionManagerListener;
14 
15 GCK_ASSUME_NONNULL_BEGIN
16 
17 GCK_EXTERN NSString *const kGCKKeyConnectionState;
18 
44 GCK_EXPORT
45 @interface GCKSessionManager : NSObject
46 
48 @property(nonatomic, strong, readonly, GCK_NULLABLE) GCKSession *currentSession;
49 
51 @property(nonatomic, strong, readonly, GCK_NULLABLE) GCKCastSession *currentCastSession;
52 
54 @property(nonatomic, assign, readonly) GCKConnectionState connectionState;
55 
59 - (instancetype)init NS_UNAVAILABLE;
60 
69 - (BOOL)startSessionWithDevice:(GCKDevice *)device;
70 
81 - (BOOL)startSessionWithDevice:(GCKDevice *)device
82  sessionOptions:(GCKSessionOptions * GCK_NULLABLE_TYPE)options;
83 
97 - (BOOL)startSessionWithOpenURLOptions:(GCKOpenURLOptions *)openURLOptions
98  sessionOptions:(GCKSessionOptions * GCK_NULLABLE_TYPE)sessionOptions;
99 
107 - (BOOL)suspendSessionWithReason:(GCKConnectionSuspendReason)reason;
108 
115 - (BOOL)endSession;
116 
125 - (BOOL)endSessionAndStopCasting:(BOOL)stopCasting;
126 
132 - (BOOL)hasConnectedSession;
133 
140 
153 - (void)setDefaultSessionOptions:(GCKSessionOptions * GCK_NULLABLE_TYPE)sessionOptions
154  forDeviceCategory:(NSString *)category;
155 
163 - (GCKSessionOptions * GCK_NULLABLE_TYPE)
164  defaultSessionOptionsForDeviceCategory:(NSString *)category;
165 
171 - (void)addListener:(id<GCKSessionManagerListener>)listener;
172 
178 - (void)removeListener:(id<GCKSessionManagerListener>)listener;
179 
180 @end
181 
198 GCK_EXPORT
199 @protocol GCKSessionManagerListener <NSObject>
200 
201 @optional
202 
209 - (void)sessionManager:(GCKSessionManager *)sessionManager willStartSession:(GCKSession *)session;
210 
217 - (void)sessionManager:(GCKSessionManager *)sessionManager didStartSession:(GCKSession *)session;
218 
225 - (void)sessionManager:(GCKSessionManager *)sessionManager
226  willStartCastSession:(GCKCastSession *)session;
227 
234 - (void)sessionManager:(GCKSessionManager *)sessionManager
235  didStartCastSession:(GCKCastSession *)session;
236 
243 - (void)sessionManager:(GCKSessionManager *)sessionManager willEndSession:(GCKSession *)session;
244 
252 - (void)sessionManager:(GCKSessionManager *)sessionManager
253  didEndSession:(GCKSession *)session
254  withError:(NSError *GCK_NULLABLE_TYPE)error;
255 
262 - (void)sessionManager:(GCKSessionManager *)sessionManager
263  willEndCastSession:(GCKCastSession *)session;
264 
272 - (void)sessionManager:(GCKSessionManager *)sessionManager
273  didEndCastSession:(GCKCastSession *)session
274  withError:(NSError *GCK_NULLABLE_TYPE)error;
275 
283 - (void)sessionManager:(GCKSessionManager *)sessionManager
284  didFailToStartSession:(GCKSession *)session
285  withError:(NSError *)error;
286 
294 - (void)sessionManager:(GCKSessionManager *)sessionManager
295  didFailToStartCastSession:(GCKCastSession *)session
296  withError:(NSError *)error;
297 
305 - (void)sessionManager:(GCKSessionManager *)sessionManager
306  didSuspendSession:(GCKSession *)session
307  withReason:(GCKConnectionSuspendReason)reason;
308 
316 - (void)sessionManager:(GCKSessionManager *)sessionManager
317  didSuspendCastSession:(GCKCastSession *)session
318  withReason:(GCKConnectionSuspendReason)reason;
319 
326 - (void)sessionManager:(GCKSessionManager *)sessionManager willResumeSession:(GCKSession *)session;
327 
334 - (void)sessionManager:(GCKSessionManager *)sessionManager didResumeSession:(GCKSession *)session;
335 
342 - (void)sessionManager:(GCKSessionManager *)sessionManager
343  willResumeCastSession:(GCKCastSession *)session;
344 
351 - (void)sessionManager:(GCKSessionManager *)sessionManager
352  didResumeCastSession:(GCKCastSession *)session;
353 
364 - (void)sessionManager:(GCKSessionManager *)sessionManager
365  session:(GCKSession *)session
366  didUpdateDevice:(GCKDevice *)device;
367 
376 - (void)sessionManager:(GCKSessionManager *)sessionManager
377  session:(GCKSession *)session
378  didReceiveDeviceVolume:(float)volume
379  muted:(BOOL)muted;
388 - (void)sessionManager:(GCKSessionManager *)sessionManager
389  castSession:(GCKCastSession *)session
390  didReceiveDeviceVolume:(float)volume
391  muted:(BOOL)muted;
392 
400 - (void)sessionManager:(GCKSessionManager *)sessionManager
401  session:(GCKSession *)session
402  didReceiveDeviceStatus:(NSString *GCK_NULLABLE_TYPE)statusText;
403 
411 - (void)sessionManager:(GCKSessionManager *)sessionManager
412  castSession:(GCKCastSession *)session
413  didReceiveDeviceStatus:(NSString *GCK_NULLABLE_TYPE)statusText;
414 
423 - (void)sessionManager:(GCKSessionManager *)sessionManager
424  didUpdateDefaultSessionOptionsForDeviceCategory:(NSString *)category;
425 
426 @end
427 
428 GCK_ASSUME_NONNULL_END
GCKConnectionState connectionState
The current session connection state.
Definition: GCKSessionManager.h:54
GCKSession * currentSession
The current session, if any.
Definition: GCKSessionManager.h:48
An object representing a receiver device.
Definition: GCKDevice.h:82
An abstract base class representing a session with a receiver device.
Definition: GCKSession.h:30
BOOL hasConnectedSession()
Tests if a session is currently being managed by this session manager, and it is currently connected...
BOOL endSession()
Ends the current session.
A class that manages a Cast session with a receiver device.
Definition: GCKCastSession.h:28
An object representing options that can be passed to a Cast-enabled application via a deep-link URL...
Definition: GCKOpenURLOptions.h:24
instancetype NS_UNAVAILABLE()
Default initializer is not available.
GCKCastSession * currentCastSession
The current Cast session, if any.
Definition: GCKSessionManager.h:51
BOOL hasConnectedCastSession()
Tests if a Cast session is currently being managed by this session manager, and it is currently conne...
A class that manages sessions.
Definition: GCKSessionManager.h:45