connectOtherRoom method

Future<void> connectOtherRoom(
  1. String param
)

Request cross-room calls so that two different rooms can share audio and video streams (e.g., "anchor PK" scenarios).

In TRTC, two anchors in different rooms can use the "cross-room call" feature to co-anchor across the rooms. They can engage in "co-anchoring competition" without the need to exit their own rooms.

For example, when anchor A in room "001" uses connectOtherRoom to successfully call anchor B in room "002", all users in room "001" will receive the onRemoteUserEnterRoom(B) and onUserVideoAvailable(B,true) callbacks of anchor B, and all users in room "002" will receive the onRemoteUserEnterRoom(A) and onUserVideoAvailable(A,true) callbacks of anchor A.

In short, cross-room call is to share between two anchors in different rooms, so that users in either room can see both of them.

For the sake of compatibility of subsequent extended fields for cross-room call, parameters in JSON format are used currently and must contain at least two fields:

  • roomId: if anchor A in room "001" wants to co-anchor with anchor B in room "002", the roomId must be set to 002 when anchor A calls connectOtherRoom .

  • userId: if anchor A in room "001" wants to co-anchor with anchor B in room "002", the userId must be set to the userId of anchor B when anchor A calls connectOtherRoom .

The result of requesting cross-room call will be returned through the TRTCCloudListener.onConnectOtherRoom callback.

Sample call:

var object = new Map();

object['roomId'] = 155;

object['userId'] = '57890';

trtcCloud.connectOtherRoom(jsonEncode(object));

Parameters:

param Co-anchoring parameters in the format of JSON string. roomId indicates the target room number, and userId indicates the target user ID.

Not supported on:

  • web

Implementation

Future<void> connectOtherRoom(String param) {
  return _cloudChannel!.invokeMethod('connectOtherRoom', {
    "param": param,
  });
}