onAnswerReceived method

Future<void> onAnswerReceived(
  1. RTCSessionDescription answer,
  2. SDPStreamMetadata? metadata
)

Implementation

Future<void> onAnswerReceived(
    RTCSessionDescription answer, SDPStreamMetadata? metadata) async {
  if (metadata != null) {
    _updateRemoteSDPStreamMetadata(metadata);
  }

  if (direction == CallDirection.kOutgoing) {
    setCallState(CallState.kConnecting);
    await pc!.setRemoteDescription(answer);
    for (final candidate in remoteCandidates) {
      await pc!.addCandidate(candidate);
    }
  }

  /// Send select_answer event.
  await sendSelectCallAnswer(
      opts.room, callId, Timeouts.lifetimeMs, localPartyId, remotePartyId!);
}