inviteToCall method

Future<CallSession> inviteToCall(
  1. Room room,
  2. CallType type, {
  3. String? userId,
  4. String? deviceId,
})

Make a P2P call to room

Pretty important to set the userId, or all the users in the room get a call. Including your own other devices, so just set it to directChatMatrixId

Setting the deviceId would make all other devices for that userId ignore the call Ideally only group calls would need setting both userId and deviceId to allow having 2 devices from the same user in a group call

For p2p call, you want to have all the devices of the specified userId ring

Implementation

Future<CallSession> inviteToCall(
  Room room,
  CallType type, {
  String? userId,
  String? deviceId,
}) async {
  final roomId = room.id;
  final callId = genCallID();
  if (currentGroupCID == null) {
    incomingCallRoomId[roomId] = callId;
  }
  final opts = CallOptions(
    callId: callId,
    type: type,
    dir: CallDirection.kOutgoing,
    room: room,
    voip: this,
    localPartyId: localPartyId,
    iceServers: await getIceServers(),
  );
  final newCall = createNewCall(opts);

  newCall.remoteUserId = userId;
  newCall.remoteDeviceId = deviceId;

  currentCID = VoipId(roomId: roomId, callId: callId);
  await newCall.initOutboundCall(type).then((_) {
    delegate.handleNewCall(newCall);
  });
  return newCall;
}