createGroupCallFromRoomStateEvent method
Create a new group call from a room state event.
Implementation
Future<GroupCall?> createGroupCallFromRoomStateEvent(SDNEvent event,
{bool emitHandleNewGroupCall = true}) async {
final roomId = event.roomId;
final content = event.content;
final room = client.getRoomById(roomId!);
if (room == null) {
Logs().w('Couldn\'t find room $roomId for GroupCall');
return null;
}
final groupCallId = event.stateKey;
final callType = content.tryGet<String>('m.type');
if (callType == null ||
callType != GroupCallType.Video && callType != GroupCallType.Voice) {
Logs().w('Received invalid group call type $callType for room $roomId.');
return null;
}
final callIntent = content.tryGet<String>('m.intent');
if (callIntent == null ||
callIntent != GroupCallIntent.Prompt &&
callIntent != GroupCallIntent.Room &&
callIntent != GroupCallIntent.Ring) {
Logs()
.w('Received invalid group call intent $callType for room $roomId.');
return null;
}
final groupCall = GroupCall(
client: client,
voip: this,
room: room,
groupCallId: groupCallId,
type: callType,
intent: callIntent,
);
groupCalls[groupCallId!] = groupCall;
groupCalls[room.id] = groupCall;
onIncomingGroupCall.add(groupCall);
if (emitHandleNewGroupCall) {
await delegate.handleNewGroupCall(groupCall);
}
return groupCall;
}