disconnect method

Future<void> disconnect({
  1. bool disableRetry = false,
})

Implementation

Future<void> disconnect({bool disableRetry = false}) async {
  try {
    if (_socket != null) {
      if (disableRetry) {
        log("$logSuffix Disabled Retry");
        retry = false;
      }
      await _socket?.close();
      log("Socket Service Closed");
      _socket?.destroy();
      log("Socket Service Destroyed");
      _socket = null;
      onConnectionClose!();
    }
  } catch (e) {
    onConnectionClose!();
    log("Disconnect Exception $e");
  }
}