disconnect method
- bool stopReceiver = false,
Closes the sender connection, optionally stopping the receiver app.
Implementation
Future<void> disconnect({bool stopReceiver = false}) async {
try {
if (stopReceiver && _socket != null && _session != null) {
await _request(_receiver, {
'type': 'STOP',
'sessionId': _session,
}, destination: 'receiver-0');
}
} finally {
_fail(
const SocketException('Cast session disconnected'),
StackTrace.current,
);
await _subscription?.cancel();
_subscription = null;
}
}