disconnect method

  1. @override
Future<void> disconnect()
override

Disconnects from the socket server.

Throws SocketDisconnectionException if disconnection fails.

Implementation

@override
Future<void> disconnect() async {
  try {
    await methodChannel.invokeMethod('disconnect');
  } on PlatformException catch (e) {
    _handlePlatformException(e, 'disconnect');
  } catch (e) {
    if (e is SocketException) {
      rethrow;
    }
    throw SocketDisconnectionException('Unexpected error during disconnection: $e');
  }
}