accept method

Future<void> accept(
  1. String callerName,
  2. String callerNumber,
  3. String destinationNumber,
  4. String clientState,
  5. String callId,
  6. IncomingInviteParams invite,
  7. Map<String, String> customHeaders,
  8. bool isAttach,
)

Accepts an incoming call.

callerName The name of the caller. callerNumber The number of the caller. destinationNumber The destination number (usually the current user's number). clientState The client state information. callId The unique ID for this call. invite The incoming invite parameters containing the SDP offer. customHeaders Custom headers to include in the answer. isAttach Whether this is an attach call.

Implementation

Future<void> accept(
  String callerName,
  String callerNumber,
  String destinationNumber,
  String clientState,
  String callId,
  IncomingInviteParams invite,
  Map<String, String> customHeaders,
  bool isAttach,
) async {
  final sessionId = _selfId;
  final session = await _createSession(
    null,
    peerId: Uuid().v4(),
    sessionId: sessionId,
    callId: callId,
    media: 'audio',
  );

  _sessions[sessionId] = session;

  // Set the remote SDP from the inbound INVITE
  await session.peerConnection?.setRemoteDescription(
    RTCSessionDescription(invite.sdp, 'offer'),
  );

  // Create and send the Answer (or Attach)
  await _createAnswer(
    session,
    'audio',
    callerName,
    callerNumber,
    destinationNumber,
    clientState,
    callId,
    customHeaders,
    isAttach,
  );

  // Indicate the call is now active (in mobile code, we do this after answer).
  onCallStateChange?.call(session, CallState.active);
}