Skip to content

DigitalWorldCall

Defined in: src/webrtc/call.ts:355

Typed Event Emitter class which can act as a Base Model for all our model and communication events. This makes it much easier for us to distinguish between events, as we now need to properly type this, so that our events are not stringly-based and prone to silly typos.

Type parameters:

  • Events - List of all events emitted by this TypedEventEmitter. Normally an enum type.
  • Arguments - A ListenerMap type providing mappings from event names to listener types.
  • SuperclassArguments - TODO: not really sure. Alternative listener mappings, I think? But only honoured for .emit?

callId: string

Defined in: src/webrtc/call.ts:357


optional direction?: CallDirection

Defined in: src/webrtc/call.ts:361


optional groupCallId?: string

Defined in: src/webrtc/call.ts:429


optional hangupParty?: CallParty

Defined in: src/webrtc/call.ts:359


optional hangupReason?: string

Defined in: src/webrtc/call.ts:360


optional invitee?: string

Defined in: src/webrtc/call.ts:358


isPtt: boolean = false

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


ourPartyId: string

Defined in: src/webrtc/call.ts:362


optional peerConn?: RTCPeerConnection

Defined in: src/webrtc/call.ts:363


roomId: string

Defined in: src/webrtc/call.ts:356


toDeviceSeq: number = 0

Defined in: src/webrtc/call.ts:364

get hasLocalUserMediaAudioTrack(): boolean

Defined in: src/webrtc/call.ts:549

boolean


get hasLocalUserMediaVideoTrack(): boolean

Defined in: src/webrtc/call.ts:539

boolean


get hasPeerConnection(): boolean

Defined in: src/webrtc/call.ts:2976

boolean


get hasRemoteUserMediaAudioTrack(): boolean

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

boolean


get hasRemoteUserMediaVideoTrack(): boolean

Defined in: src/webrtc/call.ts:543

boolean


get localScreensharingFeed(): CallFeed | undefined

Defined in: src/webrtc/call.ts:571

CallFeed | undefined


get localScreensharingStream(): MediaStream | undefined

Defined in: src/webrtc/call.ts:579

MediaStream | undefined


get localUsermediaFeed(): CallFeed | undefined

Defined in: src/webrtc/call.ts:567

CallFeed | undefined


get localUsermediaStream(): MediaStream | undefined

Defined in: src/webrtc/call.ts:575

MediaStream | undefined


get remoteScreensharingFeed(): CallFeed | undefined

Defined in: src/webrtc/call.ts:587

CallFeed | undefined


get remoteScreensharingStream(): MediaStream | undefined

Defined in: src/webrtc/call.ts:595

MediaStream | undefined


get remoteUsermediaFeed(): CallFeed | undefined

Defined in: src/webrtc/call.ts:583

CallFeed | undefined


get remoteUsermediaStream(): MediaStream | undefined

Defined in: src/webrtc/call.ts:591

MediaStream | undefined


get state(): CallState

Defined in: src/webrtc/call.ts:523

CallState

set state(state): void

Defined in: src/webrtc/call.ts:527

CallState

void


get type(): CallType

Defined in: src/webrtc/call.ts:533

CallType

optional [captureRejectionSymbol]<K>(error, event, …args): void

Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:103

K

Error

string | symbol

AnyRest

void

TypedEventEmitter.[captureRejectionSymbol]


addListener<T>(event, listener): this

Defined in: src/models/typed-event-emitter.ts:70

Alias for on.

T extends EventEmitterEvents | CallEvent

T

Listener<CallEvent, CallEventHandlerMap, T>

this

TypedEventEmitter.addListener


answer(audio?, video?): Promise<void>

Defined in: src/webrtc/call.ts:1065

Answer a call.

boolean

boolean

Promise<void>


answerWithCallFeeds(callFeeds): void

Defined in: src/webrtc/call.ts:1118

CallFeed[]

void


callHasEnded(): boolean

Defined in: src/webrtc/call.ts:2067

boolean


createDataChannel(label, options): RTCDataChannel

Defined in: src/webrtc/call.ts:493

Create a datachannel using this call’s peer connection.

string

A human readable label for this datachannel

RTCDataChannelInit | undefined

An object providing configuration options for the data channel.

RTCDataChannel


emit<T>(event, …args): boolean

Defined in: src/models/typed-event-emitter.ts:86

Synchronously calls each of the listeners registered for the event named event, in the order they were registered, passing the supplied arguments to each.

T extends CallEvent

T

The name of the event to emit

Parameters<CallEventHandlerMap[T]>

Arguments to pass to the listener

boolean

true if the event had listeners, false otherwise.

TypedEventEmitter.emit

emit<T>(event, …args): boolean

Defined in: src/models/typed-event-emitter.ts:87

Synchronously calls each of the listeners registered for the event named event, in the order they were registered, passing the supplied arguments to each.

