SkylinkEvents

Namespace

SkylinkEvents

Description:
Source:
Since:
  • 2.0
Example
Import SkylinkEventManager and SkylinkConstants from 'skylinkjs'

Example 1: Adding a listener
SkylinkEventManager.addEventListener(SkylinkConstants.EVENTS.ON_INCOMING_STREAM, evt => {
  const { detail } = evt;
  // do something
});

Example 2: Removing a listener
SkylinkEventManager.removeEventListener(SkylinkConstants.EVENTS.ON_INCOMING_STREAM, evt => {
  const { detail } = evt;
  // do something
});

Events

CANDIDATES_GATHERED

Description:
  • Event triggered when all remote ICE candidates gathering has completed and been processed.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
room roomInfo

The current room

peerId String

The peer's id

candidatesLength Object

The remote ICE candidates length.

Properties
Name Type Description
expected number

The expected total number of remote ICE candidates to be received.

received number

The actual total number of remote ICE candidates received.

processed number

The total number of remote ICE candidates processed.

CANDIDATE_GENERATION_STATE

Description:
  • Event triggered when a Peer connection ICE gathering state has changed.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
room roomInfo

The current room

peerId String

The peer's id

state SkylinkConstants.CANDIDATE_GENERATION_STATE

The current Peer connection ICE gathering state.

CANDIDATE_PROCESSING_STATE

Description:
  • Event triggered when remote ICE candidate processing state has changed when Peer is using trickle ICE.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
room roomInfo

The current room

peerId String

The peer's id

state SkylinkConstants.CANDIDATE_PROCESSING_STATE

The ICE candidate processing state.

candidateId String

The remote ICE candidate session ID.

candidateType String

The remote ICE candidate type.

candidate Object

The remote ICE candidate.

Properties
Name Type Description
candidate String

The remote ICE candidate connection description.

sdpMid- String

The remote ICE candidate identifier based on the remote session description.

sdpMLineIndex number

The remote ICE candidate media description index (starting from 0) based on the remote session description.

error Error

The error object.

CHANNEL_CLOSE

Description:
  • Event triggered when socket connection to Signaling server has closed.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
session socketSession

The socket connection session information.

peerId string

The Peer ID.

CHANNEL_ERROR

Description:
  • This may be caused by Javascript errors in the event listener when subscribing to events.
    It may be resolved by checking for code errors in your Web App in the event subscribing listener.
    Event triggered when socket connection encountered exception.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
error Error | String

The error object.

session socketSession

The socket connection session information.

peerId string

The Peer ID.

CHANNEL_MESSAGE

Description:
  • Note that this is used only for SDK developer purposes. Event triggered when receiving socket message from the Signaling server.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
message Object

The socket message object.

session socketSession

The socket connection session information.

CHANNEL_OPEN

Description:
  • Event triggered when socket connection to Signaling server has opened.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
session socketSession

The socket connection session information.

peerId string

The Peer ID.

CHANNEL_REOPEN

Description:
  • [DEPRECATED] Event triggered when socket connection to Signaling server has re-opened.

    This event has been replaced with SESSION_DISCONNECT. Implementation of reconnecting back to a room remains the same.
Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
session socketSession

The socket connection session information.

CHANNEL_RETRY

Description:
  • [DEPRECATED] Event triggered when attempting to establish socket connection to Signaling server when failed.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
fallbackType SkylinkConstants.SOCKET_FALLBACK

The current fallback state.

currentAttempt Number

The current socket reconnection attempt.

session socketSession

The socket connection session information.

DATA_CHANNEL_STATE

Description:
  • Event triggered when a Datachannel connection state has changed.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
room roomInfo

The current room

peerId String

The peer's id

state SkylinkConstants.DATA_CHANNEL_STATE

The current Datachannel connection state.

error Error

The error object. Defined only when state payload is ERROR or SEND_MESSAGE_ERROR.

channelName String

The Datachannel ID.

channelType SkylinkConstants.DATA_CHANNEL_TYPE

The Datachannel type.

messageType SkylinkConstants.DATA_CHANNEL_MESSAGE_ERROR

The Datachannel sending Datachannel message error type. Defined only when state payload is SEND_MESSAGE_ERROR.

bufferAmount Object

