openRoom method

Room openRoom([
  1. int roomId = 0
])

Initialises and returns a Room instance for the chat room with the given ID.

Alternatively, the method can be called without a parameter, in which case one of the rooms belonging to the connected user will be opened — useful when you have a single hub.

Implementation

Room openRoom([int roomId = 0]) {
  _ensureReady();

  if (roomId == 0) {
    if (_roomIdsAtJoin.isNotEmpty) {
      roomId = _roomIdsAtJoin[0];
    } else {
      throw StateError('The user does not have any rooms yet.');
    }
  }

  return Room(_connector, roomId);
}