close method

void close([
  1. int code = 1000,
  2. String? reason
])

Implementation

void close([int code = 1000, String? reason]) {
  _manuallyClosed = true;
  _reconnecting = false;
  _heartbeatTimer?.cancel();
  _heartbeatTimer = null;

  try {
    if (reason == null) {
      _socket?.close(code);
    } else {
      _socket?.close(code, reason);
    }
  } catch (_) {}
  _socket = null;
  _setState(WebSocketConnectionState.disconnected);
  _emitLocal('close', reason);
}