Calls

calls

index

Properties

channel

the current call channel

string

status

current call status

"connected" | "connecting" | "disconnected" | "checking"

tracks

local tracks published by active user

Tracks

Methods

addTracks

addTracks(tracks: Tracks) : Promise<void>;

add local tracks to call

emits track:add event

Parameters

tracks

local tracks

Tracks
Returns
Promise<void>

addUsers

addUsers(users: string[]) : Promise<Status>;

add users to call, sends a newcall notification to users if they are online

emits user:add event

Parameters

users

an array of user ids to add to call

string[]
Returns
Promise<Status>

configure

configure(config: CallConfig) : Promise<Status>;

update channel configuration

emtts cnl:config event

Parameters

config

call channel configuration

CallConfig
Returns
Promise<Status>

create

create(channelId: string, tracks?: Tracks, config?: CallConfig) : Promise<Status>;

create a new call channel

fails if call exists at channel id or user has no permissions to create call.

Parameters

channelId

channel id

string
tracks ?

initial tracks

Tracks
config ?

call configuration

CallConfig
Returns
Promise<Status>

delUsers

delUsers(users: string[]) : Promise<Status>;

delete | remove users from call. users removed this way will not be able to join unless added again

emits user:del event

Parameters

users

an array of user ids to delete

string[]
Returns
Promise<Status>

delete

delete(reason?: string) : Promise<Status>;

delete call, disconnecting all active users, only the call owner (one who started it) can do this

emits cnl:delete event

Parameters

reason ?

optionally tell others the reason

string
Returns
Promise<Status>

getUsers

getUsers(): Promise<ActiveUser[]>;

get active call users,

Returns

active users mapped with their active tracks and muted statuses

Promise<ActiveUser[]>

join

join(channelId: string, tracks?: Tracks) : Promise<Status>;

join an existing call

emits user:join event

Parameters

channelId

channel id

string
tracks ?

initial tracks

Tracks
Returns
Promise<Status>

leave

leave(): Promise<Status>;

leave call channel

emits user:left event

Returns
Promise<Status>

modUsers

modUsers(users: User[]) : Promise<Status>;

moderate users in call,

disabling send permissions will mute a user's tracks but they will still be able to receive media, disabling recv permissions will pause sending media to user though they will still be connected, updating the permissions will resume send and recv operations.

emits user:mod event

check concepts for more about permissions

Parameters

users

an array of users to moderate

User[]
Returns
Promise<Status>

muteTracks

muteTracks(trackName: string | string[], newState: boolean) : Promise<void>;

Mute user tracks by name(s). this will send empty frames for video and audio

Empty audio frames have every sample's value set to 0. Empty video frames have every pixel set to black.

emits track:mute event

Parameters

trackName

track name to mute

string | string[]
newState

true to mute and false to unmute, if newState is currentState it is ignored

boolean
Returns
Promise<void>

muteUser

muteUser(userId: string, kind: "audio" | "video", newState: boolean, reason?: string) : Promise<void>;

mute another user's tracks

the user's tracks are not forwarded to other users in the same call channel until they are unmuted again only call admins can mute and unmute other users or else fails with [UnAuthorized]

this method takes in the track kind rather thanthe trackName to avoid users from recreating new tracks. muting a specific trackName is not supported.

emits track:mute event for all muted tracks

Parameters

userId

the userId to mute

string
kind

kind of track to mute can be either "video" or "audio"

"audio" | "video"
newState

true to mute and false to unmute, if newState is currentState it is ignored

boolean
reason ?

optional mute reason

string
Returns
Promise<void>

on

on<K extends keyof CallEventMap>(event: K, handler: (ev: CallEventMap[K]) : any;) : void;

listen for call events

Parameters

event

event

K
handler

event handler

(ev: CallEventMap[K]) : any;
Returns
void

removeTracks

removeTracks(name: string | string[]) : Promise<void>;

remove user tracks by name emits track:del event

Parameters

name

track name(s) to remove

string | string[]
Returns
Promise<void>