T extends CallEvent

T

The name of the event to emit

Parameters<CallEventHandlerMap[T]>

Arguments to pass to the listener

boolean

true if the event had listeners, false otherwise.

TypedEventEmitter.emit


emitPromised<T>(event, …args): Promise<boolean>

Defined in: src/models/typed-event-emitter.ts:98

Similar to emit but calls all listeners within a Promise.all and returns the promise chain

T extends CallEvent

T

The name of the event to emit

Parameters<CallEventHandlerMap[T]>

Arguments to pass to the listener

Promise<boolean>

true if the event had listeners, false otherwise.

TypedEventEmitter.emitPromised

emitPromised<T>(event, …args): Promise<boolean>

Defined in: src/models/typed-event-emitter.ts:102

Similar to emit but calls all listeners within a Promise.all and returns the promise chain

T extends CallEvent

T

The name of the event to emit

Parameters<CallEventHandlerMap[T]>

Arguments to pass to the listener

Promise<boolean>

true if the event had listeners, false otherwise.

TypedEventEmitter.emitPromised


eventNames(): (string | symbol)[]

Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:967

Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or Symbols.

import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.on('foo', () => {});
myEE.on('bar', () => {});
const sym = Symbol('symbol');
myEE.on(sym, () => {});
console.log(myEE.eventNames());
// Prints: [ 'foo', 'bar', Symbol(symbol) ]

(string | symbol)[]

v6.0.0

TypedEventEmitter.eventNames


getCurrentCallStats(): Promise<any[] | undefined>

Defined in: src/webrtc/call.ts:917

Promise<any[] | undefined>


getFeeds(): CallFeed[]

Defined in: src/webrtc/call.ts:607

Returns an array of all CallFeeds

CallFeed[]

CallFeeds


getLocalFeeds(): CallFeed[]

Defined in: src/webrtc/call.ts:615

Returns an array of all local CallFeeds

CallFeed[]

local CallFeeds


getMaxListeners(): number

Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:819

Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to EventEmitter.defaultMaxListeners.

number

v1.0.0

TypedEventEmitter.getMaxListeners


getOpponentDeviceId(): string | undefined

Defined in: src/webrtc/call.ts:503

string | undefined


getOpponentMember(): RoomMember | undefined

Defined in: src/webrtc/call.ts:499

RoomMember | undefined


getOpponentSessionId(): string | undefined

Defined in: src/webrtc/call.ts:507

string | undefined


getRemoteAssertedIdentity(): AssertedIdentity | undefined

Defined in: src/webrtc/call.ts:519

AssertedIdentity | undefined


getRemoteFeeds(): CallFeed[]

Defined in: src/webrtc/call.ts:623

Returns an array of all remote CallFeeds

CallFeed[]

remote CallFeeds


hangup(reason, suppressEvent): void

Defined in: src/webrtc/call.ts:1156

Hangup a call.

CallErrorCode

The reason why the call is being hung up.

boolean

True to suppress emitting an event.

void


initStats(stats, peerId?): void

Defined in: src/webrtc/call.ts:2980

GroupCallStats

string = "unknown"

void


initWithHangup(event): void

Defined in: src/webrtc/call.ts:1031

Configure this call from a hangup or reject event. Used by DigitalWorldClient.

DigitalWorldEvent

The m.call.hangup event

void


initWithInvite(event): Promise<void>

Defined in: src/webrtc/call.ts:943

Configure this call from an invite event. Used by DigitalWorldClient.

DigitalWorldEvent

The m.call.invite event

Promise<void>


isLocalOnHold(): boolean

Defined in: src/webrtc/call.ts:1552

Indicates whether we are ‘on hold’ to the remote party (ie. if true, they cannot hear us).

boolean

true if the other party has put us on hold


isLocalVideoMuted(): boolean

Defined in: src/webrtc/call.ts:1485

Check if local video is muted.

If there are multiple video tracks, all of the tracks need to be muted for this to return true. This means if there are no video tracks, this will return true.

boolean

True if the local preview video is muted, else false (including if the call is not set up yet).


isMicrophoneMuted(): boolean

Defined in: src/webrtc/call.ts:1519

Check if the microphone is muted.

If there are multiple audio tracks, all of the tracks need to be muted for this to return true. This means if there are no audio tracks, this will return true.

boolean

True if the mic is muted, else false (including if the call is not set up yet).


isRemoteOnHold(): boolean

Defined in: src/webrtc/call.ts:1527

boolean

true if we have put the party on the other side of the call on hold (that is, we are signalling to them that we are not listening)


isScreensharing(): boolean

Defined in: src/webrtc/call.ts:1235

If there is a screensharing stream returns true, otherwise returns false

boolean

is screensharing


listenerCount(event): number

Defined in: src/models/typed-event-emitter.ts:115

Returns the number of listeners listening to the event named event.

EventEmitterEvents | CallEvent

The name of the event being listened for

number

TypedEventEmitter.listenerCount


listeners(event): Function[]

Defined in: src/models/typed-event-emitter.ts:122

Returns a copy of the array of listeners for the event named event.

EventEmitterEvents | CallEvent

Function[]

TypedEventEmitter.listeners


noIncomingFeeds(): boolean

Defined in: src/webrtc/call.ts:671

Returns true if there are no incoming feeds, otherwise returns false

boolean

no incoming feeds


off<T>(event, listener): this

Defined in: src/models/typed-event-emitter.ts:129

Alias for removeListener

T extends EventEmitterEvents | CallEvent

T

Listener<CallEvent, CallEventHandlerMap, T>

this

TypedEventEmitter.off


on<T>(event, listener): this

Defined in: src/models/typed-event-emitter.ts:150

Adds the listener function to the end of the listeners array for the event named event.

No checks are made to see if the listener has already been added. Multiple calls passing the same combination of event and listener will result in the listener being added, and called, multiple times.

By default, event listeners are invoked in the order they are added. The prependListener method can be used as an alternative to add the event listener to the beginning of the listeners array.

T extends EventEmitterEvents | CallEvent

T

The name of the event.

Listener<CallEvent, CallEventHandlerMap, T>

The callback function

this

a reference to the EventEmitter, so that calls can be chained.

TypedEventEmitter.on


onAnsweredElsewhere(msg): void

Defined in: src/webrtc/call.ts:2464

MCallAnswer

void


onAnswerReceived(event): Promise<void>

Defined in: src/webrtc/call.ts:1875

Used by DigitalWorldClient.

DigitalWorldEvent

Promise<void>


onAssertedIdentityReceived(event): Promise<void>

Defined in: src/webrtc/call.ts:2056

DigitalWorldEvent

Promise<void>


once<T>(event, listener): this

Defined in: src/models/typed-event-emitter.ts:169

Adds a one-time listener function for the event named event. The next time event is triggered, this listener is removed and then invoked.

Returns a reference to the EventEmitter, so that calls can be chained.

By default, event listeners are invoked in the order they are added. The prependOnceListener method can be used as an alternative to add the event listener to the beginning of the listeners array.

T extends EventEmitterEvents | CallEvent

T

The name of the event.

Listener<CallEvent, CallEventHandlerMap, T>

The callback function

this

a reference to the EventEmitter, so that calls can be chained.

TypedEventEmitter.once


onHangupReceived(msg): void

Defined in: src/webrtc/call.ts:2428

MCallHangupReject

void


onNegotiateReceived(event): Promise<void>

Defined in: src/webrtc/call.ts:1959

DigitalWorldEvent

Promise<void>


onRejectReceived(msg): void

Defined in: src/webrtc/call.ts:2443

MCallHangupReject

void


onRemoteIceCandidatesReceived(ev): Promise<void>

Defined in: src/webrtc/call.ts:1831

DigitalWorldEvent

Promise<void>


onSDPStreamMetadataChangedReceived(event): void

Defined in: src/webrtc/call.ts:2048

DigitalWorldEvent

void


onSelectAnswerReceived(event): Promise<void>

Defined in: src/webrtc/call.ts:1933

DigitalWorldEvent

Promise<void>


opponentCanBeTransferred(): boolean

Defined in: src/webrtc/call.ts:511

boolean


opponentSupportsDTMF(): boolean

Defined in: src/webrtc/call.ts:515

boolean


opponentSupportsSDPStreamMetadata(): boolean

Defined in: src/webrtc/call.ts:1227

Returns true if this.remoteSDPStreamMetadata is defined, otherwise returns false

boolean

can screenshare


placeCall(audio, video): Promise<void>

Defined in: src/webrtc/call.ts:2810

Place a call to this room.

boolean

boolean

Promise<void>

if you have not specified a listener for ‘error’ events.

if have passed audio=false.


placeCallWithCallFeeds(callFeeds, requestScreenshareFeed?): Promise<void>

Defined in: src/webrtc/call.ts:2854

Place a call to this room with call feed.

CallFeed[]

to use

boolean = false

Promise<void>

if you have not specified a listener for ‘error’ events.

if have passed audio=false.


placeVideoCall(): Promise<void>

Defined in: src/webrtc/call.ts:484

Place a video call to this room.

Promise<void>

If you have not specified a listener for ‘error’ events.


placeVoiceCall(): Promise<void>

Defined in: src/webrtc/call.ts:476

Place a voice call to this room.

Promise<void>

If you have not specified a listener for ‘error’ events.


prependListener<T>(event, listener): this

Defined in: src/models/typed-event-emitter.ts:186

Adds the listener function to the beginning of the listeners array for the event named event.

No checks are made to see if the listener has already been added. Multiple calls passing the same combination of event and listener will result in the listener being added, and called, multiple times.

T extends EventEmitterEvents | CallEvent

T

The name of the event.

Listener<CallEvent, CallEventHandlerMap, T>

The callback function

this

a reference to the EventEmitter, so that calls can be chained.

TypedEventEmitter.prependListener


prependOnceListener<T>(event, listener): this

Defined in: src/models/typed-event-emitter.ts:202

Adds a one-timelistener function for the event named event to the beginning of the listeners array. The next time event is triggered, this listener is removed, and then invoked.

T extends EventEmitterEvents | CallEvent

T

The name of the event.

Listener<CallEvent, CallEventHandlerMap, T>

The callback function

this

a reference to the EventEmitter, so that calls can be chained.

TypedEventEmitter.prependOnceListener


pushLocalFeed(callFeed, addToPeerConnection?): void

Defined in: src/webrtc/call.ts:806

Pushes supplied feed to the call

CallFeed

to push

boolean = true

whether to add the tracks to the peer connection

void


rawListeners(event): Function[]

Defined in: src/models/typed-event-emitter.ts:243

Returns a copy of the array of listeners for the event named eventName, including any wrappers (such as those created by .once()).

EventEmitterEvents | CallEvent

Function[]

TypedEventEmitter.rawListeners


reject(): void

Defined in: src/webrtc/call.ts:1176

Reject a call This used to be done by calling hangup, but is a separate method and protocol event as of MSC2746.

void


removeAllListeners(event?): this

Defined in: src/models/typed-event-emitter.ts:219

Removes all listeners, or those of the specified event.

It is bad practice to remove listeners added elsewhere in the code, particularly when the EventEmitter instance was created by some other component or module (e.g. sockets or file streams).

EventEmitterEvents | CallEvent

The name of the event. If undefined, all listeners everywhere are removed.

this

a reference to the EventEmitter, so that calls can be chained.

TypedEventEmitter.removeAllListeners


removeListener<T>(event, listener): this

Defined in: src/models/typed-event-emitter.ts:232

Removes the specified listener from the listener array for the event named event.

T extends EventEmitterEvents | CallEvent

T

Listener<CallEvent, CallEventHandlerMap, T>

this

a reference to the EventEmitter, so that calls can be chained.

TypedEventEmitter.removeListener


removeLocalFeed(callFeed): void

Defined in: src/webrtc/call.ts:867

Removes local call feed from the call and its tracks from the peer connection

CallFeed

to remove

void


replacedBy(newCall): void

Defined in: src/webrtc/call.ts:1129

Replace this call with a new call, e.g. for glare resolution. Used by DigitalWorldClient.

DigitalWorldCall

The new call.

void


sendDtmfDigit(digit): void

Defined in: src/webrtc/call.ts:1572

Sends a DTMF digit to the other party

string

The digit (nb. string - ‘#’ and ‘*’ are dtmf too)

void


sendMetadataUpdate(): Promise<void>

Defined in: src/webrtc/call.ts:1597

Promise<void>


setLocalVideoMuted(muted): Promise<boolean>

Defined in: src/webrtc/call.ts:1425

Set whether our outbound video should be muted or not.

boolean

True to mute the outbound video.

Promise<boolean>

the new mute state


setMaxListeners(n): this

Defined in: node_modules/.pnpm/@types+node@22.20.0/node_modules/@types/node/events.d.ts:813

By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. The emitter.setMaxListeners() method allows the limit to be modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

Returns a reference to the EventEmitter, so that calls can be chained.

number

this

v0.3.5

TypedEventEmitter.setMaxListeners


setMicrophoneMuted(muted): Promise<boolean>

Defined in: src/webrtc/call.ts:1494

Set whether the microphone should be muted or not.

boolean

True to mute the mic.

Promise<boolean>

the new mute state


setRemoteOnHold(onHold): void

Defined in: src/webrtc/call.ts:1531

boolean

void


setScreensharingEnabled(enabled, opts?): Promise<boolean>

Defined in: src/webrtc/call.ts:1245

Starts/stops screensharing

boolean

the desired screensharing state

IScreensharingOpts

screen sharing options

Promise<boolean>

new screensharing state


transfer(targetUserId): Promise<void>

Defined in: src/webrtc/call.ts:2604

string

Promise<void>


transferToCall(transferTargetCall): Promise<void>

Defined in: src/webrtc/call.ts:2630

DigitalWorldCall

Promise<void>


updateLocalUsermediaStream(stream, forceAudio?, forceVideo?): Promise<void>

Defined in: src/webrtc/call.ts:1350

Replaces/adds the tracks from the passed stream to the localUsermediaStream

MediaStream

to use a replacement for the local usermedia stream

boolean = false

boolean = false

Promise<void>