The Datachannel - buffered amount information.

Properties
Name Type Description
bufferedAmount number

The size of currently queued data to send on the Datachannel connection.

bufferedAmountLowThreshold number

Threshold The current buffered amount low threshold configured.

DATA_TRANSFER_STATE

Description:
  • Event triggered when a data transfer state has changed.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
state SkylinkConstants.DATA_TRANSFER_STATE

The current data transfer state.

transferId String

The data transfer ID. Note that this is defined as null when the transfers fails to start.

peerId String

The Peer ID.

transferInfo transferInfo

The data transfer information.

error Object

The error object.

Properties
Name Type Description
message Error | String

The error message.

transferType SkylinkConstants.DATA_TRANSFER_DIRECTION

The data transfer direction from where the error occurred.

ENCRYPT_SECRETS_UPDATED

Description:
  • Event triggered when encrypt secret data is updated.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
room roomInfo

The current room

encryptSecrets Object

The secretId and secret pair.

selectedSecretId String

The id of the secret that is used for encryption and decryption of messages. If value is an empty string, message will not be encrypted.

peerId String

The Peer ID.

peerInfo peerInfo

The Peer session information. Object signature matches the peerInfo parameter payload received in the PEER JOINED event.

GET_CONNECTION_STATUS_STATE_CHANGE

Description:
Source:
Parameters:
Name Type Description
detail Object

Event's payload/

Properties
Name Type Attributes Description
state SkylinkConstants.GET_CONNECTION_STATUS_STATE

The current retrieval state from getConnectionStatus method.

peerId String

The Peer ID.

stats statistics <optional>

The Peer connection current stats.

error Error

The error object. Defined only when state payload is RETRIEVE_ERROR.

GET_PEERS_STATE_CHANGE

Description:
  • Event triggered when getPeers method retrieval state changes.

Source:
Parameters:
Name Type Description
detail Object

Event's payload

Properties
Name Type Description
state SkylinkConstants.GET_PEERS_STATE

The current getPeers retrieval state.

privilegePeerId SkylinkUser.sid

The Users privileged Peer Id.

peerList Object

The list of Peer IDs Rooms within the same App space.

Properties
Name Type Description
#room Array

The list of Peer IDs associated with the Room defined in #room property.

HANDSHAKE_PROGRESS

Description:
  • Event triggered when a Peer connection establishment state has changed.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Attributes Description
state SkylinkConstants.HANDSHAKE_PROGRESS

The current Peer connection establishment state.

peerId String

The Peer ID.

room roomInfo

The room.

error Error | String <optional>

The error object. Defined only when state is ERROR.

ICE_CONNECTION_STATE

Description:
  • Learn more about how ICE works in this article here. Event triggered when a Peer connection ICE connection state has changed.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
state SkylinkConstants.ICE_CONNECTION_STATE

The current Peer connection ICE connection state.

state String

The Peer ID.

LOCAL_MEDIA_MUTED

Description:
  • Event triggered when muteStreams method changes User Streams audio and video tracks muted status.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
streamId String

The muted Stream Id.

isScreensharing Boolean

The flag if the media muted was screensharing.

mediaStatus JSON

The Peer streaming media status. This indicates the media status for both getUserMedia Stream and shareScreen Stream.

Properties
Name Type Description
audioMuted Boolean

The value of the audio status. If Peer mediaStatus is -1, audio is not present in the stream. If Peer mediaStatus is 1, audio is present in the stream and active (not muted). If Peer mediaStatus is 0, audio is present in the stream and muted.

videoMuted Boolean

The value of the video status. If Peer mediaStatus is -1, video is not present in the stream. If Peer mediaStatus is 1, video is present in the stream and active (not muted). If Peer mediaStatus is 0, video is present in the stream and muted.

MEDIA_ACCESS_ERROR

Description:
  • Event triggered when retrieval of Stream failed.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
error Error | String

The error object.

isScreensharing Boolean

The flag if event occurred during shareScreen method and not getUserMedia method.

isAudioFallbackError Boolean

The flag if event occurred during retrieval of audio tracks only when getUserMedia method had failed to retrieve both audio and video tracks.

MEDIA_ACCESS_FALLBACK

Description:
  • Event triggered when Stream retrieval fallback state has changed.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
