Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disconnect not working #14

Open
gabrielrf97 opened this issue Oct 24, 2020 · 2 comments
Open

Disconnect not working #14

gabrielrf97 opened this issue Oct 24, 2020 · 2 comments

Comments

@gabrielrf97
Copy link

gabrielrf97 commented Oct 24, 2020

Disconnect feature is not working in current example. (master, HEAD a0cf9d4).

After the sample app successfully connects to the cast device, by clicking in the top left tab bar icon and calling disconnect, with the current declaration:

void disconnect() async { if (null != _castSender) { await _castSender.disconnect(); final prefs = await SharedPreferences.getInstance(); prefs.remove('cast_session_host'); prefs.remove('cast_session_port'); prefs.remove('cast_session_device_name'); prefs.remove('cast_session_device_type'); prefs.remove('cast_session_sender_id'); prefs.remove('cast_session_destination_id'); setState(() { _castSender = null; _servicesFound = false; _castConnected = false; _discover(); }); } }

the app does not disconnect from the cast device.

@Cdriic
Copy link

Cdriic commented Jan 29, 2021

Disconnect feature is not working in current example. (master, HEAD a0cf9d4).

After the sample app successfully connects to the cast device, by clicking in the top left tab bar icon and calling disconnect, with the current declaration:

void disconnect() async { if (null != _castSender) { await _castSender.disconnect(); final prefs = await SharedPreferences.getInstance(); prefs.remove('cast_session_host'); prefs.remove('cast_session_port'); prefs.remove('cast_session_device_name'); prefs.remove('cast_session_device_type'); prefs.remove('cast_session_sender_id'); prefs.remove('cast_session_destination_id'); setState(() { _castSender = null; _servicesFound = false; _castConnected = false; _discover(); }); } }

the app does not disconnect from the cast device.

Solution: (cast_sender.dart)
Future<bool> disconnect() async { if (null != _connectionChannel && null != _castSession?.castMediaStatus) { _connectionChannel.sendMessage({ 'type': 'CLOSE', 'sessionId': _castSession.castMediaStatus.sessionId, }); } if (null != _socket) { await _socket.destroy(); } _dispose(); connectionDidClose = true; return true; }

TO

Future<bool> disconnect() async { if (null != _connectionChannel) { _connectionChannel.sendMessage({ 'type': 'CLOSE', }); } if (null != _socket) { await _socket.destroy(); } _dispose(); connectionDidClose = true; return true; }

@gabrielrf97
Copy link
Author

That actually works. I'm facing some network issues here, which lead me to undeterministic tests. I expect them to be solved later on and I'll comment again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants