close method

void close([
  1. int? code,
  2. String? reason,
  3. dynamic reconnect = false
])

Close the underlying connection supporting the socket.

Implementation

void close([
  int? code,
  String? reason,
  reconnect = false,
]) {
  _shouldReconnect = reconnect;
  if (isConnected) {
    // _ws != null and state is connected
    _socketState = SocketState.closing;
    _closeSink(code, reason);
  } else if (!_shouldReconnect) {
    dispose();
  }
}