error JSON

The error result.

Properties
Name Type Description
error String

The error object.

diff JSON

The list of excepted but received audio and video tracks in Stream. Defined only when state payload is FALLBACKED.

video JSON

The expected and received video tracks.

Properties
Name Type Description
expected Number

The expected video tracks.

received Number

The received video tracks.

audio JSON

The expected and received audio tracks.

Properties
Name Type Description
expected Number

The expected audio tracks.

received Number

The received audio tracks.

state SkylinkConstants.MEDIA_ACCESS_FALLBACK_STATE

The fallback state.

isScreensharing boolean

The flag if event occurred during shareScreen method and not getUserMedia method.

isAudioFallback boolean

The flag if event occurred during retrieval of audio tracks only when getUserMedia method failed to retrieve both audio and video tracks.

streamId String

The Stream ID. Defined only when state payload is FALLBACKED.

MEDIA_ACCESS_REQUIRED

Description:
  • Event triggered when retrieval of Stream is required to complete joinRoom method request.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

MEDIA_ACCESS_STOPPED

Description:
  • Event triggered when Stream has stopped streaming.

Source:
Parameters:
Name Type Description
detail.isScreensharing Object

The flag if event occurred during shareScreen method and not jgetUserMedia method.

detail.isAudioFallback boolean

The flag if event occurred during retrieval of audio tracks only when jgetUserMedia method had failed to retrieve both audio and video tracks.

detail.streamId String

The Stream ID.

MEDIA_ACCESS_SUCCESS

Description:
  • Event triggered when retrieval of Stream is successful.

Source:
Parameters:
Name Type Description
detail Object
Properties
Name Type Description
stream MediaStream

The Stream object. To attach it to an element: attachMediaStream(videoElement, stream);.

isScreensharing Boolean

The flag if event occurred during shareScreen method and not getUserMedia method.

isAudioFallback Boolean

The flag if event occurred during retrieval of audio tracks only when getUserMedia method had failed to retrieve both audio and video tracks.

streamId String

The Stream ID.

isVideo boolean

The flag if the incoming stream has a video track.

isAudio boolean

The flag if the incoming stream has an audio track.

ON_INCOMING_DATA

Description:
  • Event triggered when receiving completed data transfer from Peer.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
data Blob | String

The data.

transferId String

The data transfer ID.

peerId String

The Peer ID.

transferInfo transferInfo

The data transfer information. Object signature matches the transferInfo parameter payload received in the DATA TRANSFER STATE except without the data property.

isSelf Boolean

The flag if Peer is User.

ON_INCOMING_MESSAGE

Description:
  • Event triggered when receiving message from Peer.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
room roomInfo

The current room

message JSON

The message result.

Properties
Name Type Attributes Description
content JSON | string

The message.

senderPeerId String

The sender Peer ID.

targetPeerId String | Array <optional>

The value of the targetPeerId defined in Skylink#sendP2PMessage or sendMessage. Defined as User's Peer ID when isSelf payload value is false. Defined as null when provided targetPeerId in sendP2PMessage or sendMessage is not defined.

listOfPeers Array <optional>

The list of Peers that the message has been sent to. Defined only when isSelf payload value is true.

isPrivate boolean

The flag if message is targeted or not, basing off the targetPeerId parameter being defined in sendP2PMessage or sendMessage.

isDataChannel boolean

The flag if message is sent from sendP2PMessage.

timeStamp String

The time stamp when the message was sent.

peerId String

The Peer ID.

peerInfo peerInfo

The Peer session information. Object signature matches the peerInfo parameter payload received in the PEER JOINED event.

isSelf boolean

The flag if Peer is User.

ON_INCOMING_SCREEN_STREAM

Description:
  • Event triggered when receiving Peer Screenshare Stream.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
room roomInfo

The current room.

peerId String

The peer's id.

stream MediaStream

The Stream object.

streamId String

The Stream id.

isSelf Boolean

The flag if Peer is User.

peerInfo peerInfo

The Peer session information.

isVideo boolean

The flag if the incoming screen stream has a video track.

isAudio boolean

The flag if the incoming screen stream has an audio track.

ON_INCOMING_STREAM

Description:
  • Event triggered when receiving Peer Stream.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
room roomInfo

