GCKDiscoveryManager Class Reference

A class that manages the device discovery process. More...

#import <GCKDiscoveryManager.h>

+ Inheritance diagram for GCKDiscoveryManager:

Instance Methods

(instancetype) - NS_UNAVAILABLE
 Default initializer is not available. More...
 
(void) - addListener:
 Adds a listener that will receive discovery notifications. More...
 
(void) - removeListener:
 Removes a previously registered listener. More...
 
(void) - startDiscovery
 Starts the discovery process. More...
 
(void) - stopDiscovery
 Stops the discovery process. More...
 
(BOOL) - isDiscoveryActiveForDeviceCategory:
 Tests whether discovery is currently active for the given device category. More...
 
(GCKDevice *) - deviceAtIndex:
 Returns the device at the given index in the manager's list of discovered devices. More...
 
(GCKDevice *GCK_NULLABLE_TYPE) - deviceWithUniqueID:
 Returns the device with the given unique ID in the manager's list of discovered devices. More...
 
(void) - findDeviceWithUniqueID:timeout:completion:
 Waits for a device with the given unique ID to be discovered, and invokes a completion block. More...
 
(void) - cancelFindOperation
 Cancels any in-progress find operation started by findDeviceWithUniqueID:timeout:completion:. More...
 

Properties

GCKDiscoveryState discoveryState
 The current discovery state. More...
 
BOOL hasDiscoveredDevices
 A flag indicating whether any devices have been discovered by any of the discovery providers managed by this object. More...
 
BOOL passiveScan
 A flag indicating whether discovery should employ a "passive" scan. More...
 
BOOL discoveryActive
 A flag indicating whether discovery is active or not. More...
 
NSUInteger deviceCount
 The number of devices that are currently discovered. More...
 

Detailed Description

A class that manages the device discovery process.

GCKDiscoveryManager manages a collection of GCKDeviceProvider subclass instances, each of which is responsible for discovering devices of a specific type. It also maintains a lexicographically ordered list of the currently discovered devices.

The framework automatically starts the discovery process when the application moves to the foreground and suspends it when the application moves to the background. It is generally not necessary for the application to call startDiscovery (GCKDiscoveryManager) and stopDiscovery (GCKDiscoveryManager), except as an optimization measure to reduce network traffic and CPU utilization in areas of the application that do not use Cast functionality.

If the application is using the framework's Cast dialog, either by way of GCKUICastButton or by presenting it directly, then that dialog will use GCKDiscoveryManager to populate its list of available devices. If however the application is providing its own device selection/control dialog UI, then it should use the GCKDiscoveryManager and its associated listener protocol, GCKDiscoveryManagerListener, to populate and update its list of available devices.

Since
3.0

Method Documentation

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

Adds a listener that will receive discovery notifications.

Parameters
listenerThe listener to add.
- (void) cancelFindOperation

Cancels any in-progress find operation started by findDeviceWithUniqueID:timeout:completion:.

Since
4.0
- (GCKDevice *) deviceAtIndex: (NSUInteger)  index

Returns the device at the given index in the manager's list of discovered devices.

- (GCKDevice *GCK_NULLABLE_TYPE) deviceWithUniqueID: (NSString *)  uniqueID

Returns the device with the given unique ID in the manager's list of discovered devices.

Parameters
uniqueIDThe device's unique ID.
Returns
The matching GCKDevice object, or nil if a matching device was not found.
- (void) findDeviceWithUniqueID: (NSString *)  uniqueID
timeout: (NSTimeInterval)  timeout
completion: (void(^)(GCKDevice *))  completion 

Waits for a device with the given unique ID to be discovered, and invokes a completion block.

If a matching device is already in the discovered device list, the completion block will be invoked immediately (but after this method returns). Only one find operation can be active at a time; starting a new find operation while another one is in progress will cancel the current one.

Parameters
uniqueIDThe unique ID of the device.
timeoutThe maximum amount of time to wait for the device to be discovered.
completionThe completion block to invoke when either the device is found or the timeout is reached. The device (if found) or nil (if not found) will be passed to the completion block.
Since
4.0
- (BOOL) isDiscoveryActiveForDeviceCategory: (NSString *)  deviceCategory

Tests whether discovery is currently active for the given device category.

- (instancetype) NS_UNAVAILABLE

Default initializer is not available.

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

Removes a previously registered listener.

Parameters
listenerThe listener to remove.
- (void) startDiscovery

Starts the discovery process.

- (void) stopDiscovery

Stops the discovery process.

Property Documentation

- (NSUInteger) deviceCount
readnonatomicassign

The number of devices that are currently discovered.

- (BOOL) discoveryActive
readnonatomicassign

A flag indicating whether discovery is active or not.

Since
3.4
- (GCKDiscoveryState) discoveryState
readnonatomicassign

The current discovery state.

- (BOOL) hasDiscoveredDevices
readnonatomicassign

A flag indicating whether any devices have been discovered by any of the discovery providers managed by this object.

- (BOOL) passiveScan
readwritenonatomicassign

A flag indicating whether discovery should employ a "passive" scan.

Passive scans are less resource-intensive but do not provide results that are as fresh as active scans.


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