createGameRoom method
@detail api
@author shenpengliang
@brief Create a game room instance.
This API only returns a room instance. You still need to call joinRoom:userInfo:{@link #ByteRTCGameRoom#joinRoom:userInfo} to actually create/join the room.
Each call of this API creates one ByteRTCGameRoom{@link #ByteRTCGameRoom} instance. Call this API as many times as the number of rooms you need, and then call joinRoom:userInfo:{@link #ByteRTCGameRoom#joinRoom:userInfo} of each GameRTCRoom 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 roomConfig The room configuration, see GameRoomConfig{@link #GameRoomConfig}.
@return ByteRTCGameRoom{@link #ByteRTCGameRoom} instance.
If you get NULL instead of an GameRTCRoom 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 GameRTCRoom instance, and then call joinRoom:userInfo:{@link #ByteRTCGameRoom#joinRoom:userInfo}.
- Do not create multiple rooms with the same roomId, otherwise the newly created room instance will replace the old one.
Implementation
FutureOr<ByteRTCGameRoom> createGameRoom(
NSString roomId, GameRoomConfig roomConfig) async {
final result =
await nativeCall('createGameRoom:roomConfig:', [roomId, roomConfig]);
return packObject(result,
() => ByteRTCGameRoom(const NativeClassOptions([], disableInit: true)));
}