The current room

peerId String

The peer's id

stream MediaStream

The Stream object. To attach it to an element: attachMediaStream(videoElement, stream);.

streamId String

The stream id.

isSelf boolean

The flag if Peer is User.

peerInfo peerInfo

The Peer session information.

isVideo boolean

The flag if the incoming stream has a video track.

isAudio boolean

The flag if the incoming stream has an audio track.

PEER_CONNECTION_STATE

Description:
  • Event triggered when a Peer connection session description exchanging state has changed.

    Learn more about how ICE works in this article here.
Source:
Parameters:
Name Type Description
detail Object

Event's payload

Properties
Name Type Description
state SkylinkConstants.PEER_CONNECTION_STATE

The current Peer connection session description exchanging states.

peerId String

The Peer ID

PEER_JOINED

Description:
  • Event triggered when a Peer joins the room.

    PEER_JOINED event with isSelf=true indicates that the local peer has successfully joined the room. All call actions should be done after the PEER_JOINED event is registered. If MCU feature is enabled on the appKey, SERVER PEER JOINED is the corresponding event.
Source:
Parameters:
Name Type Description
detail Object

Event's payload

Properties
Name Type Description
room roomInfo

The current room.

peerId String

The Peer ID.

peerInfo peerInfo

The Peer session information.

isSelf boolean

The flag if Peer is User.

PEER_LEFT

Description:
  • Event triggered when a Peer leaves the room.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
peerId String

The Peer ID.

peerInfo peerInfo

The Peer session information. Object signature matches the peerInfo parameter payload received in thepeerJoined event.

isSelf boolean

The flag if Peer is User.

room roomInfo

The room.

PEER_UPDATED

Description:
  • Event triggered when a Peer session information has been updated.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
room roomInfo

The current room

peerId String

The peer's id

isSelf boolean

The flag if Peer is User.

peerInfo peerInfo

The Peer session information. Object signature matches the peerInfo parameter payload received in the PEER JOINED event.

PERSISTENT_MESSAGE_STATE

Description:
  • Event triggered when persistent message state changes.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
room roomInfo

The current room

isPersistent Object

The flag if messages should be persistent.

peerId String

The Peer ID.

peerInfo peerInfo

The Peer session information. Object signature matches the peerInfo parameter payload received in the PEER JOINED event.

READY_STATE_CHANGE

Description:
  • Event triggered when init() method ready state changes.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
readyState SkylinkConstants.READY_STATE_CHANGE

The current ready state when instantiating new Skylink().

error JSON

The error result. Defined only when state is ERROR.

Properties
Name Type Description
status Number

The HTTP status code when failed.

errorCode SkylinkConstants.READY_STATE_CHANGE_ERROR

The ready state change failure code.

content Error

The error object.

room String

The Room to The Room to retrieve session token for.

RECORDING_STATE

Description:
  • Event triggered when recording session state has changed.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
state SkylinkConstants.RECORDING_STATE

The current recording session state.

recordingId String

The recording session ID.

error Error | String

The error object. Defined only when state payload is ERROR.

ROOM_LOCK

Description:
  • Event triggered when Room locked status has changed.

Source:
Parameters:
Name Type Description
detail Object

Event's payload

Properties
Name Type Description
isLocked Boolean

The flag if Room is locked.

peerId String

The Peer ID.

peerInfo peerInfo

The Peer session information. Object signature matches the peerInfo parameter payload received in the PEER JOINED event.

isSelf Boolean

The flag if User changed the Room locked status.

room roomInfo

The room.

ROOM_REJOIN

Description:
  • Event triggered when joinRoom can be re-initiated. This event is preceded by leaveRoom initiated by the SDK in response to peer connection changing to FAILED state.

Source:
Parameters:
Name Type Description
detail Object

Event's payload

Properties
Name Type Description
room roomInfo

The previous room

peerId String

The previous peer id

Returns:
Type
SkylinkEvent

RTMP_STATE

Description:
  • Event triggered when rtmp session state has changed.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
state SkylinkConstants.RTMP_STATE

The current recording session state.

rtmpId String

The rtmp session ID.

error Error | String

The error object. Defined only when state payload is ERROR.

SERVER_PEER_JOINED

