invite method
Initiates a new call.
callerName
The name of the caller.
callerNumber
The number of the caller.
destinationNumber
The number to call.
clientState
The client state information.
callId
The unique ID for this call.
telnyxSessionId
The Telnyx session ID.
customHeaders
Custom headers to include in the invite.
Implementation
Future<void> invite(
String callerName,
String callerNumber,
String destinationNumber,
String clientState,
String callId,
String telnyxSessionId,
Map<String, String> customHeaders,
) async {
final sessionId = _selfId;
final session = await _createSession(
null,
peerId: Uuid().v4(),
sessionId: sessionId,
callId: callId,
media: 'audio',
);
_sessions[sessionId] = session;
await _createOffer(
session,
'audio',
callerName,
callerNumber,
destinationNumber,
clientState,
callId,
telnyxSessionId,
customHeaders,
);
// Indicate a new outbound call is created
onCallStateChange?.call(session, CallState.newCall);
}