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);
    }
  }
  if (remotePartyId != null) {
    /// Send select_answer event.
    await sendSelectCallAnswer(
        opts.room, callId, localPartyId, remotePartyId!);
  }
}