createGameRoom method

Future<IGameRoom?> createGameRoom(
  1. string roomId,
  2. GameRoomConfig config
)

@detail api @author luomingkang @brief Create a game room instance.
This API only returns a room instance. You still need to call joinRoom{@link #RTCRoom#joinRoom} to actually create/join the room.
Each call of this API creates one RTCRoom{@link #RTCRoom} instance. Call this API as many times as the number of rooms you need, and then call joinRoom{@link #RTCRoom#joinRoom} of each RTCRoom instance to join multiple rooms at the same time.
In multi-room mode, a user can subscribe to media streams in the joined rooms at the same time. @param roomId The string matches the regular expression: [a-zA-Z0-9_\@\\-\\.]{1,128}. @param config The game room configuration. See GameRoomConfig{@link #GameRoomConfig}. @return RTCRoom{@link #RTCRoom} instance. If you get NULL instead of an RTCRoom instance, please ensure the roomId is valid. And the specified room is not yet created. @note - If the room that you wish to join already exists, you still need to call this API first to create the RTCRoom instance, and then call joinRoom{@link #RTCRoom#joinRoom}. - Do not create multiple rooms with the same roomId, otherwise the newly created room instance will replace the old one. - To forward streams to the other rooms, call startForwardStreamToRooms{@link #RTCRoom#startForwardStreamToRooms} instead of enabling Multi-room mode.

Implementation

Future<IGameRoom?> createGameRoom(
    string roomId, GameRoomConfig config) async {
  $a() async => packObject(
      await ($instance as $p_a.RTCEngine)
          .createGameRoom(roomId, unpackObject<$p_a.GameRoomConfig>(config)),
      () => IGameRoom());
  $i() async => packObject(
      await ($instance as $p_i.ByteRTCEngine)
          .createGameRoom(roomId, unpackObject<$p_i.GameRoomConfig>(config)),
      () => IGameRoom());

  if (Platform.isAndroid) {
    return $a();
  } else if (Platform.isIOS) {
    return $i();
  } else {
    throw UnsupportedError(
        'Not Support Platform ${Platform.operatingSystem}');
  }
}