fetchOrCreateGroupCall method
Future<GroupCallSession>
fetchOrCreateGroupCall(
- String groupCallId,
- Room room,
- CallBackend backend,
- String? application,
- 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.
preShareKey
for livekit calls it creates and shares a key with other
participants in the call without entering, useful on onboarding screens.
does not do anything in mesh calls
Implementation
Future<GroupCallSession> fetchOrCreateGroupCall(
String groupCallId,
Room room,
CallBackend backend,
String? application,
String? scope, {
bool preShareKey = true,
}) async {
// somehow user were mising their powerlevels events and got stuck
// with the exception below, this part just makes sure importantStateEvents
// does not cause it.
await room.postLoad();
if (!room.groupCallsEnabledForEveryone) {
await room.enableGroupCalls();
}
if (!room.canJoinGroupCall) {
throw MatrixSDKVoipException(
'''
User ${client.userID}:${client.deviceID} is not allowed to join famedly calls in room ${room.id},
canJoinGroupCall: ${room.canJoinGroupCall},
groupCallsEnabledForEveryone: ${room.groupCallsEnabledForEveryone},
needed: ${room.powerForChangingStateEvent(EventTypes.GroupCallMember)},
own: ${room.ownPowerLevel}}
plMap: ${room.getState(EventTypes.RoomPowerLevels)?.content}
''',
);
}
GroupCallSession? groupCall = getGroupCallById(room.id, groupCallId);
groupCall ??= await _newGroupCall(
groupCallId,
room,
backend,
application,
scope,
);
if (preShareKey) {
await groupCall.backend.preShareKey(groupCall);
}
return groupCall;
}