Description:
  • Event triggered when a server Peer joins the room.

    • SERVER_PEER_JOINED event indicates that the MCU has successfully joined the

    room. All call actions should be done after the SERVER_PEER_JOINED event is registered. For P2P key, PEER JOINED is the corresponding event.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
room roomInfo

The current room

peerId String

The peer's id

serverPeerType SkylinkConstants.PEER_TYPE

The server Peer type

SERVER_PEER_LEFT

Description:
  • Event triggered when a server Peer leaves the room.

    • Handling an MCU disconnect using the serverPeerLeft event - Reconnection
Source:
Parameters:
Name Type Description
detail Object

Event's payload

Properties
Name Type Description
peerId String

The Peer ID

room roomInfo

The room.

serverPeerType SkylinkConstants.PEER_TYPE

The server Peer type

SESSION_DISCONNECT

Description:
  • Event triggered when Room session has ended abruptly due to network disconnections.

    • Handling a socket disconnect using the sessionDisconnect event - Reconnection
Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
peerId String

The User's Room session Peer ID

peerInfo peerInfo

The User's Room session information. Object signature matches the peerInfo parameter payload received in the PEER JOINED event.

reason peerInfo

Reason for the disconnect

SOCKET_ERROR

Description:
  • Event triggered when attempt to establish socket connection to Signaling server has failed.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
errorCode SkylinkConstants.SOCKET_ERROR

The socket connection error code.

error Error | String | Number

The error object.

type SkylinkConstants.SOCKET_FALLBACK

The fallback state of the socket connection attempt.

session socketSession

The socket connection session information.

STORED_MESSAGES

Description:
  • Event triggered when receiving stored messages from the Signaling Server.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
room roomInfo

The current room

storedMessages Array

The stored messages result.

Properties
Name Type Description
targetPeerId String

The value of the targetPeerId defined in sendP2PMessage or sendMessage. Defined as User's Peer ID when isSelf payload value is false. Defined as null when provided targetPeerId in sendP2PMessage or sendMessage is not defined.

senderPeerId JSON | String

The sender Peer ID.

content JSON | String

The message.

timeStamp JSON | String

The timestamp when the message was sent, in simplified extended ISO format.

isPrivate boolean

The flag if message is targeted or not, basing off the targetPeerId parameter being defined in sendP2PMessage or sendMessage. Value will always be false for stored messages.

isDataChannel boolean

The flag if message is sent from sendP2PMessage. Value will always be true for stored messages.

peerId String

The Peer ID.

peerInfo peerInfo

The Peer session information. Object signature matches the peerInfo parameter payload received in the PEER JOINED event.

isSelf boolean

The flag if Peer is User.

STREAM_ENDED

Description:
  • Event triggered when a Peer Stream streaming has stopped. Note that it may not be the currently sent Stream to User, and it also triggers when User leaves the Room for any currently sent Stream to User from Peer.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
peerId String

The Peer ID.

room roomInfo

The room.

peerInfo peerInfo

The Peer session information. Object signature matches the peerInfo parameter payload received in the PEER JOINED event.

isSelf Boolean

The flag if Peer is User.

isScreensharing Boolean

The flag if Peer Stream is a screensharing Stream.

streamId String

The Stream ID.

isVideo boolean

The flag if the ended stream has a video track.

isAudio boolean

The flag if the ended stream has an audio track.

STREAM_MUTED

Description:
  • Event triggered when Peer Stream audio or video tracks has been muted / unmuted.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
peerId String

The Peer ID.

peerInfo peerInfo

The Peer session information. Object signature matches the peerInfo parameter payload received in the PEER JOINED event.

isSelf Boolean

The flag if Peer is User.

isVideo boolean

The flag if the muted stream has a video track.

isAudio boolean

The flag if the muted stream has an audio track.

isScreensharing boolean

The flag if the muted stream is a screensharing stream.

SYSTEM_ACTION

Description:
  • Event triggered when Signaling server reaction state has changed.

Source:
Parameters:
Name Type Description
detail Object

Event's payload.

Properties
Name Type Description
action SkylinkConstants.SYSTEM_ACTION

The current Signaling server reaction state.

message String

The message.

reason SkylinkConstants.SYSTEM_ACTION_REASON

The Signaling server reaction state reason of action code.