close method

Future<void> close([
  1. int? closeCode,
  2. String? reason
])

Fecha a sessão permanentemente

Implementation

Future<void> close([int? closeCode, String? reason]) async {
  if (_state == WsSessionState.closed) return;

  _state = WsSessionState.closed;

  // Fecha conexão se existir
  if (_connection != null) {
    await _connection!.close(closeCode, reason);
    _connection = null;
  }

  // Limpa salas
  _rooms.clear();
}