closeConnection method

void closeConnection()

Disconnects the _ws connection, without removing the user set on client.

This will not trigger default auto-retry mechanism for reconnection. You need to call openConnection to reconnect to _ws.

Implementation

void closeConnection() {
  if (wsConnectionStatus == ConnectionStatus.disconnected) return;

  logger.info('Closing web-socket connection for ${state.currentUser?.id}');
  _wsConnectionStatus = ConnectionStatus.disconnected;

  _connectionStatusSubscription?.cancel();
  _connectionStatusSubscription = null;

  _ws.disconnect();
}