Conference

Introduction Properties Methods Listeners

Introduction

The Conference object in the API handles, sends and updates all the important information throughout the lifetime of the call.

Properties

Name Type Description
callId

String

The current callId, you pass this into the Conference class constructor to start a call.
peerId

String

The current peerId, this is automatically generated for each participant and is used to identify each user, along with any data passed into the extraData parameter.
dataHandler DataHandler The current data handler instance, this can be used to pass any data to users of the conference throughout the lifetime of the call.

Methods

Name Description
constructor(apiKey: string, callId: string, extraData: any) Initializes the Conference object with provided data
getPermissionState(): {DevicePermissionStatus} Returns the current permission state for device (audio/video) access
setOutputDevice(deviceId: string) Sets the output device (speaker) for the current session
startCall() Initializes the session, connects to other Peers
endCall() Ends the call, cleaning up any session information
startScreenshare(): {Boolean | BAError} Starts a screenshare, returns either a Boolean or a BAError object
stopScreenshare(): {Boolean | BAError} Stops a screenshare, returns either a Boolean or a BAError object
BETA
setLocationType(location: LocationType)
Sets location of the current user to either 'onsite' or 'offsite'
BETA
setOnsiteMic(peerId: string)
Sets the new main onsite microphone based on given peerId and triggers an update to handle the changes based on the new peerId
BETA
getCurrentOnsiteMic(): {string}
Returns peerId of the current onsite main microphone
BETA
getAllOnsiteMics(): {string[]}
Returns an array of peerIds consisting of all possible onsite microphones

constructor(apiKey: string, callId: string, extraData: any)

Create's the conference object with the custom callId and stores any extraUserData to send as a string (i.e. userId) to other Peers

let status = conf.getPermissionState()

// returns
{ 
    state: "success" | "failed" | "denied",
    error: {
        reason: string // specific to each Browser DOM
        rawStr: string // error to display to user
    }
}

getPermissionState() -> {DevicePermissionStatus}

Between handles all the hard parts of getting device permissions for your application. Returns a DevicePermissionStatus object with details about the permission status.

let status = conf.getPermissionState()

// returns
{ 
    state: "success" | "failed" | "denied",
    error: {
        reason: string // specific to each Browser DOM
        rawStr: string // error to display to user
    }
}

setOutputDevice(deviceId: string)

Sets the device to use for audio output in the conference.

conf.setOutputDevice(deviceId: string)

startCall()

This method verifies the API key, and then starts the initial connection process to sockets and media servers. It also sets device permissions, sets up listeners for device data.

conf.startCall()

endCall()

Ends the call, cleaning up any session information and emitting a 'sessionTerminated' event on the Conference() class.

conf.endCall()

startScreenshare(): {Boolean | BAError}

Checks for screenshare permissions and publishes the selected window/screen. Emits a 'screenshareCreated' event to other participants and a 'localShareCreated' event for the local participant, on the Conference class.

try {
    await conf.startScreenshare()
} catch (error: BAError) {
    console.log("Error starting screenshare", error)
}

stopScreenshare(): {Boolean | BAError}

Stops screenshare, emitting a 'screenshareClosed' to other participants on the Conference class.

try {
    await conf.stopScreenshare()
} catch (error: BAError) {
    console.log("Error stopping screenshare", error)
}

BETA
setLocationType(location: LocationType)

Sets the location type for the current user. It must be called before startCall() to take effect.

let location = 'onsite' // 'onsite' | 'offsite
conf.setLocationType(location)

BETA
setOnsiteMic(peerId: string)

Sets the new main onsite microphone based on given peerId and triggers an update to handle the changes based on the new peerId.

// an example to get a new main onsite microphone
let newMainId = conf.getAllOnsiteMics()[0]

conf.setOnsiteMic(newMainId)

BETA
getCurrentOnsiteMic(): {string}

Returns peerId of the current onsite main microphone.

let currentMicId = conf.getCurrentOnsiteMic()

BETA
getAllOnsiteMics(): {string[]}

Returns an array of peerIds consisting of all possible onsite microphones.

let possibleMicIds = conf.getAllOnsiteMics()

Listeners

devicesUpdated -> {MediaDeviceInfo[]}

Media devices are automatically pushed to you whenever there's a change. Between supports video/audio input device on all browsers, audio output device are only supported on Chromium browsers.

conf.on('devicesUpdated', (MediaDeviceInfo[]) => { })

localParticipant -> {LocalParticipant}

When the local stream of the current user is published, the LocalParticipant object is emitted. This object allows for getting the video stream, muting/unmuting devices, changing devices, etc... Learn more here

conf.on('localParticipant', (LocalParticipant) => { })

peerJoined -> {Peer}

When a user joins a call, the Peer object is emitted. This object allows for getting their video stream, setting volume data, etc... Learn more here

conf.on('peerJoined', (peer: Peer) => { })

peerLeft -> {string}

When a user leaves a call, the id of the particpant is emitted as a string. You can do any custom cleanup required by your application such as removing the video.

conf.on('peerLeft', (peerId: string) => { })

socketFailed -> {}

Emitted when the socket connection fails, the API will attempt to reconnect until it cannot, the socketDisconnected is then emitted

conf.on('socketFailed', () => { })

socketDisconnected -> {}

Emitted when the socket disconnects unexpectedly.

conf.on('socketDisconnected', () => { })

socketClose -> {}

Emitted when the socket is closed from user input.

conf.on('socketClose', () => { })

localShareCreated -> {}

Emitted for the the local participant when they start screensharing.

conf.on('localShareCreated', () => { })

localShareClosed -> {}

Emitted for the the local participant when they stop screensharing specifically through the browser level interface.

conf.on('localShareClosed', () => { })

screenShareCreated -> {Peer}

Emitted when a peer starts screensharing, emits a new Peer object.

conf.on('screenShareCreated', (peer: Peer) => { })

screenShareClosed -> {string}

Emitted when a peer stops screensharing, emits the id of the Peer as well.

conf.on('screenShareClosed', (peerId: string) => { })

BETA
onsiteMicrophonesUpdated -> {string}

Emitted when onsite microphones are updated, usually when a new onsite peer joins or leaves.

conf.on('onsiteMicrophonesUpdated', (peerIds: string[]) => { })

BETA
notification -> {Notification}

Emitted when onsite network conditions change.

conf.on('notification', (peerId: Notification) => { })