joinRoom method

Future<void> joinRoom(
  1. int roomId,
  2. String username, {
  3. String? pin,
  4. String? display,
  5. String? token,
  6. bool? history,
})

joinRoom

you use a join request to join a Text Room, make sure to call setup before calling joinRoom

roomId : numeric ID of the room to join.
username : unique username to have in the room; mandatory.
pin : pin to join the room; mandatory if configured.
display : display name to have in the room; optional.
token : invitation token, in case the room has an ACL; optional.
history : true|false, whether to retrieve history messages when available (default=true).

Implementation

Future<void> joinRoom(int roomId, String username,
    {String? pin, String? display, String? token, bool? history}) async {
  if (setupDone) {
    _context._logger.info('data channel is open, now trying to join');
    var register = {
      'textroom': "join",
      'transaction': randomString(),
      'room': roomId,
      'username': username,
      'display': display,
      "pin": pin,
      "token": token,
      "history": history
    }..removeWhere((key, value) => value == null);
    _handleRoomIdTypeDifference(register);
    await this.sendData(stringify(register));
  } else {
    _context._logger.shout(
        'method was called before calling setup(), hence aborting further operation.');
    throw "method was called before calling setup(), hence aborting further operation.";
  }
}