disconnect method
Disconnect from the server
Implementation
Future<void> disconnect() async {
if (_state == unconnected) return;
_logger.info('Disconnecting from $_endpoint');
try {
await _dispatcher.disconnect();
_state = unconnected;
_stateController.add(_state);
_logger.info('Disconnected successfully');
} catch (e) {
_logger.severe('Disconnect failed: $e');
rethrow;
}
}