sendInviteToCall method

Future<String?> sendInviteToCall(
  1. Room room,
  2. String callId,
  3. int lifetime,
  4. String party_id,
  5. String? invitee,
  6. String sdp, {
  7. String type = 'offer',
  8. String version = voipProtoVersion,
  9. String? txid,
  10. CallCapabilities? capabilities,
  11. SDPStreamMetadata? metadata,
})

This is sent by the caller when they wish to establish a call. callId is a unique identifier for the call. version is the version of the VoIP specification this message adheres to. This specification is version 1. lifetime is the time in milliseconds that the invite is valid for. Once the invite age exceeds this value, clients should discard it. They should also no longer show the call as awaiting an answer in the UI. type The type of session description. Must be 'offer'. sdp The SDP text of the session description. invitee The user ID of the person who is being invited. Invites without an invitee field are defined to be intended for any member of the room other than the sender of the event. party_id The party ID for call, Can be set to client.deviceId.

Implementation

Future<String?> sendInviteToCall(Room room, String callId, int lifetime,
    String party_id, String? invitee, String sdp,
    {String type = 'offer',
    String version = voipProtoVersion,
    String? txid,
    CallCapabilities? capabilities,
    SDPStreamMetadata? metadata}) async {
  txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';

  final content = {
    'call_id': callId,
    'party_id': party_id,
    if (groupCallId != null) 'conf_id': groupCallId,
    'version': version,
    'lifetime': lifetime,
    'offer': {'sdp': sdp, 'type': type},
    if (invitee != null) 'invitee': invitee,
    if (capabilities != null) 'capabilities': capabilities.toJson(),
    if (metadata != null) sdpStreamMetadataKey: metadata.toJson(),
  };
  return await _sendContent(
    room,
    EventTypes.CallInvite,
    content,
    txid: txid,
  );
}