atmoky Engage Server SDK is now available! Check out the documentation to learn more.
API Reference
Classes
LocalParticipant

LocalParticipant

Summary
LocalParticipant represents the local user of the room.

Properties

audioTracks

Map of track sid => all published audio tracks
Type
Map<string, LocalTrackPublication>

identity

Participant's assigned identity (retrieved from the JWT token).
Type
string

isSpeaking

True if the participant is currently speaking
Type
boolean

isSpeakingLevel

The current audio level estimate of a speaker between 0 and 1.0, 1 being loudest, 0 being softest.
Remarks
This member is only updated when the order of loudest speakers changes.
Type
number

lastSpokeAt

optional
Date when participant last spoke
Type
Date

metadata

optional
Participant's metadata.
Type
string

name

optional
Participant's assigned display name (retrieved from the JWT token).
Type
string

permissions

optional
Participant's permissions.
Type
ParticipantPermission

sid

Server assigned unique id
Type
string

tracks

Map of track sid => all published tracks
Type
Map<string, LocalTrackPublication>

videoTracks

Map of track sid => all published video tracks
Type
Map<string, LocalTrackPublication>

Accessors

connectionQuality

Returns the current connection quality of the participant.

isCameraEnabled

True if the participant has enabled their camera.
Type
boolean

isMicrophoneEnabled

True if the participant has enabled their microphone.
Type
boolean

isScreenShareEnabled

True if the participant is currently sharing their screen.
Type
boolean

joinedAt

Date when the participant joined the room.
Type
undefined | Date

Methods

createScreenTracks

Creates a screen capture tracks with getDisplayMedia(). A LocalVideoTrack is always created and returned.
Signature
createScreenTracks(options?: ScreenShareCaptureOptions)
NameTypeDescription
options optionalScreenShareCaptureOptions
Returns
Promise<LocalTrack[]>
Remarks
If { audio: true }, and the browser supports audio capture, a LocalAudioTrack is also created.

createTracks

Create local camera and/or microphone tracks
Signature
createTracks(options?: CreateLocalTracksOptions)
NameTypeDescription
options optionalCreateLocalTracksOptions
Returns
Promise<LocalTrack[]>

enableCameraAndMicrophone

Publish both camera and microphone at the same time. This is useful for displaying a single Permission Dialog box to the end user.
Signature
enableCameraAndMicrophone()
Returns
Promise<void>

getPosition

Returns the position of the participant.
Signature
getPosition()
Returns
Vector3D
💡
This is not the position of the AudioListener. And will be (0,0,0) if the position has not been set.

getTracks

Returns a list of all tracks published by the participant.
Signature
getTracks()

publishData

Publish a new data payload to the room. Data will be forwarded to each participant in the room if the destination field in publishOptions is empty
Signature
publishData(data: Uint8Array, kind: DataPacket_Kind, publishOptions?: DataPublishOptions)
NameTypeDescription
dataUint8ArrayUint8Array of the payload. To send string data, use TextEncoder.encode
kindDataPacket_Kindwhether to send this as reliable or lossy.
For data that you need delivery guarantee (such as chat messages), use Reliable.
For data that should arrive as quickly as possible, but you are ok with dropped
packets, use Lossy.
publishOptions optionalDataPublishOptionsoptionally specify a topic and destination
Returns
Promise<void>

publishTrack

Publish a new track to the room
Signature
publishTrack(track: MediaStreamTrack | LocalTrack, options?: TrackPublishOptions)
NameTypeDescription
trackMediaStreamTrack | LocalTrack
options optionalTrackPublishOptions
Returns
Promise<LocalTrackPublication>

setCameraEnabled

Enable or disable a participant's camera track.
If a track has already published, it'll mute or unmute the track. Resolves with a LocalTrackPublication instance if successful and undefined otherwise
Signature
setCameraEnabled(enabled: boolean, options?: VideoCaptureOptions, publishOptions?: TrackPublishOptions)
NameTypeDescription
enabledboolean
options optionalVideoCaptureOptions
publishOptions optionalTrackPublishOptions
Returns
Promise<undefined | LocalTrackPublication>

