createRoom method

Future<int> createRoom(
  1. int hubId
)

Creates a chat room between the connected user and a hub.

Returns a Future resolving into the ID of the newly created room.

Implementation

Future<int> createRoom(int hubId) {
  _ensureReady();

  final Completer<int> completer = Completer();

  _channel.push('create_room', {'hub': hubId})
    ..onReply('ok', (PushResponse pushResponse) {
      final int roomId = pushResponse.response['id'];
      completer.complete(roomId);
    })
    ..onReply('error', (error) {
      completer.completeError(ErrorEvent());
    })
    ..onReply('timeout', (error) {
      completer.completeError(ErrorEvent());
    });

  return completer.future;
}