close method

void close()

Close the WebSocket connection permanently.

Implementation

void close() {
  _state = WebSocketState.closed;
  _stopPingInterval();
  _reconnectTimer?.cancel();
  _reconnectTimer = null;
  _wsSubscription?.cancel();
  _wsSubscription = null;
  _ws?.close();
  _ws = null;
}