setMetadata

Sets and updates the metadata of the local participant. Note: this requires CanUpdateOwnMetadata permission encoded in the token.
Signature
setMetadata(metadata: string)
NameTypeDescription
metadatastring
Returns
void

setMicrophoneEnabled

Enable or disable a participant's microphone track.
If a track has already published, it'll mute or unmute the track. Resolves with a LocalTrackPublication instance if successful and undefined otherwise
Signature
setMicrophoneEnabled(enabled: boolean, options?: AudioCaptureOptions, publishOptions?: TrackPublishOptions)
NameTypeDescription
enabledboolean
options optionalAudioCaptureOptions
publishOptions optionalTrackPublishOptions
Returns
Promise<undefined | LocalTrackPublication>
💡
The first time microphone access is requested, this methods tries to resume the audio context. It must therefore be called from a user action handler (e.g. click handler) in order to succeed.

setName

Sets and updates the name of the local participant. Note: this requires CanUpdateOwnMetadata permission encoded in the token.
Signature
setName(name: string)
NameTypeDescription
namestring
Returns
void

setPosition

Sets the position of the local participant.
Signature
setPosition(x: number, y: number, z: number)
NameTypeDescription
xnumberx-coordinate
ynumbery-coordinate
znumberz-coordinate
Returns
void
Remarks
This position is broadcasted to other participants in the room if the PositionSync feature is enabled (see positionSync).
Note, this will not set the position of the AudioListener as it may differ from the position of the participant. To set the position of the AudioListener, use setPosition.

setScreenShareEnabled

Start or stop sharing a participant's screen Resolves with a LocalTrackPublication instance if successful and undefined otherwise
Signature
setScreenShareEnabled(enabled: boolean, options?: ScreenShareCaptureOptions, publishOptions?: TrackPublishOptions)
NameTypeDescription
enabledboolean
options optionalScreenShareCaptureOptions
publishOptions optionalTrackPublishOptions
Returns
Promise<undefined | LocalTrackPublication>

setTrackSubscriptionPermissions

Control who can subscribe to LocalParticipant's published tracks.
By default, all participants can subscribe. This allows fine-grained control over who is able to subscribe at a participant and track level.
Note: if access is given at a track-level (i.e. both [allParticipantsAllowed] and [ParticipantTrackPermission.allTracksAllowed] are false), any newer published tracks will not grant permissions to any participants and will require a subsequent permissions update to allow subscription.
Signature
setTrackSubscriptionPermissions(allParticipantsAllowed: boolean, participantTrackPermissions: ParticipantTrackPermission[])
NameTypeDescription
allParticipantsAllowedbooleanAllows all participants to subscribe all tracks.
Takes precedence over participantTrackPermissions if set to true.
By default this is set to true.
participantTrackPermissionsParticipantTrackPermission[]Full list of individual permissions per
participant/track. Any omitted participants will not receive any permissions.
Returns
void

unpublishTrack

Unpublish a track from the room
Signature
unpublishTrack(track: MediaStreamTrack | LocalTrack, stopOnUnpublish?: boolean)
NameTypeDescription
trackMediaStreamTrack | LocalTrackThe track to unpublish.
stopOnUnpublish optionalbooleanWhether to stop the track after unpublishing.
Returns
Promise<undefined | LocalTrackPublication> Promise resolving in the publication that was unpublished or undefined. if no publication was found.

unpublishTracks

Unpublish several tracks at once.
Signature
unpublishTracks(tracks: MediaStreamTrack[] | LocalTrack[])
NameTypeDescription
tracksMediaStreamTrack[] | LocalTrack[]
Returns
Promise<LocalTrackPublication[]>

atmoky Logo

© 2024 atmoky, GmbH.
All rights reserved.

We use cookies to measure and improve your browsing experience, and serve personalized ads or content.