onCallNegotiate method

Future<void> onCallNegotiate(
  1. String roomId,
  2. String senderId,
  3. Map<String, dynamic> content
)

Implementation

Future<void> onCallNegotiate(
    String roomId, String senderId, Map<String, dynamic> content) async {
  if (senderId == client.userID) {
    // Ignore messages to yourself.
    return;
  }
  final String callId = content['call_id'];
  Logs().d('Negotiate received for call ID $callId');
  final call = calls[callId];
  if (call != null) {
    if (call.room.id != roomId) {
      Logs().w(
          'Ignoring call negotiation for room $roomId claiming to be for call in room ${call.room.id}');
      return;
    }

    final description = content['description'];
    try {
      SDPStreamMetadata? metadata;
      if (content[sdpStreamMetadataKey] != null) {
        metadata = SDPStreamMetadata.fromJson(content[sdpStreamMetadataKey]);
      }
      await call.onNegotiateReceived(metadata,
          RTCSessionDescription(description['sdp'], description['type']));
    } catch (e, s) {
      Logs().e('Failed to complete negotiation', e, s);
    }
  }
}