Search code examples
ioschromecastgoogle-cast

GCKDeviceManager Protocol - What is the difference between didDisconnectWithError: and didDisconnectFromApplicationWithError:?


In the <GCKDeviceManagerDelegate> Protocol I see two very similar methods:

/**
 * Called when the connection to the device has been terminated. It is safe to release the
 * GCKDeviceManager object from within this callback.
 *
 * @param deviceManager The device manager.
 * @param error The error that caused the disconnection; nil if there was no error (e.g. intentional
 * disconnection).
 */
- (void)deviceManager:(GCKDeviceManager *)deviceManager
    didDisconnectWithError:(NSError *)error;

and

/**
 * Called when disconnected from the current application.
 *
 * @param deviceManager The device manager.
 * @param error The error that caused the disconnect, or <code>nil</code> if this was a normal
 * disconnect.
 */
- (void)deviceManager:(GCKDeviceManager *)deviceManager
    didDisconnectFromApplicationWithError:(NSError *)error;

Is deviceManager:didDisconnectWithError: called if the Chromecast receiver is disconnected or loses connection to the application, and deviceManager:didDisconnectFromApplicationWithError: called when the application tries to disconnect from the Chromecast receiver?

What are the use-cases when each delegate method would be called?


Solution

  • A sender application can connect to a cast device and upon successful connection can launch a receiver application on the cast device. So "connecting to a device" and "running an application" are two separate actions, so are "stopping the receiver application" and "disconnecting" from the cast device. As such, there are those two separate methods.