fetchOrCreateGroupCall method

Future<GroupCallSession> fetchOrCreateGroupCall(
  1. String groupCallId,
  2. Room room,
  3. CallBackend backend,
  4. String? application,
  5. String? scope,
)

Create a new group call in an existing room.

groupCallId The room id to call

application normal group call, thrirdroom, etc

scope room, between specifc users, etc.

Implementation

Future<GroupCallSession> fetchOrCreateGroupCall(
  String groupCallId,
  Room room,
  CallBackend backend,
  String? application,
  String? scope,
) async {
  final groupCall = getGroupCallById(room.id, groupCallId);

  if (groupCall != null) {
    if (!room.canJoinGroupCall) {
      throw Exception(
          'User is not allowed to join famedly calls in the room');
    }
    return groupCall;
  }

  if (!room.groupCallsEnabledForEveryone) {
    await room.enableGroupCalls();
  }

  // The call doesn't exist, but we can create it
  return await _newGroupCall(
    groupCallId,
    room,
    backend,
    application,
    scope,
  );
}