Skip to main content

@dialstack/sdk-dev / webrtc/src / Call

Class: Call

Defined in: sdk/webrtc/src/call.ts:169

Constructors​

Constructor​

TypeScript
new Call(init): Call;

Defined in: sdk/webrtc/src/call.ts:308

Parameters​

init​

CallInit

Returns​

Call

Properties​

direction​

TypeScript
readonly direction: CallDirection;

Defined in: sdk/webrtc/src/call.ts:173


duration​

TypeScript
duration: number = 0;

Defined in: sdk/webrtc/src/call.ts:179


from​

TypeScript
readonly from: string;

Defined in: sdk/webrtc/src/call.ts:174


fromName​

TypeScript
readonly fromName: string | null;

Defined in: sdk/webrtc/src/call.ts:175


id​

TypeScript
id: string;

Defined in: sdk/webrtc/src/call.ts:172


isMuted​

TypeScript
isMuted: boolean = false;

Defined in: sdk/webrtc/src/call.ts:178


peerConnection​

TypeScript
readonly peerConnection: RTCPeerConnection;

Defined in: sdk/webrtc/src/call.ts:180


state​

TypeScript
state: CallState;

Defined in: sdk/webrtc/src/call.ts:177


to​

TypeScript
readonly to: string;

Defined in: sdk/webrtc/src/call.ts:176

Accessors​

audioInputDeviceId​

Get Signature​

TypeScript
get audioInputDeviceId(): string | null;

Defined in: sdk/webrtc/src/call.ts:414

The selected mic, or null for the OS default.

Returns​

string | null


canSendDtmf​

Get Signature​

TypeScript
get canSendDtmf(): boolean;

Defined in: sdk/webrtc/src/call.ts:217

Whether DTMF can be sent on this call — the gate the softphone UI uses for its in-call keypad. False when the audio sender exposes no .dtmf (e.g. a connected call that never got a usable sender). Only meaningful once the call is active — the sender is attached during answer/offer negotiation (attachDtmfSender). sendDtmf() still throws if called anyway. Both web and native go through the same sender: web via the browser RTCDTMFSender, native via react-native-webrtc's RTCRtpSender.dtmf (provided by the DialStack fork).

Returns​

boolean


effectiveAudioInputDeviceId​

Get Signature​

TypeScript
get effectiveAudioInputDeviceId(): string | null;

Defined in: sdk/webrtc/src/call.ts:422

The device actually captured. May differ from audioInputDeviceId at acquisition, where the constraint is ideal — how a caller detects a substitution.

Returns​

string | null


isConnected​

Get Signature​

TypeScript
get isConnected(): boolean;

Defined in: sdk/webrtc/src/call.ts:204

Whether the call is a live, connected conversation — answered and not ended. Hold is a media modifier, not a separate lifecycle, so BOTH active and held count as connected; trying/ringing (not yet up) and ended do not. This is the single source of truth for "is this call transferable / bridgeable / controllable" — every such gate (transfer, completeTransfer, the in-call control row, isCallActive) reads it so the rule can't drift between call sites.

Returns​

boolean


isFinished​

Get Signature​

TypeScript
get isFinished(): boolean;

Defined in: sdk/webrtc/src/call.ts:573

Internal

True once the call is over by either path: the server's call.ended (which sets endedSettled) or a local dispose().

Returns​

boolean


isHeld​

Get Signature​

TypeScript
get isHeld(): boolean;

Defined in: sdk/webrtc/src/call.ts:182

Returns​

boolean


isReconnecting​

Get Signature​

TypeScript
get isReconnecting(): boolean;

Defined in: sdk/webrtc/src/call.ts:191

True while the signalling socket is down and the phone is resuming its session. The call is still up: audio keeps flowing on an unchanged network, and hold, mute and hang-up issued now apply once it is back.

Returns​

boolean


localMediaStream​

Get Signature​

TypeScript
get localMediaStream(): MediaStream;

Defined in: sdk/webrtc/src/call.ts:902

The local capture (mic) stream. A local conference mixes against this rather than opening a second getUserMedia, so every merged leg shares the one capture the call already owns.

Returns​

MediaStream


remoteMediaStream​

Get Signature​

TypeScript
get remoteMediaStream(): MediaStream;

Defined in: sdk/webrtc/src/call.ts:893

Returns​

MediaStream

Methods​

acceptRemoteAnswer()​

TypeScript
acceptRemoteAnswer(sdp): Promise<void>;

