disconnect method

  1. @override
Future<bool> disconnect({
  1. int? delayMs,
})
override

delayMs: milliseconds to wait after destroying the socket

Implementation

@override
Future<bool> disconnect({int? delayMs}) async {
  try {
    // await _socket?.flush();
    _socket?.destroy();

    if (delayMs != null) {
      await Future.delayed(Duration(milliseconds: delayMs), () => null);
    }
    return true;
  } catch (e) {
    _socket?.destroy();
    status = TCPStatus.none;
    _statusStreamController.add(status);
    return false;
  }
}