Defined in: sdk/webrtc/src/call.ts:1095

Parameters​

sdp​

string

Returns​

Promise<void>


acceptRemoteProvisionalAnswer()​

TypeScript
acceptRemoteProvisionalAnswer(sdp): Promise<boolean>;

Defined in: sdk/webrtc/src/call.ts:1058

Parameters​

sdp​

string

Returns​

Promise<boolean>


addRemoteCandidate()​

TypeScript
addRemoteCandidate(
candidate,
sdpMid,
sdpMLineIndex
): Promise<void>;

Defined in: sdk/webrtc/src/call.ts:1120

Parameters​

candidate​

string

sdpMid​

string | null

sdpMLineIndex​

number | null

Returns​

Promise<void>


answer()​

TypeScript
answer(): void;

Defined in: sdk/webrtc/src/call.ts:617

Returns​

void


attachConference()​

TypeScript
attachConference(conference): void;

Defined in: sdk/webrtc/src/call.ts:913

Attach (or detach, with null) the local conference this call is merged into.

While attached, the wire carries the conference's MIXED track rather than this call's mic track, which changes what mute has to do — see mute(). Set by the conference owner (the softphone's merge action), not by the core.

Parameters​

conference​

ConferenceSink | null

Returns​

void


attendedTransfer()​

TypeScript
attendedTransfer(destination): Promise<Call>;

Defined in: sdk/webrtc/src/call.ts:821

Attended (consultative) transfer, step 1: hold this call and dial destination as a consult leg. Resolves with the consult Call. Once the consult party answers, call completeTransfer() on THIS call to bridge them; or hang up the consult and resume() to abandon the transfer.

Parameters​

destination​

string

Returns​

Promise<Call>


completeTransfer()​

TypeScript
completeTransfer(): void;

Defined in: sdk/webrtc/src/call.ts:843

Attended transfer, step 2: bridge the remote party to the consult leg's party. Valid once the consult call (started via attendedTransfer) is answered; this call is held at that point. On success both calls end with reason 'transferred'.

Returns​

void


dispose()​

TypeScript
dispose(): void;

Defined in: sdk/webrtc/src/call.ts:1197

Returns​

void


endLocally()​

TypeScript
endLocally(reason): void;

Defined in: sdk/webrtc/src/call.ts:1395

Internal

End the call here without waiting for the server, because the socket it lived on is gone. Emits ended like a server end, so every owner tears down the same way.

Parameters​

reason​

CallEndReason

Returns​

void


handleActionError()​

TypeScript
handleActionError(reqId): void;

Defined in: sdk/webrtc/src/call.ts:589

Internal

The server's error reply to one of this call's actions.

Parameters​

reqId​

string

Returns​

void


handleServerMessage()​

TypeScript
handleServerMessage(msg): void;

Defined in: sdk/webrtc/src/call.ts:1151

Parameters​

msg​

ServerMessage

Returns​

void


hangup()​

TypeScript
hangup(): void;

Defined in: sdk/webrtc/src/call.ts:663

Returns​

void


hold()​

TypeScript
hold(): void;

Defined in: sdk/webrtc/src/call.ts:673

Returns​

void


holdAfterResume()​

TypeScript
holdAfterResume(): void;

Defined in: sdk/webrtc/src/call.ts:708

Re-hold a call resume() ran on in this same tick. hold()'s state !== 'active' guard would swallow it, since the state only flips on the server echo. Only for that unwind; use hold() everywhere else.

Returns​

void


mute()​

TypeScript
mute(): void;

Defined in: sdk/webrtc/src/call.ts:726

Returns​

void


off()​

TypeScript
off<K>(event, handler?): void;

Defined in: sdk/webrtc/src/call.ts:609

Type Parameters​

K​

K extends keyof CallEventMap

Parameters​

event​

K

handler?​

Listener<K>

Returns​

void


on()​

TypeScript
on<K>(event, handler): void;

Defined in: sdk/webrtc/src/call.ts:600

Type Parameters​

K​

K extends keyof CallEventMap

Parameters​

event​

K

handler​

Listener<K>

Returns​

void


onAnswerFailure()​

TypeScript
onAnswerFailure(report): void;

Defined in: sdk/webrtc/src/call.ts:368

Internal

Set by the owner to surface an answer built off the offer path failing.

Parameters​

report​

(e) => void

Returns​

void


onCaptureFailure()​

TypeScript
onCaptureFailure(report): void;

Defined in: sdk/webrtc/src/call.ts:375

Parameters​

report​

(e) => void

Returns​

void


ownsRequest()​

TypeScript
ownsRequest(reqId): boolean;

Defined in: sdk/webrtc/src/call.ts:584

Internal

Whether reqId names an action frame this call sent.

Parameters​

reqId​

string

Returns​

boolean


prepareAnswerForOffer()​

TypeScript
prepareAnswerForOffer(sdp): Promise<void>;

Defined in: sdk/webrtc/src/call.ts:938

Parameters​

sdp​

string

Returns​

Promise<void>


reject()​

TypeScript
reject(reason?): void;

Defined in: sdk/webrtc/src/call.ts:654

Parameters​

reason?​

RejectReason = 'decline'

Returns​

void


restartIce()​

TypeScript
restartIce(): void;

Defined in: sdk/webrtc/src/call.ts:1278

Restart ICE on this call: gather candidates afresh on the current network and renegotiate them with the far end. The call does this by itself when ICE fails, stays disconnected, or a resumed session finds media down; it is public for hosts that learn of a network change first (an OS event). A no-op unless the call is connected, and while a restart is under way.

Returns​

void


restore()​

TypeScript
restore(msg): void;

Defined in: sdk/webrtc/src/call.ts:1231

Internal

The resumed session still has this call. Adopts the server's view of its hold state, which the frames lost in the gap may have changed.

Mute goes the other way: the user's choice is the local one, and the track already follows it, so a server that disagrees lost a mute or unmute on the dying socket and is told again. One the user made during the drop was queued and is already on its way; sending it twice changes nothing.

Parameters​

msg​
answered_at​

string

call_id​

string

direction​

CallDirection

from​

string

from_name?​

string | null

held​

boolean

muted​

boolean

to​

string

type​

"call.restored"

Returns​

void


resume()​

TypeScript
resume(): void;

Defined in: sdk/webrtc/src/call.ts:715

Returns​

void


sendDtmf()​

TypeScript
sendDtmf(
digits,
duration?,
interToneGap?
): void;

Defined in: sdk/webrtc/src/call.ts:770

Parameters​

digits​

string

duration?​

number = 100

interToneGap?​

number = 70

Returns​

void


setAudioInputDevice()​

TypeScript
setAudioInputDevice(deviceId): Promise<void>;

Defined in: sdk/webrtc/src/call.ts:428

Internal — the phone-level setter broadcasts this to every live call.

Parameters​

deviceId​

string | null

Returns​

Promise<void>


setAudioOutputDevice()​

TypeScript
setAudioOutputDevice(deviceId): void;

Defined in: sdk/webrtc/src/call.ts:553

Route this call's ringback tone to deviceId (null = OS default).

Parameters​

deviceId​

string | null

Returns​

void


setConferenceHold()​

TypeScript
setConferenceHold(held): void;

Defined in: sdk/webrtc/src/call.ts:693

Hold or resume this leg as part of holding the whole conference.

hold() refuses while merged because holding ONE party silences it to the other. Holding every leg together is the coherent version, so the caller that does that reaches the frames through here.

Parameters​

held​

boolean

Returns​

void


startOutbound()​

TypeScript
startOutbound(): Promise<RTCSessionDescriptionInit>;

Defined in: sdk/webrtc/src/call.ts:925

Returns​

Promise<RTCSessionDescriptionInit>


suspend()​

TypeScript
suspend(): void;

Defined in: sdk/webrtc/src/call.ts:1210

Internal

The socket dropped and the phone is resuming the session; the call stays up meanwhile.

Returns​

void


transfer()​

TypeScript
transfer(destination): void;

Defined in: sdk/webrtc/src/call.ts:793

Blind transfer: redirect the remote party to destination. The call must be connected.

Once the far end accepts, the server hangs up and the call ends as 'transferred' while the target may still be ringing; the outcome is not reported. A transfer the far end refuses reports a transfer_failed error and leaves the call connected.

One transfer at a time: a second throws a transfer_failed error until the server has answered the first.

Parameters​

destination​

string

Returns​

void


unmute()​

TypeScript
unmute(): void;

Defined in: sdk/webrtc/src/call.ts:730

Returns​

void


whenLocalMediaReady()​

TypeScript
whenLocalMediaReady(): Promise<void>;

Defined in: sdk/webrtc/src/call.ts:382

Returns​

Promise<void>