Skylink Class
Defined in: source/template/header.js:51
Available since 0.5.0
Prerequisites on using Skylink
Before using any Skylink functionalities, you will need to authenticate your App Key using theinit()
method.
To manage or create App Keys, you may access the Temasys Console here.
To view the list of supported browsers, visit the list here.
Here are some articles to help you get started:
Here are some demos you may use to aid your development:
- Getaroom.io [Demo / Source code]
- Creating a component [Link]
You may see the example below in the Constructor tab to have a general idea how event subscription
and the ordering of init()
and
joinRoom()
methods should be called.
If you have any issues, you may find answers to your questions in the FAQ section on our support portal, asks questions, request features or raise bug tickets as well.
If you would like to contribute to our Temasys Web SDK codebase, see the contributing README.
Skylink
()
Example:
// Here's a simple example on how you can start using Skylink. var skylinkDemo = new Skylink();
// Subscribe all events first as a general guideline skylinkDemo.on("incomingStream", function (peerId, stream, peerInfo, isSelf) { if (isSelf) { attachMediaStream(document.getElementById("selfVideo"), stream); } else { var peerVideo = document.createElement("video"); peerVideo.id = peerId; peerVideo.autoplay = "autoplay"; document.getElementById("peersVideo").appendChild(peerVideo); attachMediaStream(peerVideo, stream); } });
skylinkDemo.on("peerLeft", function (peerId, peerInfo, isSelf) { if (!isSelf) { var peerVideo = document.getElementById(peerId); // do a check if peerVideo exists first if (peerVideo) { document.getElementById("peersVideo").removeChild(peerVideo); } else { console.error("Peer video for " + peerId + " is not found."); } } });
// init() should always be called first before other methods other than event methods like on() or off(). skylinkDemo.init("YOUR_APP_KEY_HERE", function (error, success) { if (success) { skylinkDemo.joinRoom("my_room", { userData: "My Username", audio: true, video: true }); } });
Events Sequence:
There is no event sequence for this method._acknowledgeAnswer
()
Function that sends a SIG_MESSAGE_TYPE.ANSWER_ACK message to MCU to denote that SDP negotiation has completed (either with success or error)
Events Sequence:
There is no event sequence for this method._ACKProtocolHandler
()
Function that handles the "ACK" data transfer protocol.
Events Sequence:
There is no event sequence for this method._addIceCandidate
()
Function that adds the ICE candidate to Peer connection.
Events Sequence:
There is no event sequence for this method._addIceCandidateFromQueue
()
Function that adds all the Peer connection buffered ICE candidates received. This should be called only after the remote session description is received and set.
Events Sequence:
There is no event sequence for this method._addIceCandidateToQueue
()
Function that buffers the Peer connection ICE candidate when received before remote session description is received and set.
Events Sequence:
There is no event sequence for this method._addLocalMediaStreams
()
Function that sets User's Stream to send to Peer connection.
Priority for shareScreen()
Stream over getUserMedia()
Stream.
Events Sequence:
There is no event sequence for this method._addPeer
()
Function that starts the Peer connection session. Remember to remove previous method of reconnection (re-creating the Peer connection - destroy and create connection).
Events Sequence:
There is no event sequence for this method._answerHandler
()
Function that handles the "answer" socket message received.
See confluence docs for the "answer" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._approachEventHandler
()
Function that handles the "approach" socket message received.
See confluence docs for the "approach" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._base64ToBlob
()
Function that converts Base64 string into Blob object. This is referenced from<EMAIL_ADDRESS>#6850276.
Events Sequence:
There is no event sequence for this method._blobToArrayBuffer
()
Function that converts a Blob object into ArrayBuffer object.
Events Sequence:
There is no event sequence for this method._blobToBase64
()
Function that converts a Blob object into Base64 string.
Events Sequence:
There is no event sequence for this method._byeHandler
()
Function that handles the "bye" socket message received.
See confluence docs for the "bye" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._CANCELProtocolHandler
()
Function that handles the "CANCEL" data transfer protocol.
Events Sequence:
There is no event sequence for this method._candidateHandler
()
Function that handles the "candidate" socket message received.
See confluence docs for the "candidate" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._chunkBlobData
()
Function that chunks Blob object based on the data chunk size provided.
If provided Blob object size is lesser than or equals to the chunk size, it should return an array
of length of 1
.
Events Sequence:
There is no event sequence for this method._chunkDataURL
()
Function that chunks large string into string chunks based on the data chunk size provided.
If provided string length is lesser than or equals to the chunk size, it should return an array
of length of 1
.
Events Sequence:
There is no event sequence for this method._clearAllStoredLogsFn
()
Function that clears the stored logs.
Events Sequence:
There is no event sequence for this method._closeChannel
()
Function that stops the socket connection to the Signaling.
Events Sequence:
There is no event sequence for this method._closeDataChannel
()
Function that stops the Datachannel connection and removes object references.
Events Sequence:
There is no event sequence for this method._compareTrackCounts
targetMid
,
)
Function that compares trackCount sent by MCU and decides wether to add new Transceivers based on count differences
Events Sequence:
There is no event sequence for this method.Parameters:
-
targetMid
{String}
_condition
()
Function that checks if the current state condition is met before subscribing event handler to wait for condition to be fulfilled.
Events Sequence:
There is no event sequence for this method._containsInList
()
Function that checks if value is contained in a SDK constant.
Events Sequence:
There is no event sequence for this method._createDataChannel
()
Function that starts a Datachannel connection with Peer.
Events Sequence:
There is no event sequence for this method._createPeerConnection
()
Function that creates the Peer connection.
Events Sequence:
There is no event sequence for this method._createSocket
()
Function that creates and opens a socket connection to the Signaling.
Events Sequence:
There is no event sequence for this method._DATAProtocolHandler
()
Function that handles the data transfer chunk received.
Events Sequence:
There is no event sequence for this method._doAnswer
()
Function that creates the Peer connection answer session description. This comes after receiving and setting the offer session description.
Events Sequence:
There is no event sequence for this method._doOffer
()
Function that creates the Peer connection offer session description.
Events Sequence:
There is no event sequence for this method._endOfCandidatesHandler
()
Function that handles the "endOfCandidates" socket message received.
See confluence docs for the "endOfCandidates" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._enterHandler
()
Function that handles the "enter" socket message received.
See confluence docs for the "enter" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._ERRORProtocolHandler
()
Function that handles the "ERROR" data transfer protocol.
Events Sequence:
There is no event sequence for this method._getCodecsSupport
()
Function that retrieves the current list of support codecs.
Events Sequence:
There is no event sequence for this method._getDataChannelBuffer
()
Function that returns the Datachannel buffer threshold and amount.
Events Sequence:
There is no event sequence for this method.Returns:
The buffered amount information.
_getPeerCustomSettings
()
Function that returns the Peer custom settings.
Events Sequence:
There is no event sequence for this method._getSDPCodecsSupport
()
Function that parses the current list of supported codecs from session description.
Events Sequence:
There is no event sequence for this method._getSDPCommonSupports
()
Function that checks if there are any common codecs supported for remote end.
Events Sequence:
There is no event sequence for this method._getSDPFingerprint
()
Function that parses and retrieves the session description fingerprint.
Events Sequence:
There is no event sequence for this method._getSDPICECandidates
()
Function that parses and retrieves the session description ICE candidates.
Events Sequence:
There is no event sequence for this method._getSDPMediaSSRC
()
Function that gets each media line SSRCs.
Events Sequence:
There is no event sequence for this method._getSDPSelectedCodec
()
Function that retrieves the session description selected codec.
Events Sequence:
There is no event sequence for this method._getStoredLogsFn
()
Function that gets the stored logs.
Events Sequence:
There is no event sequence for this method._getTransferData
()
Function that returns the compiled data transfer data.
Events Sequence:
There is no event sequence for this method._getTransferInfo
()
Function that returns the data transfer session.
Events Sequence:
There is no event sequence for this method._getUserInfo
()
Function that returns the User session information to be sent to Peers.
Events Sequence:
There is no event sequence for this method._handleAuthStats
()
Function that handles the posting of app key authentication states.
Events Sequence:
There is no event sequence for this method._handleBandwidthStats
()
Function that handles the posting of peer connection bandwidth information.
Events Sequence:
There is no event sequence for this method._handleClientStats
()
Function that handles the posting of client information.
Events Sequence:
There is no event sequence for this method._handleDatachannelStats
()
Function that handles buffer of stats data
Events Sequence:
There is no event sequence for this method._handleDatachannelStats
()
Function that handles the posting of datachannel states.
Events Sequence:
There is no event sequence for this method._handleDataTransferTimeoutForPeer
()
Function that handles the data transfers sessions timeouts.
Events Sequence:
There is no event sequence for this method._handleEndedStreams
()
Function that handles ended streams.
Events Sequence:
There is no event sequence for this method._handleIceCandidateStats
()
Function that handles the posting of peer local/remote ICE candidate processing states.
Events Sequence:
There is no event sequence for this method._handleIceConnectionStats
()
Function that handles the posting of peer ICE connection states.
Events Sequence:
There is no event sequence for this method._handleIceGatheringStats
()
Function that handles the posting of peer local/remote ICE gathering states.
Events Sequence:
There is no event sequence for this method._handleNegotiationStats
()
Function that handles the posting of peer connection negotiation states.
Events Sequence:
There is no event sequence for this method._handleRecordingStats
()
Function that handles the posting of recording states.
Events Sequence:
There is no event sequence for this method._handleSDPConnectionSettings
()
Function that modifies the session description to handle the connection settings. This is experimental and never recommended to end-users.
Events Sequence:
There is no event sequence for this method._handleSessionStats
()
Function that handles the posting of session states.
Events Sequence:
There is no event sequence for this method._handleSignalingStats
()
Function that handles the posting of socket connection states.
Events Sequence:
There is no event sequence for this method._initSelectedRoom
()
Starts initialising for Room credentials for room name provided in joinRoom()
method.
Events Sequence:
There is no event sequence for this method._inRoomHandler
()
Function that handles the "inRoom" socket message received.
See confluence docs for the "inRoom" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._introduceErrorEventHandler
()
Function that handles the "introduceError" socket message received.
See confluence docs for the "introduceError" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._isLowerThanVersion
()
Function that compares the SM / DT protocol versions to see if it in the version.
Events Sequence:
There is no event sequence for this method._loadInfo
()
Loads and checks the dependencies if they are loaded correctly.
Events Sequence:
There is no event sequence for this method._logFn
()
Function that handles the logs received and prints in the Web Console interface according to the log level set.
Events Sequence:
There is no event sequence for this method._MESSAGEProtocolHandler
()
Function that handles the "MESSAGE" data transfer protocol.
Events Sequence:
There is no event sequence for this method._modifyDTLSRole
()
Function that modifies the DTLS role in answer sdp This needs to be done until https://bugzilla.mozilla.org/show_bug.cgi?id=1240897 is released in Firefox 68 Estimated release date for Firefox 68 : 2019-07-09 (https://wiki.mozilla.org/Release_Management/Calendar)
Events Sequence:
There is no event sequence for this method._muteAudioEventHandler
()
Function that handles the "muteAudioEvent" socket message received.
See confluence docs for the "muteAudioEvent" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._muteStreams
()
Function that handles the muting of Stream audio and video tracks.
Events Sequence:
There is no event sequence for this method._muteVideoEventHandler
()
Function that handles the "muteVideoEvent" socket message received.
See confluence docs for the "muteVideoEvent" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._offerHandler
()
Function that handles the "offer" socket message received.
See confluence docs for the "offer" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._onIceCandidate
()
Function that handles the Peer connection gathered ICE candidate to be sent.
Events Sequence:
There is no event sequence for this method._onRemoteStreamAdded
()
Function that handles the RTCPeerConnection.onaddstream
remote MediaStream received.
Events Sequence:
There is no event sequence for this method._onStreamAccessError
()
Function that handles the native navigator.getUserMedia()
API failure callback result.
Events Sequence:
There is no event sequence for this method._onStreamAccessSuccess
()
Function that handles the native navigator.getUserMedia()
API success callback result.
Events Sequence:
There is no event sequence for this method._openChannel
()
Function that starts the socket connection to the Signaling. This starts creating the socket connection and called at first not when requiring to fallback.
Events Sequence:
There is no event sequence for this method._parseConnectionStats
()
Function that handles the stats tabulation.
Events Sequence:
There is no event sequence for this method._parseInfo
()
Parses the Room credentials information retrieved from API server.
Events Sequence:
There is no event sequence for this method._parseSDPMediaStreamIDs
()
Function that parses the session description to get the MediaStream IDs. NOTE: It might not completely accurate if the setRemoteDescription() fails..
Events Sequence:
There is no event sequence for this method._parseStreamSettings
()
Function that parses the getUserMedia()
settings provided.
Events Sequence:
There is no event sequence for this method._parseStreamTracksInfo
()
Function that parses the mediastream tracks for details.
Events Sequence:
There is no event sequence for this method._peerListEventHandler
()
Function that handles the "peerList" socket message received.
See confluence docs for the "peerList" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._postStatsToServer
()
Function that sends the stats to the API server.
Events Sequence:
There is no event sequence for this method._printAllStoredLogsFn
()
Function that prints in the Web Console interface the stored logs.
Events Sequence:
There is no event sequence for this method._privateMessageHandler
()
Function that handles the "private" socket message received.
See confluence docs for the "private" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._processDataChannelData
()
Function that handles the data received from Datachannel and routes to the relevant data transfer protocol handler.
Events Sequence:
There is no event sequence for this method._processSigMessage
()
Function that handles and processes the socket message received.
Events Sequence:
There is no event sequence for this method._publicMessageHandler
()
Function that handles the "public" socket message received.
See confluence docs for the "public" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._recordingEventHandler
message
,
)
Handles the RECORDING Protocol message event received from the platform signaling.
Events Sequence:
There is no event sequence for this method.Parameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
RECORDING
payload.-
url
{String}The recording URL if mixing has completed.
-
action
{String}The recording action received.
-
error
{String}The recording error exception received.
-
_redirectHandler
()
Function that handles the "redirect" socket message received.
See confluence docs for the "redirect" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._refreshPeerConnection
()
Function that refresh connections.
Events Sequence:
There is no event sequence for this method._removePeer
()
Function that ends the Peer connection session.
Events Sequence:
There is no event sequence for this method._removeSDPCodecs
()
Function that modifies the session description to remove codecs.
Events Sequence:
There is no event sequence for this method._removeSDPFilteredCandidates
()
Function that modifies the session description to remove non-relay ICE candidates.
Events Sequence:
There is no event sequence for this method._removeSDPFirefoxH264Pref
()
Function that modifies the session description to remove the previous experimental H264 codec that is apparently breaking connections. NOTE: We should perhaps not remove it since H264 is supported?
Events Sequence:
There is no event sequence for this method._removeSDPREMBPackets
()
Function that modifies the session description to remove REMB packets fb.
Events Sequence:
There is no event sequence for this method._removeSDPUnknownAptRtx
()
Function that modifies the session description to remove apt/rtx lines that does exists.
Events Sequence:
There is no event sequence for this method._renderSDPOutput
()
Function that modifies the session description to append the MediaStream and MediaStreamTrack IDs that seems to be missing from Firefox answer session description to Chrome connection causing freezes in re-negotiation.
Events Sequence:
There is no event sequence for this method._replaceTrack
trackIDToCompare
,
trackToReplace
,
)
Function that iterates the Peer Connections and replaces track using the RTCRTPSender.replaceTrack
Events Sequence:
There is no event sequence for this method.Parameters:
-
trackIDToCompare
{String}- ID of the track whose RTCRTPSenders needs to be used
-
trackToReplace
{MediaStreamTrack}- The new track which will replace the old track
_reportToAPI
()
Function that will send the log to an API endpoint for persistence
Events Sequence:
There is no event sequence for this method._requestServerInfo
()
Starts retrieving Room credentials information from API server.
Events Sequence:
There is no event sequence for this method._restartHandler
()
Function that handles the "restart" socket message received.
See confluence docs for the "restart" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._restartMCUConnection
()
Function that handles the _restartPeerConnection
scenario
for MCU enabled Peer connections.
This is implemented currently by making the user leave and join the Room again.
The Peer ID will not stay the same though.
Events Sequence:
There is no event sequence for this method._restartPeerConnection
()
Function that re-negotiates a Peer connection. Remember to remove previous method of reconnection (re-creating the Peer connection - destroy and create connection).
Events Sequence:
There is no event sequence for this method._retrieveStats
()
Function that retrieves Peer connection stats.
Events Sequence:
There is no event sequence for this method._roomLockEventHandler
()
Function that handles the "roomLockEvent" socket message received.
See confluence docs for the "roomLockEvent" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._rtmpEventHandler
message
,
)
Handles the RTMP Protocol message event received from the platform signaling.
Events Sequence:
There is no event sequence for this method.Parameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
RTMP
payload.-
action
{String}The RTMP action received.
-
error
{String}The RTMP error exception received.
-
_sendChannelMessage
()
Function that sends a socket message over the socket connection to the Signaling.
Events Sequence:
There is no event sequence for this method._sendMessageToDataChannel
()
Function that sends data over the Datachannel connection.
Events Sequence:
There is no event sequence for this method._setClientInfoForLogging
()
Function that binds the SKylink instance to reportAPI instance and returns a new bound function
Events Sequence:
There is no event sequence for this method._setIceServers
()
Function that filters and configures the ICE servers received from Signaling
based on the init()
configuration and returns the updated
list of ICE servers to be used when constructing Peer connection.
Events Sequence:
There is no event sequence for this method._setLocalAndSendMessage
()
Function that sets the local session description and sends to Peer. If trickle ICE is disabled, the local session description will be sent after ICE gathering has been completed.
Events Sequence:
There is no event sequence for this method._setOriginalDTLSRole
()
Function sets the original DTLS role which was negotiated on first offer/ansswer exchange This needs to be done until https://bugzilla.mozilla.org/show_bug.cgi?id=1240897 is released in Firefox 68 Estimated release date for Firefox 68 : 2019-07-09 (https://wiki.mozilla.org/Release_Management/Calendar)
Events Sequence:
There is no event sequence for this method._setSCTPport
()
Function adds SCTP port number for Firefox 63.0.3 and above if its missing in the answer from MCU
Events Sequence:
There is no event sequence for this method._setSDPBitrate
()
Function that modifies the session description to limit the maximum sending bandwidth. Setting this may not necessarily work in Firefox.
Events Sequence:
There is no event sequence for this method._setSDPCodec
()
Function that modifies the session description to set the preferred audio/video codec.
Events Sequence:
There is no event sequence for this method._setSDPCodecParams
()
Function that modifies the session description to configure settings for OPUS audio codec.
Events Sequence:
There is no event sequence for this method._signalingEndOfCandidates
()
Function that signals the end-of-candidates flag.
Events Sequence:
There is no event sequence for this method._startDataTransfer
()
Function that starts the data transfer to Peers.
Events Sequence:
There is no event sequence for this method._startDataTransferToPeer
()
Function that starts or listens the data transfer status to Peer. This reacts differently during MCU environment.
Events Sequence:
There is no event sequence for this method.Returns:
Returns a Boolean only during MCU environment which flag indicates if Peer requires interop (Use messaging Datachannel connection instead).
_stopStreams
()
Function that handles stopping the Stream streaming.
Events Sequence:
There is no event sequence for this method._streamEventHandler
()
Function that handles the "stream" socket message received.
See confluence docs for the "stream" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._throttle
()
Function that throttles a method function to prevent multiple invokes over a specified amount of time.
Returns a function to be invoked ._throttle(fn, 1000)()
to make throttling functionality work.
Events Sequence:
There is no event sequence for this method._trigger
()
Function that triggers an event.
The rest of the parameters after the eventName
parameter is considered as the event parameter payloads.
Events Sequence:
There is no event sequence for this method._updateUserEventHandler
()
Function that handles the "updateUserEvent" socket message received.
See confluence docs for the "updateUserEvent" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._wait
()
Function that starts an interval check to wait for a condition to be resolved.
Events Sequence:
There is no event sequence for this method._waitForOpenChannel
()
Function that waits for Socket connection to Signaling to be opened.
Events Sequence:
There is no event sequence for this method._welcomeHandler
()
Function that handles the "welcome" socket message received.
See confluence docs for the "welcome" expected properties to be received
based on the current SM_PROTOCOL_VERSION
.
Events Sequence:
There is no event sequence for this method._WRQProtocolHandler
()
Function that handles the "WRQ" data transfer protocol.
Events Sequence:
There is no event sequence for this method.acceptDataTransfer
peerId
,
transferId
,
[accept=false]
,
)
Function that accepts or rejects an upload data transfer request from Peer to User.
Example:
// Example 1: Accept Peer upload data transfer request skylinkDemo.on("incomingDataRequest", function (transferId, peerId, transferInfo, isSelf) { if (!isSelf) { skylinkDemo.acceptDataTransfer(peerId, transferId, true); } });
// Example 2: Reject Peer upload data transfer request skylinkDemo.on("incomingDataRequest", function (transferId, peerId, transferInfo, isSelf) { if (!isSelf) { skylinkDemo.acceptDataTransfer(peerId, transferId, false); } });
Events Sequence:
Event sequence followssendBlobData()
method after acceptDataTransfer()
method is invoked.
Parameters:
-
peerId
{String}The Peer ID.
-
transferId
{String}The data transfer ID.
-
accept
{Boolean} OptionalDEFAULT:false
The flag if User accepts the upload data transfer request from Peer.
cancelDataTransfer
peerId
,
transferId
,
)
For MCU enabled Peer connections, the cancel data transfer functionality may differ, as it will result in all Peers related to the data transfer ID to be terminated.Function that terminates a currently uploading / downloading data transfer from / to Peer.
Example:
// Example 1: Cancel Peer data transfer var transferSessions = {};
skylinkDemo.on("dataTransferState", function (state, transferId, peerId) { if ([skylinkDemo.DATA_TRANSFER_STATE.DOWNLOAD_STARTED, skylinkDemo.DATA_TRANSFER_STATE.UPLOAD_STARTED].indexOf(state) > -1) { if (!Array.isArray(transferSessions[transferId])) { transferSessions[transferId] = []; } transferSessions[transferId].push(peerId); } else { transferSessions[transferId].splice(transferSessions[transferId].indexOf(peerId), 1); } });
function cancelTransfer (peerId, transferId) { skylinkDemo.cancelDataTransfer(peerId, transferId); }
Events Sequence:
Event sequence followssendBlobData()
method after cancelDataTransfer()
method is invoked.
Parameters:
-
peerId
{String}The Peer ID.
-
transferId
{String}The data transfer ID.
disableAudio
()
Deprecation Warning!
This method has been deprecated. Use muteStream()
method instead.
Function that mutes both getUserMedia()
Stream and
shareScreen()
Stream audio tracks.
Example:
function muteAudio () { skylinkDemo.disableAudio(); }
Events Sequence:
- Invokes
muteStream()
method withoptions.audioMuted
value astrue
andoptions.videoMuted
value with currentpeerInfo.mediaStatus.videoMuted
value. SeegetPeerInfo()
method for more information.
disableVideo
()
Deprecation Warning!
This method has been deprecated. Use muteStream()
method instead.
Function that mutes both getUserMedia()
Stream and
shareScreen()
Stream video tracks.
Example:
function muteVideo () { skylinkDemo.disableVideo(); }
Events Sequence:
- Invokes
muteStream()
method withoptions.videoMuted
value astrue
andoptions.audioMuted
value with currentpeerInfo.mediaStatus.audioMuted
value. SeegetPeerInfo()
method for more information.
enableAudio
()
Deprecation Warning!
This method has been deprecated. Use muteStream()
method instead.
Function that unmutes both getUserMedia()
Stream and
shareScreen()
Stream audio tracks.
Example:
function unmuteAudio () { skylinkDemo.enableAudio(); }
Events Sequence:
- Invokes
muteStream()
method withoptions.audioMuted
value asfalse
andoptions.videoMuted
value with currentpeerInfo.mediaStatus.videoMuted
value. SeegetPeerInfo()
method for more information.
enableVideo
()
Deprecation Warning!
This method has been deprecated. Use muteStream()
method instead.
Function that unmutes both getUserMedia()
Stream and
shareScreen()
Stream video tracks.
Example:
function unmuteVideo () { skylinkDemo.enableVideo(); }
Events Sequence:
- Invokes
muteStream()
method withoptions.videoMuted
value asfalse
andoptions.audioMuted
value with currentpeerInfo.mediaStatus.audioMuted
value. SeegetPeerInfo()
method for more information.
generateUUID
()
Function that generates an UUID (Unique ID).
Events Sequence:
There is no event sequence for this method.Returns:
Returns a generated UUID (Unique ID).
getConnectionStatus
[targetPeerId]
,
[callback]
,
)
Note that this is not well supported in the Edge browser.Function that retrieves Peer connection bandwidth and ICE connection stats.
Example:
// Example 1: Retrieve a Peer connection stats function startBWStatsInterval (peerId) { setInterval(function () { skylinkDemo.getConnectionStatus(peerId, function (error, success) { if (error) return; var sendVideoBytes = success.connectionStats[peerId].video.sending.bytes; var sendAudioBytes = success.connectionStats[peerId].audio.sending.bytes; var recvVideoBytes = success.connectionStats[peerId].video.receiving.bytes; var recvAudioBytes = success.connectionStats[peerId].audio.receiving.bytes; var localCandidate = success.connectionStats[peerId].selectedCandidate.local; var remoteCandidate = success.connectionStats[peerId].selectedCandidate.remote; console.log("Sending audio (" + sendAudioBytes + "bps) video (" + sendVideoBytes + ")"); console.log("Receiving audio (" + recvAudioBytes + "bps) video (" + recvVideoBytes + ")"); console.log("Local candidate: " + localCandidate.ipAddress + ":" + localCandidate.portNumber + "?transport=" + localCandidate.transport + " (type: " + localCandidate.candidateType + ")"); console.log("Remote candidate: " + remoteCandidate.ipAddress + ":" + remoteCandidate.portNumber + "?transport=" + remoteCandidate.transport + " (type: " + remoteCandidate.candidateType + ")"); }); }, 1000); }
// Example 2: Retrieve a list of Peer connection stats function printConnStats (peerId, data) { if (!data.connectionStats[peerId]) return; var sendVideoBytes = data.connectionStats[peerId].video.sending.bytes; var sendAudioBytes = data.connectionStats[peerId].audio.sending.bytes; var recvVideoBytes = data.connectionStats[peerId].video.receiving.bytes; var recvAudioBytes = data.connectionStats[peerId].audio.receiving.bytes; var localCandidate = data.connectionStats[peerId].selectedCandidate.local; var remoteCandidate = data.connectionStats[peerId].selectedCandidate.remote; console.log(peerId + " - Sending audio (" + sendAudioBytes + "bps) video (" + sendVideoBytes + ")"); console.log(peerId + " - Receiving audio (" + recvAudioBytes + "bps) video (" + recvVideoBytes + ")"); console.log(peerId + " - Local candidate: " + localCandidate.ipAddress + ":" + localCandidate.portNumber + "?transport=" + localCandidate.transport + " (type: " + localCandidate.candidateType + ")"); console.log(peerId + " - Remote candidate: " + remoteCandidate.ipAddress + ":" + remoteCandidate.portNumber + "?transport=" + remoteCandidate.transport + " (type: " + remoteCandidate.candidateType + ")"); }
function startBWStatsInterval (peerIdA, peerIdB) { setInterval(function () { skylinkDemo.getConnectionStatus([peerIdA, peerIdB], function (error, success) { if (error) { printConnStats(peerIdA, error.connectionStats); printConnStats(peerIdB, error.connectionStats); } else { printConnStats(peerIdA, success.connectionStats); printConnStats(peerIdB, success.connectionStats); } }); }, 1000); }
// Example 3: Retrieve all Peer connection stats function printConnStats (listOfPeers, data) { listOfPeers.forEach(function (peerId) { if (!data.connectionStats[peerId]) return; var sendVideoBytes = data.connectionStats[peerId].video.sending.bytes; var sendAudioBytes = data.connectionStats[peerId].audio.sending.bytes; var recvVideoBytes = data.connectionStats[peerId].video.receiving.bytes; var recvAudioBytes = data.connectionStats[peerId].audio.receiving.bytes; var localCandidate = data.connectionStats[peerId].selectedCandidate.local; var remoteCandidate = data.connectionStats[peerId].selectedCandidate.remote; console.log(peerId + " - Sending audio (" + sendAudioBytes + "bps) video (" + sendVideoBytes + ")"); console.log(peerId + " - Receiving audio (" + recvAudioBytes + "bps) video (" + recvVideoBytes + ")"); console.log(peerId + " - Local candidate: " + localCandidate.ipAddress + ":" + localCandidate.portNumber + "?transport=" + localCandidate.transport + " (type: " + localCandidate.candidateType + ")"); console.log(peerId + " - Remote candidate: " + remoteCandidate.ipAddress + ":" + remoteCandidate.portNumber + "?transport=" + remoteCandidate.transport + " (type: " + remoteCandidate.candidateType + ")"); }); }
function startBWStatsInterval (peerIdA, peerIdB) { setInterval(function () { skylinkDemo.getConnectionStatus(function (error, success) { if (error) { printConnStats(error.listOfPeers, error.connectionStats); } else { printConnStats(success.listOfPeers, success.connectionStats); } }); }, 1000); }
Events Sequence:
- Retrieves Peer connection stats for all targeted Peers.
- If Peer connection has closed or does not exists: This can be checked with
peerConnectionState
event triggering parameter payloadstate
asCLOSED
for Peer.-
getConnectionStatusStateChange
event triggers parameter payloadstate
asRETRIEVE_ERROR
. - ABORT and return error.
-
getConnectionStatusStateChange
event triggers parameter payloadstate
asRETRIEVING
.- Received response from retrieval.
- If retrieval was successful:
getConnectionStatusStateChange
event triggers parameter payloadstate
asRETRIEVE_SUCCESS
.
- Else:
-
getConnectionStatusStateChange
event triggers parameter payloadstate
asRETRIEVE_ERROR
.
-
- If retrieval was successful:
- If Peer connection has closed or does not exists: This can be checked with
Parameters:
-
targetPeerId
{String | Array} OptionalThe target Peer ID to retrieve connection stats from.
- When provided as an Array, it will retrieve all connection stats from all the Peer IDs provided.
- When not provided, it will retrieve all connection stats from the currently connected Peers in the Room.
-
callback
{Function} OptionalThe callback function fired when request has completed. Function parameters signature is
function (error, success)
Function request completion is determined by thegetConnectionStatusStateChange
event triggeringstate
parameter payload value asRETRIEVE_SUCCESS
for all Peers targeted for request success. [Rel: Skylink.GET_CONNECTION_STATUS_STATE]-
error
{JSON}The error result in request. Defined as
null
when there are no errors in request-
listOfPeers
{Array}The list of Peer IDs targeted. -
retrievalErrors
{JSON}The list of Peer connection stats retrieval errors. -
retrievalErrors.#peerId
{Error | String}The Peer connection stats retrieval error associated with the Peer ID defined in#peerId
property. If#peerId
value is"self"
, it means that it is the error when there are no Peer connections to refresh with. -
connectionStats
{JSON}The list of Peer connection stats. These are the Peer connection stats that has been managed to be successfully retrieved. -
connectionStats.#peerId
{JSON}The Peer connection stats associated with the Peer ID defined in#peerId
property. Object signature matches thestats
parameter payload received in thegetConnectionStatusStateChange
event.
-
-
success
{JSON}The success result in request. Defined as
null
when there are errors in request-
listOfPeers
{Array}The list of Peer IDs targeted. -
connectionStats
{JSON}The list of Peer connection stats. -
connectionStats.#peerId
{JSON}The Peer connection stats associated with the Peer ID defined in#peerId
property. Object signature matches thestats
parameter payload received in thegetConnectionStatusStateChange
event.
-
-
getCurrentDataStreamsSession
()
Function that gets the list of current data streaming sessions.
Example:
// Example 1: Get the list of current data streaming sessions in the same Room var currentDataStreams = skylinkDemo.getCurrentDataStreamsSession();
Events Sequence:
There is no event sequence for this method.Returns:
The list of Peers Stream.
#streamId
{JSON}The data streaming session.
streamInfo
{JSON}The data streaming information. Object signature matches the
streamInfo
parameter payload received in thedataStreamState
event except without thechunk
amdchunkSize
property.peerId
{String}The sender Peer ID.
isSelf
{Boolean}The flag if Peer is User.
getCurrentDataTransfers
()
Function that gets the list of current data transfers.
Example:
// Example 1: Get the list of current data transfers in the same Room var currentTransfers = skylinkDemo.getCurrentDataTransfers();
Events Sequence:
There is no event sequence for this method.Returns:
The list of Peers Stream.
#transferId
{JSON}The data transfer session.
transferInfo
{JSON}The data transfer information. Object signature matches the
transferInfo
parameter payload received in thedataTransferState
event except without thedata
property.peerId
{String}The sender Peer ID.
isSelf
{Boolean}The flag if Peer is User.
getPeerCustomSettings
()
Function that gets the list of current custom Peer settings sent and set.
Example:
// Example 1: Get the list of current Peer custom settings var currentPeerSettings = skylinkDemo.getPeersCustomSettings();
Events Sequence:
There is no event sequence for this method.Returns:
The list of Peers custom settings sent and set.
#peerId
{JSON}The Peer settings sent and set.
settings
{JSON}The custom Peer settings. Object signature matches the
peerInfo.settings
parameter payload received in thepeerJoined
event.mediaStatus
{JSON}The custom Peer Stream muted settings. Object signature matches the
peerInfo.mediaStatus
parameter payload received in thepeerJoined
event.
getPeerInfo
[peerId]
,
)
Function that returns the User / Peer current session information.
Example:
// Example 1: Get Peer current session information var peerPeerInfo = skylinkDemo.getPeerInfo(peerId);
// Example 2: Get User current session information var userPeerInfo = skylinkDemo.getPeerInfo();
Events Sequence:
There is no event sequence for this method.Parameters:
-
peerId
{String} OptionalThe Peer ID to return the current session information from.
- When not provided or that the Peer ID is does not exists, it will return the User current session information.
Returns:
The User / Peer current session information.
Object signature matches the peerInfo
parameter payload received in the
peerJoined
event.
getPeers
[showAll=false]
,
[callback]
,
)
Note that this feature requiresFunction that retrieves the list of Peer IDs from Rooms within the same App space."isPrivileged"
flag to be enabled for the App Key provided in theinit()
method, as only Users connecting using the App Key with this flag enabled (which we call privileged Users / Peers) can retrieve the list of Peer IDs from Rooms within the same App space. Read more about privileged App Key feature here.
Example:
// Example 1: Retrieving the un-privileged Peers skylinkDemo.joinRoom(function (jRError, jRSuccess) { if (jRError) return; skylinkDemo.getPeers(function (error, success) { if (error) return; console.log("The list of only un-privileged Peers in the same App space ->", success); }); });
// Example 2: Retrieving the all Peers (privileged or un-privileged) skylinkDemo.joinRoom(function (jRError, jRSuccess) { if (jRError) return; skylinkDemo.getPeers(true, function (error, success) { if (error) return; console.log("The list of all Peers in the same App space ->", success); }); });
Events Sequence:
- If App Key provided in the
init()
method is not a Privileged enabled Key:- ABORT and return error.
- Retrieves the list of Peer IDs from Rooms within the same App space.
getPeersStateChange
event triggers parameter payloadstate
value asENQUIRED
.- If received list from Signaling server successfully:
getPeersStateChange
event triggers parameter payloadstate
value asRECEIVED
.
Parameters:
-
showAll
{Boolean} OptionalDEFAULT:false
The flag if Signaling server should also return the list of privileged Peer IDs. By default, the Signaling server does not include the list of privileged Peer IDs in the return result.
-
callback
{Function} OptionalThe callback function fired when request has completed. Function parameters signature is
function (error, success)
Function request completion is determined by thegetPeersStateChange
event triggeringstate
parameter payload value asRECEIVED
for request success. [Rel: Skylink.GET_PEERS_STATE]-
error
{Error | String}The error result in request. Defined as
null
when there are no errors in request Object signature is thegetPeers()
error when retrieving list of Peer IDs from Rooms within the same App space. -
success
{JSON}The success result in request. Defined as
null
when there are errors in request Object signature matches thepeerList
parameter payload received in thegetPeersStateChange
event.
-
getPeersDatachannels
()
Function that gets the current list of connected Peers Datachannel connections in the Room.
Example:
// Example 1: Get the list of current Peers Datachannels in the same Room var channels = skylinkDemo.getPeersDatachannels();
Events Sequence:
There is no event sequence for this method.Returns:
The list of Peers Stream.
#peerId
{JSON}The Peer Datachannels information.
#channelName
{JSON}The Datachannel information.
channelName
{String}The Datachannel ID..
channelType
{String}The Datachannel type. [Rel: Skylink.DATA_CHANNEL_TYPE]
channelProp
{String}The Datachannel property.
currentTransferId
{String}The Datachannel connection current progressing transfer session. Defined as
null
when there is currently no transfer session progressing on the Datachannel connection.currentStreamId
{String}The Datachannel connection current data streaming session ID. Defined as
null
when there is currently no data streaming session on the Datachannel connection.readyState
{String}The Datachannel connection readyState. [Rel: Skylink.DATA_CHANNEL_STATE]
bufferedAmountLow
{Number}The Datachannel buffered amount.
bufferedAmountLowThreshold
{Number}The Datachannel buffered amount threshold.
getPeersInRoom
()
Function that gets the list of connected Peers in the Room.
Example:
// Example 1: Get the list of currently connected Peers in the same Room var peers = skylinkDemo.getPeersInRoom();
Events Sequence:
There is no event sequence for this method.Returns:
The list of connected Peers.
#peerId
{JSON}The Peer information. Object signature matches the
peerInfo
parameter payload received in thepeerJoined
event except there is theisSelf
flag that determines if Peer is User or not.
getPeersStream
()
Function that gets the list of connected Peers Streams in the Room.
Example:
// Example 1: Get the list of current Peers Streams in the same Room var streams = skylinkDemo.getPeersStream();
Events Sequence:
There is no event sequence for this method.Returns:
The list of Peers Stream.
#peerId
{JSON}The Peer Stream.
stream
{MediaStream}The Stream object.
streamId
{String}The Stream ID.
isSelf
{Boolean}The flag if Peer is User.
getRecordings
()
Note that this feature requires MCU and recording to be enabled for the App Key provided in the
init()
method. If recording feature is not available to
be enabled in the Developer Console, please
contact us on our support portal.
Gets the list of current recording sessions since User has connected to the Room.
Example:
// Example 1: Get recording sessions skylinkDemo.getRecordings();
Events Sequence:
There is no event sequence for this method.Returns:
The list of recording sessions.
#recordingId
{JSON}The recording session.
active
{Boolean}The flag that indicates if the recording session is currently active.
state
{Number}The current recording state. [Rel: Skylink.RECORDING_STATE]
startedDateTime
{String}The recording session started DateTime in ISO 8601 format.Note that this value may not be very accurate as this value is recorded when the start event is received.
endedDateTime
{String}The recording session ended DateTime in ISO 8601 format.Note that this value may not be very accurate as this value is recorded when the stop event is received. Defined only after
state
has triggeredSTOP
.mixingDateTime
{String}The recording session mixing completed DateTime in ISO 8601 format.Note that this value may not be very accurate as this value is recorded when the mixing completed event is received. Defined only when
state
isLINK
.links
{JSON}The recording session links. Object signature matches the
link
parameter payload received in therecordingState
event. Defined only whenstate
isLINK
.error
{Error}The recording session error. Defined only when
state
isERROR
.
getScreenSources
callback
,
)
Function that returns the screensharing sources.
Example:
// Example 1: Retrieve the list of available shareScreen() sources. skylinkDemo.getScreenSources(function (sources) { skylinkDemo.shareScreen(sources.mediaSource[0] || null); });
// Example 2: Retrieve the list of available shareScreen() sources with a specific item. skylinkDemo.getScreenSources(function (sources) { if (sources.mediaSourceInput[0]) { skylinkDemo.shareScreen({ mediaSource: mediaSourceInput[0].mediaSource, sourceId: mediaSourceInput[0].sourceId }); } else { skylinkDemo.shareScreen(); } });
Events Sequence:
There is no event sequence for this method.Parameters:
-
callback
{Function}The callback function fired when request has completed. Function parameters signature is
function (success)
-
success
{JSON}The success result in request. Object signature is the list of sources.
-
success
{JSON}The list of screensharing media sources and screen sources.
-
mediaSource
{Array}The array of screensharing media sources. -
mediaSource.#index
{String}The screensharing media source item. [Rel: Skylink.MEDIA_SOURCE] -
mediaSourceInput
{Array}The list of specific media source screen inputs. -
mediaSourceInput.#index
{JSON}The media source screen input item. -
mediaSourceInput.#index.sourceId
{String}The screen input item ID. -
mediaSourceInput.#index.label
{String}The screen input item label name. -
mediaSourceInput.#index.mediaSource
{String}The screen input item media source it belongs to. [Rel: Skylink.MEDIA_SOURCE]
-
-
getStreamSources
callback
,
)
Function that returns the camera and microphone sources.
Example:
// Example 1: Retrieve the getUserMedia() stream with selected source ID. skylinkDemo.getStreamSources(function (sources) { skylinkDemo.getUserMedia({ audio: sources.audio.input[0].deviceId, video: sources.video.input[0].deviceId }); });
// Example 2: Set the output audio speaker (Chrome 49+ supported only) skylinkDemo.getStreamSources(function (sources) { var videoElement = document.getElementById('video'); if (videoElement && typeof videoElement.setSinkId === 'function') { videoElement.setSinkId(sources.audio.output[0].deviceId) } });
Events Sequence:
There is no event sequence for this method.Parameters:
-
callback
{Function}The callback function fired when request has completed. Function parameters signature is
function (success)
-
success
{JSON}The success result in request. Object signature is the list of sources.
-
audio
{JSON}The list of audio input (microphone) and output (speakers) sources. -
audio.input
{Array}The list of audio input (microphone) sources. -
audio.input.#index
{JSON}The audio input source item. -
audio.input.#index.deviceId
{String}The audio input source item device ID. -
audio.input.#index.label
{String}The audio input source item device label name. -
audio.input.#index.groupId
{String} OptionalThe audio input source item device physical device ID. Note that there can be differentdeviceId
due to differing sources but can share agroupId
because it's the same device. -
audio.output
{Array}The list of audio output (speakers) sources. -
audio.output.#index
{JSON}The audio output source item. Object signature matchescallback.success.audio.input.#index
format. -
video
{JSON}The list of video input (camera) sources. -
video.input
{Array}The list of video input (camera) sources. -
video.input.#index
{JSON}The video input source item. Object signature matchescallback.success.audio.input.#index
format.
-
-
getUserData
[peerId]
,
)
Function that returns the User / Peer current custom data.
Example:
// Example 1: Get Peer current custom data var peerUserData = skylinkDemo.getUserData(peerId);
// Example 2: Get User current custom data var userUserData = skylinkDemo.getUserData();
Events Sequence:
There is no event sequence for this method.Parameters:
-
peerId
{String} OptionalThe Peer ID to return the current custom data from.
- When not provided or that the Peer ID is does not exists, it will return the User current custom data.
Returns:
The User / Peer current custom data.
getUserMedia
[options]
,
[callback]
,
)
For a better user experience, the functionality is throttled when invoked many times in less
than the milliseconds interval configured in the init()
method.
Function that retrieves camera Stream.
Example:
// Example 1: Get both audio and video. skylinkDemo.getUserMedia(function (error, success) { if (error) return; attachMediaStream(document.getElementById("my-video"), success); });
// Example 2: Get only audio. skylinkDemo.getUserMedia({ audio: true }, function (error, success) { if (error) return; attachMediaStream(document.getElementById("my-audio"), success); });
// Example 3: Configure resolution for video skylinkDemo.getUserMedia({ audio: true, video: { resolution: skylinkDemo.VIDEO_RESOLUTION.HD } }, function (error, success) { if (error) return; attachMediaStream(document.getElementById("my-video"), success); });
// Example 4: Configure stereo flag for OPUS codec audio (OPUS is always used by default) skylinkDemo.init({ appKey: "xxxxxx", audioCodec: skylinkDemo.AUDIO_CODEC.OPUS }, function (initErr, initSuccess) { skylinkDemo.getUserMedia({ audio: { stereo: true }, video: true }, function (error, success) { if (error) return; attachMediaStream(document.getElementById("my-video"), success); }); });
// Example 5: Configure frameRate for video skylinkDemo.getUserMedia({ audio: true, video: { frameRate: 50 } }, function (error, success) { if (error) return; attachMediaStream(document.getElementById("my-video"), success); });
// Example 6: Configure video and audio based on selected sources. Does not work for Firefox currently. var sources = { audio: [], video: [] };
function selectStream (audioSourceId, videoSourceId) { if (AdapterJS.webrtcDetectedBrowser === 'firefox') { console.warn("Currently this feature is not supported by Firefox browsers!"); return; } skylinkDemo.getUserMedia({ audio: { optional: [{ sourceId: audioSourceId }] }, video: { optional: [{ sourceId: videoSourceId }] } }, function (error, success) { if (error) return; attachMediaStream(document.getElementById("my-video"), success); }); }
navigator.mediaDevices.enumerateDevices().then(function(devices) { var selectedAudioSourceId = ""; var selectedVideoSourceId = ""; devices.forEach(function(device) { console.log(device.kind + ": " + device.label + " source ID = " + device.deviceId); if (device.kind === "audio") { selectedAudioSourceId = device.deviceId; } else { selectedVideoSourceId = device.deviceId; } }); selectStream(selectedAudioSourceId, selectedVideoSourceId); }).catch(function (error) { console.error("Failed", error); });
Events Sequence:
- If
options.audio
value isfalse
andoptions.video
value isfalse
:- ABORT and return error.
- Retrieve camera Stream.
- If retrieval was succesful:
- If there is any previous
getUserMedia()
Stream:- Invokes
stopStream()
method.
- Invokes
- If there are missing audio or video tracks requested:
mediaAccessFallback
event triggers parameter payloadstate
asFALLBACKED
,isScreensharing
value asfalse
andisAudioFallback
value asfalse
.
- Mutes / Unmutes audio and video tracks based on current muted settings in
peerInfo.mediaStatus
. This can be retrieved withgetPeerInfo()
method. mediaAccessSuccess
event triggers parameter payloadisScreensharing
value asfalse
andisAudioFallback
value asfalse
.
- If there is any previous
- Else:
- If
options.audioFallback
is enabled in theinit()
method,options.audio
value istrue
andoptions.video
value istrue
:mediaAccessFallback
event event triggers parameter payloadstate
asFALLBACKING
,isScreensharing
value asfalse
andisAudioFallback
value astrue
.- Retrieve camera Stream with audio tracks only.
- If retrieval was successful:
- If there is any previous
getUserMedia()
Stream:- Invokes
stopStream()
method.
- Invokes
mediaAccessFallback
event event triggers parameter payloadstate
asFALLBACKED
,isScreensharing
value asfalse
andisAudioFallback
value astrue
.- Mutes / Unmutes audio and video tracks based on current muted settings in
peerInfo.mediaStatus
. This can be retrieved withgetPeerInfo()
method. mediaAccessSuccess
event triggers parameter payloadisScreensharing
value asfalse
andisAudioFallback
value astrue
.
- If there is any previous
- Else:
mediaAccessError
event triggers parameter payloadisScreensharing
value asfalse
andisAudioFallbackError
value astrue
.mediaAccessFallback
event event triggers parameter payloadstate
asERROR
,isScreensharing
value asfalse
andisAudioFallback
value astrue
.- ABORT and return error.
- If retrieval was successful:
- Else:
mediaAccessError
event triggers parameter payloadisScreensharing
value asfalse
andisAudioFallbackError
value asfalse
.- ABORT and return error.
- If
- If retrieval was succesful:
Parameters:
-
options
{JSON} OptionalThe camera Stream configuration options.
- When not provided, the value is set to
{ audio: true, video: true }
. To fallback to retrieve audio track only when retrieving of audio and video tracks failed, enable theaudioFallback
flag in theinit()
method.
-
useExactConstraints
{Boolean} OptionalDEFAULT:false
Note that by enabling this flag, exact values will be requested when retrieving camera Stream, but it does not prevent constraints related errors. By default when not enabled, expected mandatory maximum values (or optional values for source ID) will requested to prevent constraints related errors, with an exception for
The flag ifoptions.video.frameRate
option in Safari and IE (any plugin-enabled) browsers, where the expected maximum value will not be requested due to the lack of support.getUserMedia()
should request for camera Stream to match exact requested values ofoptions.audio.deviceId
andoptions.video.deviceId
,options.video.resolution
andoptions.video.frameRate
when provided. -
audio
{Boolean | JSON} OptionalDEFAULT:false
Note that the current Edge browser implementation does not support the
The audio configuration options.options.audio.optional
,options.audio.deviceId
,options.audio.echoCancellation
.-
stereo
{Boolean} OptionalDEFAULT:false
Deprecation Warning! This property has been deprecated. Configure this with the
The flag if OPUS audio codec stereo band should be configured for sending encoded audio data. When not provided, the default browser configuration is used.options.codecParams.audio.opus.stereo
and theoptions.codecParams.audio.opus["sprop-stereo"]
parameter in theinit()
method instead. If theoptions.codecParams.audio.opus.stereo
oroptions.codecParams.audio.opus["sprop-stereo"]
is configured, this overrides theoptions.audio.stereo
setting. -
usedtx
{Boolean} OptionalDeprecation Warning! This property has been deprecated. Configure this with the
The flag if OPUS audio codec should enable DTX (Discontinuous Transmission) for sending encoded audio data. This might help to reduce bandwidth as it reduces the bitrate during silence or background noise, and goes hand-in-hand with theoptions.codecParams.audio.opus.stereo
parameter in theinit()
method instead. If theoptions.codecParams.audio.opus.stereo
is configured, this overrides theoptions.audio.stereo
setting. Note that this feature might not work depending on the browser support and implementation.options.voiceActivityDetection
flag injoinRoom()
method. When not provided, the default browser configuration is used. -
useinbandfec
{Boolean} OptionalDeprecation Warning! This property has been deprecated. Configure this with the
The flag if OPUS audio codec has the capability to take advantage of the in-band FEC (Forward Error Correction) when sending encoded audio data. This helps to reduce the harm of packet loss by encoding information about the previous packet loss. When not provided, the default browser configuration is used.options.codecParams.audio.opus.useinbandfec
parameter in theinit()
method instead. If theoptions.codecParams.audio.opus.useinbandfec
is configured, this overrides theoptions.audio.useinbandfec
setting. Note that this parameter should only be used for debugging purposes only. -
maxplaybackrate
{Number} OptionalDeprecation Warning! This property has been deprecated. Configure this with the
The OPUS audio codec maximum output sampling rate in Hz (hertz) that is is capable of receiving decoded audio data, to adjust to the hardware limitations and ensure that any sending audio data would not encode at a higher sampling rate specified by this. This value must be betweenoptions.codecParams.audio.opus.maxplaybackrate
parameter in theinit()
method instead. If theoptions.codecParams.audio.opus.maxplaybackrate
is configured, this overrides theoptions.audio.maxplaybackrate
setting. Note that this feature might not work depending on the browser support and implementation. Note that this parameter should only be used for debugging purposes only.8000
to48000
. When not provided, the default browser configuration is used. -
mute
{Boolean} OptionalDEFAULT:false
The flag if audio tracks should be muted upon receiving them. Providing the value asfalse
does nothing topeerInfo.mediaStatus.audioMuted
, but when provided astrue
, this sets thepeerInfo.mediaStatus.audioMuted
value totrue
and mutes any existingshareScreen()
Stream audio tracks as well. -
optional
{Array} OptionalThis property has been deprecated. "optional" constraints has been moved from specs.
The
Note that this may result in constraints related error whenoptions.useExactConstraints
value istrue
. If you are looking to set the requested source ID of the audio track, useoptions.audio.deviceId
instead.navigator.getUserMedia()
APIaudio: { optional [..] }
property. -
deviceId
{String} OptionalNote this is currently not supported in Firefox browsers.
The audio track source ID of the device to use. The list of available audio source ID can be retrieved by thenavigator.mediaDevices.enumerateDevices
API. -
echoCancellation
{Boolean} OptionalDEFAULT:true
For Chrome/Opera/IE/Safari/Bowser, the echo cancellation functionality may not work and may produce a terrible feedback. It is recommended to use headphones or other microphone devices rather than the device in-built microphones.
The flag to enable echo cancellation for audio track.
-
-
video
{Boolean | JSON} OptionalDEFAULT:false
Note that the current Edge browser implementation does not support the
The video configuration options.options.video.optional
,options.video.deviceId
,options.video.resolution
andoptions.video.frameRate
,options.video.facingMode
.-
mute
{Boolean} OptionalDEFAULT:false
The flag if video tracks should be muted upon receiving them. Providing the value asfalse
does nothing topeerInfo.mediaStatus.videoMuted
, but when provided astrue
, this sets thepeerInfo.mediaStatus.videoMuted
value totrue
and mutes any existingshareScreen()
Stream video tracks as well. -
resolution
{JSON} OptionalThe video resolution. By default,VGA
resolution option is selected when not provided. [Rel: Skylink.VIDEO_RESOLUTION] -
resolution.width
{Number | JSON} OptionalThe video resolution width. - When provided as a number, it is the video resolution width. - When provided as a JSON, it is thenavigator.mediaDevices.getUserMedia()
.width
settings. Parameters are"ideal"
for ideal resolution width,"exact"
for exact video resolution width,"min"
for min video resolution width and"max"
for max video resolution width. Note that this may result in constraints related errors depending on the browser/hardware supports. -
resolution.height
{Number | JSON} OptionalThe video resolution height. - When provided as a number, it is the video resolution height. - When provided as a JSON, it is thenavigator.mediaDevices.getUserMedia()
.height
settings. Parameters are"ideal"
for ideal video resolution height,"exact"
for exact video resolution height,"min"
for min video resolution height and"max"
for max video resolution height. Note that this may result in constraints related errors depending on the browser/hardware supports. -
frameRate
{Number | JSON} OptionalThe video frameRate per second (fps). - When provided as a number, it is the video framerate. - When provided as a JSON, it is thenavigator.mediaDevices.getUserMedia()
.frameRate
settings. Parameters are"ideal"
for ideal video framerate,"exact"
for exact video framerate,"min"
for min video framerate and"max"
for max video framerate. Note that this may result in constraints related errors depending on the browser/hardware supports. -
optional
{Array} OptionalThis property has been deprecated. "optional" constraints has been moved from specs.
The
Note that this may result in constraints related error whenoptions.useExactConstraints
value istrue
. If you are looking to set the requested source ID of the video track, useoptions.video.deviceId
instead.navigator.getUserMedia()
APIvideo: { optional [..] }
property. -
deviceId
{String} OptionalNote this is currently not supported in Firefox browsers.
The video track source ID of the device to use. The list of available video source ID can be retrieved by thenavigator.mediaDevices.enumerateDevices
API. -
facingMode
{String | JSON} OptionalThe video camera facing mode. The list of available video source ID can be retrieved by the MediaTrackConstraintsfacingMode
API.
-
- When not provided, the value is set to
-
callback
{Function} OptionalThe callback function fired when request has completed. Function parameters signature is
function (error, success)
Function request completion is determined by themediaAccessSuccess
event triggeringisScreensharing
parameter payload value asfalse
for request success.-
error
{Error | String}The error result in request. Defined as
null
when there are no errors in request Object signature is thegetUserMedia()
error when retrieving camera Stream. -
success
{MediaStream}The success result in request. Defined as
null
when there are errors in request Object signature is the camera Stream object.
-
init
options
,
[callback]
,
)
Function that authenticates and initialises App Key used for Room connections.
Example:
// Example 1: Using CORS authentication and connection to default Room skylinkDemo(appKey, function (error, success) { if (error) return; skylinkDemo.joinRoom(); // Goes to default Room });
// Example 2: Using CORS authentication and connection to a different Room skylinkDemo(appKey, function (error, success) { skylinkDemo.joinRoom("testxx"); // Goes to "testxx" Room });
// Example 3: Using credentials authentication and connection to only default Room var defaultRoom = "test", startDateTime = (new Date()).toISOString(), duration = 1, // Allows only User session to stay for 1 hour appKeySecret = "xxxxxxx", hash = CryptoJS.HmacSHA1(defaultRoom + "_" + duration + "_" + startDateTime, appKeySecret); credentials = encodeURIComponent(hash.toString(CryptoJS.enc.Base64));
skylinkDemo({ defaultRoom: defaultRoom, appKey: appKey, credentials: { duration: duration, startDateTime: startDateTime, credentials: credentials } }, function (error, success) { if (error) return; skylinkDemo.joinRoom(); // Goes to default Room (switching to different Room is not allowed for credentials authentication) });
Events Sequence:
- If parameter
options
is not provided:- ABORT and return error.
- Checks if dependecies and browser APIs are available.
- If AdapterJS is not loaded:
readyStateChange
event triggers parameter payloadstate
asERROR
anderror.errorCode
asADAPTER_NO_LOADED
.- ABORT and return error.
- If socket.io-client is not loaded:
-
readyStateChange
event triggers parameter payloadstate
asERROR
anderror.errorCode
asNO_SOCKET_IO
. - ABORT and return error.
-
- If XMLHttpRequest API is not available:
-
readyStateChange
event triggers parameter payloadstate
asERROR
anderror.errorCode
asNO_XMLHTTPREQUEST_SUPPORT
. - ABORT and return error.
-
- If WebRTC is not supported by device:
readyStateChange
event triggers parameter payloadstate
asERROR
anderror.errorCode
asNO_WEBRTC_SUPPORT
.- ABORT and return error.
- If AdapterJS is not loaded:
- Retrieves Room session token from Auth server.
readyStateChange
event triggers parameter payloadstate
asLOADING
.- If retrieval was successful:
readyStateChange
event triggers parameter payloadstate
asCOMPLETED
.
- Else:
readyStateChange
event triggers parameter payloadstate
asERROR
.- ABORT and return error.
Parameters:
-
options
{JSON | String}The configuration options.
- When provided as a string, it's configured as
options.appKey
.
-
appKey
{String}The App Key. By default,
init()
uses HTTP CORS authentication. For credentials based authentication, see theoptions.credentials
configuration below. You can know more about the in the authentication methods article here for more details on the various authentication methods. If you are using the Persistent Room feature for scheduled meetings, you will require to use the credential based authentication. See the Persistent Room article here for more information. -
defaultRoom
{String} OptionalThe default Room to connect to when no
room
parameter is provided injoinRoom()
method.- When not provided or is provided as an empty string, its value is
options.appKey
. Note that switching Rooms is not available when usingoptions.credentials
based authentication. The Room that User will be connected to is thedefaultRoom
provided.
- When not provided or is provided as an empty string, its value is
-
roomServer
{String} OptionalThe Auth server for debugging purposes to use. Note that this is a debugging feature and is only used when instructed for debugging purposes.
-
enableIceTrickle
{Boolean} OptionalDEFAULT:true
The flag if Peer connections should trickle ICE for faster connectivity.
-
enableStatsGathering
{Boolean} OptionalDEFAULT:true
Configure the anonymous performance and connectivity statistic collection function. Temasys collects encrypted, anonymous performance and connectivity statistics to allow us to improve performance for our customers and identify regional or ISP specific connectivity issues. This data does not contain any personal information or session content. To enable the configuration of this option, you need to "Collect Quality Statistics" option on the Temasys console Website under App key settings section. The default behavior for this option if not specifically configured is true.
-
enableDataChannel
{Boolean} OptionalDEFAULT:true
Note that for Edge browsers, this value is overriden as
The flag if Datachannel connections should be enabled. This is required to be enabled forfalse
due to its supports.sendBlobData()
method,sendURLData()
method andsendP2PMessage()
method. -
enableTURNServer
{Boolean} OptionalDEFAULT:true
The flag if TURN ICE servers should be used when constructing Peer connections to allow TURN connections when required and enabled for the App Key.
-
enableSTUNServer
{Boolean} OptionalDEFAULT:true
The flag if STUN ICE servers should be used when constructing Peer connections to allow TURN connections when required.
-
forceTURN
{Boolean} OptionalDEFAULT:false
The flag if Peer connections should enforce connections over the TURN server. This overrides
options.enableTURNServer
value totrue
andoptions.enableSTUNServer
value tofalse
,options.filterCandidatesType.host
value totrue
,options.filterCandidatesType.srflx
value totrue
andoptions.filterCandidatesType.relay
value tofalse
. Note that currently for MCU enabled Peer connections, theoptions.filterCandidatesType
configuration is not honoured as Peers connected with MCU is similar as a forced TURN connection. The flags will act as if the value isfalse
and ICE candidates will never be filtered regardless of theoptions.filterCandidatesType
configuration. -
usePublicSTUN
{Boolean} OptionalDEFAULT:false
The flag if publicly available STUN ICE servers should be used if
options.enableSTUNServer
is enabled. -
TURNServerTransport
{Boolean} OptionalNote that configuring the protocol may not necessarily result in the desired network transports protocol used in the actual TURN network traffic as it depends which protocol the browser selects and connects with. This simply configures the TURN ICE server urls
The option to configure thequery option when constructing the Peer connection. When all protocols are selected, the ICE servers urls are duplicated with all protocols.
Note that for Edge browsers, this value is overriden asUDP
due to its supports.?transport=
query parameter in TURN ICE servers when constructing a Peer connections.- When not provided, its value is
ANY
. [Rel: Skylink.TURN_TRANSPORT]
- When not provided, its value is
-
disableVideoFecCodecs
{Boolean} OptionalDEFAULT:false
Note that this is an experimental flag and may cause disruptions in connections or connectivity issues when toggled, and to prevent connectivity issues, these codecs will not be removed for MCU enabled Peer connections.
The flag if video FEC (Forward Error Correction) codecs like ulpfec and red should be removed in sending session descriptions. This can be useful for debugging purposes to prevent redundancy and overheads in RTP encoding. -
disableComfortNoiseCodec
{Boolean} OptionalDEFAULT:false
Note that this is an experimental flag and may cause disruptions in connections or connectivity issues when toggled.
The flag if audio Comfort Noise (CN) codec should be removed in sending session descriptions. This can be useful for debugging purposes to test preferred audio quality and feedback. -
disableREMB
{Boolean} OptionalDEFAULT:false
Note that this is mainly used for debugging purposes and that it is an experimental flag, so it may cause disruptions in connections or connectivity issues when toggled.
The flag if video REMB feedback packets should be disabled in sending session descriptions. -
credentials
{JSON} OptionalNote that we strongly recommend developers to return the
The credentials used for authenticating App Key with credentials to retrieve the Room session token used for connection inoptions.credentials.duration
,options.credentials.startDateTime
andoptions.defaultRoom
and generate theoptions.credentials.credentials
from a web server as secret shouldn't be exposed on client web app as it poses a security risk itself.joinRoom()
method. Note that switching of Rooms is not allowed when using credentials based authentication, unlessinit()
is invoked again with a different set of credentials followed by invoking thejoinRoom()
method.-
startDateTime
{String}The credentials User session in Room starting DateTime in ISO 8601 format. -
duration
{Number}The credentials User session in Room duration in hours. -
credentials
{String}The generated credentials used to authenticate the provided App Key with its"secret"
property.To generate the credentials:
- Concatenate a string that consists of the Room name you provide in the
options.defaultRoom
, theoptions.credentials.duration
and theoptions.credentials.startDateTime
. Example:var concatStr = defaultRoom + "_" + duration + "_" + startDateTime;
- Hash the concatenated string with the App Key
"secret"
property using SHA-1. Example:var hash = CryptoJS.HmacSHA1(concatStr, appKeySecret);
See theCryptoJS.HmacSHA1
library. - Encode the hashed string using base64
Example:
var b64Str = hash.toString(CryptoJS.enc.Base64);
See the CryptoJS.enc.Base64 library. - Encode the base64 encoded string to replace special characters using UTF-8 encoding.
Example:
var credentials = encodeURIComponent(base64String);
See encodeURIComponent() API.
- Concatenate a string that consists of the Room name you provide in the
-
-
audioFallback
{Boolean} OptionalDEFAULT:false
The flag if
getUserMedia()
method should fallback to retrieve only audio Stream when retrieving audio and video Stream fails. -
forceSSL
{Boolean} OptionalDEFAULT:true
The flag if HTTPS connections should be enforced during request to Auth server and socket connections to Signaling server when accessing
window.location.protocol
value is"http:"
. By default,"https:"
protocol connections uses HTTPS connections. -
audioCodec
{String | JSON} OptionalNote that if the audio codec is not supported, the SDK will not configure the local
The option to configure the preferred audio codec to use to encode sending audio data when available for Peer connection."offer"
or"answer"
session description to prefer the codec.
Note that for Edge browsers, this value is set asOPUS
due to its supports.- When not provided, its value is
AUTO
. [Rel: Skylink.AUDIO_CODEC]
-
codec
{String}The audio codec to prefer to encode sending audio data when available. The value must not beAUTO
. [Rel: Skylink.AUDIO_CODEC] -
samplingRate
{Number} OptionalThe audio codec sampling to prefer to encode sending audio data when available. -
channels
{Number} OptionalThe audio codec channels to prefer to encode sending audio data when available.
- When not provided, its value is
-
videoCodec
{String | JSON} OptionalNote that if the video codec is not supported, the SDK will not configure the local
The option to configure the preferred video codec to use to encode sending video data when available for Peer connection."offer"
or"answer"
session description to prefer the codec.
Note that for Edge browsers, this value is set asH264
due to its supports.- When not provided, its value is
AUTO
. [Rel: Skylink.VIDEO_CODEC]
-
codec
{String}The video codec to prefer to encode sending audio data when available. The value must not beAUTO
. [Rel: Skylink.VIDEO_CODEC] -
samplingRate
{Number} OptionalThe video codec sampling to prefer to encode sending video data when available.
- When not provided, its value is
-
socketTimeout
{Number} OptionalDEFAULT:7000
The timeout for each attempts for socket connection with the Signaling server to indicate that connection has timed out and has failed to establish. Note that the mininum timeout value is
5000
. If less, this value will be5000
. Note that it is recommended to use7000
as the lowest timeout value if Peers are connecting using Polling transports to prevent connection errors. -
apiTimeout
{Number} OptionalDEFAULT:4000
The timeout to wait for response from Auth server.
-
forceTURNSSL
{Boolean} OptionalDEFAULT:false
Note that currently Firefox does not support the TURNS protocol, and that if TURNS is required, TURN ICE servers using port
The flag if TURNS protocol should be used when443
will be used instead.
Note that for Edge browsers, this value is overriden asfalse
due to its supports and only port3478
is used.options.enableTURNServer
is enabled. -
filterCandidatesType
{JSON} OptionalNote that this a debugging feature and there might be connectivity issues when toggling these flags.
The configuration options to filter the type of ICE candidates sent and received.-
host
{Boolean} OptionalDEFAULT:false
The flag if local network ICE candidates should be filtered out. -
srflx
{Boolean} OptionalDEFAULT:false
The flag if STUN ICE candidates should be filtered out. -
relay
{Boolean} OptionalDEFAULT:false
The flag if TURN ICE candidates should be filtered out.
-
-
throttleIntervals
{JSON} OptionalThe configuration options to configure the throttling method timeouts.
-
shareScreen
{Number} Optional -
getUserMedia
{Number} Optional -
refreshConnection
{Number} OptionalDEFAULT:5000
Note that this throttling is only done for MCU enabled Peer connections with the
The interval timeout foroptions.mcuUseRenegoRestart
being set tofalse
.refreshConnection()
method throttling in milliseconds. Note that there will be no throttling whenrefreshConnection()
method is called internally.
-
-
throttleShouldThrowError
{Boolean} OptionalDEFAULT:false
The flag if throttled methods should throw errors when method is invoked less than the interval timeout value configured in
options.throttleIntervals
. -
mcuUseRenegoRestart
{Boolean} OptionalDEFAULT:true
Note that this feature is currently is beta and for any enquiries on enabling and its support, please contact our support portal.
The flag ifrefreshConnection()
method should renegotiate like non-MCU enabled Peer connection for MCU enabled Peer connections instead of invokingjoinRoom()
method again. -
iceServer
{String | Array} OptionalThe ICE servers for debugging purposes to use.
- When defined as string, the value is considered as
[options.iceServer]
. Note that this is a debugging feature and is only used when instructed for debugging purposes.
-
#index
{String} OptionalThe ICE server url for debugging purposes to use.
- When defined as string, the value is considered as
-
socketServer
{String | JSON} OptionalThe Signaling server for debugging purposes to use.
- When defined as string, the value is considered as
{ url: options.socketServer }
. Note that this is a debugging feature and is only used when instructed for debugging purposes.
-
url
{String}The Signaling server URL for debugging purposes to use. -
ports
{Array} OptionalThe list of Signaling server ports for debugging purposes to use. If not defined, it will use the default list of ports specified. -
ports.#index
{Number}The Signaling server port to fallback and use for debugging purposes. -
protocol
{String} OptionalThe Signaling server protocol for debugging purposes to use. If not defined, it will use the default protocol specified.
- When defined as string, the value is considered as
-
codecParams
{JSON} OptionalNote that some of these parameters are mainly used for experimental or debugging purposes. Toggling any of these feature may result in disruptions in connectivity.
The audio and video codecs parameters to configure.-
video
{JSON} OptionalThe video codecs parameters to configure. -
video.h264
{JSON} OptionalThe H264 video codec parameters to configure. -
video.h264.profileLevelId
{String} OptionalNote that this parameter should only be used for debugging purposes only.
The H264 video codec base16 encoded string which indicates the H264 baseline, main, or the extended profiles. When not provided, the default browser configuration is used. -
video.h264.levelAsymmetryAllowed
{Boolean} OptionalNote that this is an experimental parameter which may result in connectivity issues when toggled.
The flag if streaming H264 sending video data should be encoded at a different level from receiving video data from Peer encoding to User when Peer is the offerer. If Peer is the offerer instead of the User, the Peer'speerInfo.config.priorityWeight
will be higher than User'speerInfo.config.priorityWeight
. When not provided, the default browser configuration is used. -
video.h264.packetizationMode
{Number} OptionalNote that this is an experimental parameter which may result in connectivity issues when enabled. It is advisable to turn off this feature off when receiving H264 decoders do not support the packetization mode, which may result in a blank receiving video stream.
The flag to enable H264 video codec packetization mode, which splits video frames that are larger for a RTP packet into RTP packet chunks. When not provided, the default browser configuration is used. -
video.vp8
{JSON} OptionalThe VP8 video codec parameters to configure. -
video.vp8.maxFr
{Number} OptionalNote that this parameter should only be used for debugging purposes only. Do not toggle this otherwise.
The maximum number of fps (frames per second) that the VP8 video codec decoder is capable of decoding when receiving encoded video data packets. When not provided, the default browser configuration is used. -
video.vp8.maxFs
{Number} OptionalNote that this parameter should only be used for debugging purposes only. Do not toggle this otherwise.
The maximum number of frame size macroblocks that the VP8 video codec decoder is capable of decoding when receiving encoded video data packets. The value has to have the width and height of the frame in macroblocks less than the value ofparseInt(Math.sqrt(maxFs * 8))
. E.g. If the value is1200
, it is capable of support640x480
frame width and height, which heights up to1552px
(97
macroblocks value. When not provided, the default browser configuration is used. -
video.vp9
{JSON} OptionalThe VP9 video codec parameters to configure. -
video.vp9.maxFr
{Number} OptionalNote that this parameter should only be used for debugging purposes only. Do not toggle this otherwise.
The maximum number of fps (frames per second) that the VP9 video codec decoder is capable of decoding when receiving encoded video data packets. When not provided, the default browser configuration is used. -
video.vp9.maxFs
{Number} OptionalNote that this parameter should only be used for debugging purposes only. Do not toggle this otherwise.
The maximum number of frame size macroblocks that the VP9 video codec decoder is capable of decoding when receiving encoded video data packets. The value has to have the width and height of the frame in macroblocks less than the value ofparseInt(Math.sqrt(maxFs * 8))
. E.g. If the value is1200
, it is capable of support640x480
frame width and height, which heights up to1552px
(97
macroblocks value. When not provided, the default browser configuration is used. -
audio
{JSON} OptionalThe audio codecs parameters to configure. -
audio.opus
{JSON} OptionalNote that this is only applicable to OPUS audio codecs with a sampling rate of
The OPUS audio codec parameters to configure.48000
Hz (hertz). -
audio.opus.stereo
{Boolean} OptionalThe flag if OPUS audio codec is able to decode or receive stereo packets. When not provided, the default browser configuration is used. -
audio.opus.sprop-stereo
{Boolean} OptionalThe flag if OPUS audio codec is sending stereo packets. When not provided, the default browser configuration is used. -
audio.opus.usedtx
{Boolean} OptionalNote that this feature might not work depending on the browser support and implementation.
The flag if OPUS audio codec should enable DTX (Discontinuous Transmission) for sending encoded audio data. This might help to reduce bandwidth as it reduces the bitrate during silence or background noise, and goes hand-in-hand with theoptions.voiceActivityDetection
flag injoinRoom()
method. When not provided, the default browser configuration is used. -
audio.opus.useinbandfec
{Boolean} OptionalNote that this parameter should only be used for debugging purposes only.
The flag if OPUS audio codec has the capability to take advantage of the in-band FEC (Forward Error Correction) when sending encoded audio data. This helps to reduce the harm of packet loss by encoding information about the previous packet loss. When not provided, the default browser configuration is used. -
audio.opus.maxplaybackrate
{Number} OptionalNote that this parameter should only be used for debugging purposes only.
The OPUS audio codec maximum output sampling rate in Hz (hertz) that is is capable of receiving decoded audio data, to adjust to the hardware limitations and ensure that any sending audio data would not encode at a higher sampling rate specified by this. This value must be between8000
to48000
. When not provided, the default browser configuration is used. -
minptime
{Number} OptionalNote that this parameter should only be used for debugging purposes only.
The OPUS audio codec receiving audio data decoder minimum length of time in milleseconds should be encapsulated in a single received encoded audio data packet. This value must be between3
to120
When not provided, the default browser configuration is used.
-
-
priorityWeightScheme
{String} OptionalNote that this parameter should only be used for debugging purposes only and may not work when internals change.
The User's priority weight to enforce User as offerer or answerer.- When not provided, its value is
AUTO
. [Rel: Skylink.PRIORITY_WEIGHT_SCHEME]
- When not provided, its value is
-
useEdgeWebRTC
{Boolean} OptionalDEFAULT:false
The flag to use Edge 15.x pre-1.0 WebRTC support.
-
enableSimultaneousTransfers
{Boolean} OptionalDEFAULT:true
The flag to enable simultaneous data transfers.
- When provided as a string, it's configured as
-
callback
{Function} OptionalThe callback function fired when request has completed. Function parameters signature is
function (error, success)
Function request completion is determined by thereadyStateChange
eventstate
parameter payload value asCOMPLETED
for request success. [Rel: Skylink.READY_STATE_CHANGE]-
error
{JSON | String}The error result in request.
- When defined as string, it's the error when required App Key is not provided.
Defined as
null
when there are no errors in request
-
errorCode
{Number}ThereadyStateChange
eventerror.errorCode
parameter payload value. [Rel: Skylink.READY_STATE_CHANGE_ERROR] -
error
{Error | String}ThereadyStateChange
eventerror.content
parameter payload value. -
status
{Number}ThereadyStateChange
eventerror.status
parameter payload value.
- When defined as string, it's the error when required App Key is not provided.
Defined as
-
success
{JSON}The success result in request. Defined as
null
when there are errors in request-
serverUrl
{String}The constructed REST URL requested to Auth server. -
readyState
{Number}The current ready state. [Rel: Skylink.READY_STATE_CHANGE] -
selectedRoom
{String}The Room based on the current Room session token retrieved for. -
appKey
{String}The configured value of theoptions.appKey
. -
defaultRoom
{String}The configured value of theoptions.defaultRoom
. -
roomServer
{String}The configured value of theoptions.roomServer
. -
enableIceTrickle
{Boolean}The configured value of theoptions.enableIceTrickle
. -
enableDataChannel
{Boolean}The configured value of theoptions.enableDataChannel
. -
enableTURNServer
{Boolean}The configured value of theoptions.enableTURNServer
. -
enableSTUNServer
{Boolean}The configured value of theoptions.enableSTUNServer
. -
TURNTransport
{Boolean}The configured value of theoptions.TURNServerTransport
. -
audioFallback
{Boolean}The configured value of theoptions.audioFallback
. -
forceSSL
{Boolean}The configured value of theoptions.forceSSL
. -
audioCodec
{String | JSON}The configured value of theoptions.audioCodec
. -
videoCodec
{String | JSON}The configured value of theoptions.videoCodec
. -
socketTimeout
{Number}The configured value of theoptions.socketTimeout
. -
apiTimeout
{Number}The configured value of theoptions.apiTimeout
. -
forceTURNSSL
{Boolean}The configured value of theoptions.forceTURNSSL
. -
forceTURN
{Boolean}The configured value of theoptions.forceTURN
. -
usePublicSTUN
{Boolean}The configured value of theoptions.usePublicSTUN
. -
disableVideoFecCodecs
{Boolean}The configured value of theoptions.disableVideoFecCodecs
. -
disableComfortNoiseCodec
{Boolean}The configured value of theoptions.disableComfortNoiseCodec
. -
disableREMB
{Boolean}The configured value of theoptions.disableREMB
. -
filterCandidatesType
{JSON}The configured value of theoptions.filterCandidatesType
. -
throttleIntervals
{JSON}The configured value of theoptions.throttleIntervals
. -
throttleShouldThrowError
{Boolean}The configured value of theoptions.throttleShouldThrowError
. -
mcuUseRenegoRestart
{JSON}The configured value of theoptions.mcuUseRenegoRestart
. -
iceServer
{JSON}The configured value of theoptions.iceServer
. See the.urls
property in this object for configured value if defined. -
socketServer
{JSON | String}The configured value of theoptions.socketServer
. -
useEdgeWebRTC
{Boolean}The configured value of theoptions.useEdgeWebRTC
. -
enableSimultaneousTransfers
{Boolean}The configured value of theoptions.enableSimultaneousTransfers
.
-
-
introducePeer
sendingPeerId
,
receivingPeerId
,
)
Note that this feature requiresFunction that selects and introduces a pair of Peers to start connection with each other."isPrivileged"
flag to be enabled and"autoIntroduce"
flag to be disabled for the App Key provided in theinit()
method, as only Users connecting using the App Key with this flag enabled (which we call privileged Users / Peers) can retrieve the list of Peer IDs from Rooms within the same App space. Read more about privileged App Key feature here.
Example:
// Example 1: Introduce a pair of Peers skylinkDemo.on("introduceStateChange", function (state, privilegedPeerId, sendingPeerId, receivingPeerId) { if (state === skylinkDemo.INTRODUCE_STATE.INTRODUCING) { console.log("Peer '" + sendingPeerId + "' has been introduced to '" + receivingPeerId + "'"); } });
skylinkDemo.joinRoom(function (jRError, jRSuccess) { if (jRError) return; skylinkDemo.getPeers(function (gPError, gPSuccess) { if (gPError) return; skylinkDemo.introducePeer(gPSuccess.roomName[0], gPSuccess.roomName[1]); }); });
Events Sequence:
- If App Key provided in the
init()
method is not a Privileged enabled Key:- ABORT and return error.
- Starts sending introduction request for the selected pair of Peers to the Signaling server.
introduceStateChange
event triggers parameter payloadstate
value asINTRODUCING
.- If received errors from Signaling server:
introduceStateChange
event triggers parameter payloadstate
value asERROR
.
Parameters:
-
sendingPeerId
{String}The Peer ID to be connected with
receivingPeerId
. -
receivingPeerId
{String}The Peer ID to be connected with
sendingPeerId
.
joinRoom
[room]
,
[options]
,
[callback]
,
)
Function that starts the Room session.
Example:
// Example 1: Connecting to the default Room without Stream skylinkDemo.joinRoom(function (error, success) { if (error) return; console.log("User connected."); });
// Example 2: Connecting to Room "testxx" with Stream skylinkDemo.joinRoom("testxx", { audio: true, video: true }, function (error, success) { if (error) return; console.log("User connected with getUserMedia() Stream.") });
// Example 3: Connecting to default Room with Stream retrieved earlier skylinkDemo.getUserMedia(function (gUMError, gUMSuccess) { if (gUMError) return; skylinkDemo.joinRoom(function (error, success) { if (error) return; console.log("User connected with getUserMedia() Stream."); }); });
// Example 4: Connecting to "testxx" Room with shareScreen() Stream retrieved manually skylinkDemo.on("mediaAccessRequired", function () { skylinkDemo.shareScreen(function (sSError, sSSuccess) { if (sSError) return; }); });
skylinkDemo.joinRoom("testxx", { manualGetUserMedia: true }, function (error, success) { if (error) return; console.log("User connected with shareScreen() Stream."); });
// Example 5: Connecting to "testxx" Room with User custom data var data = { username: "myusername" }; skylinkDemo.joinRoom("testxx", { userData: data }, function (error, success) { if (error) return; console.log("User connected with correct user data?", success.peerInfo.userData.username === data.username); });
// Example 6: Connecting to "testxx" Room with a pre-configured bandwidth set skylinkDemo.joinRoom("testxx", { bandwidth: skylinkDemo.VIDEO_QUALITY.HD }, function (error, success) { if (error) return; console.log("User connected with bandwidth quality HD"); });
Events Sequence:
- If User is in a Room:
- Invoke
leaveRoom()
method to end current Room connection. InvokedleaveRoom()
methodstopMediaOptions
parameter value will befalse
. Regardless of request errors,joinRoom()
will still proceed.
- Invoke
- Check if Room name provided matches the Room name of the currently retrieved Room session token.
- If Room name does not matches:
- Invoke
init()
method to retrieve new Room session token.- If request has errors:
- ABORT and return error.
- If request has errors:
- Invoke
- If Room name does not matches:
- Open a new socket connection to Signaling server.
- If Socket connection fails:
socketError
event triggers parameter payloaderrorCode
asCONNECTION_FAILED
.- Checks if there are fallback ports and transports to use.
- If there are still fallback ports and transports:
- Attempts to retry socket connection to Signaling server.
channelRetry
event triggers.socketError
event triggers parameter payloaderrorCode
asRECONNECTION_ATTEMPT
.- If attempt to retry socket connection to Signaling server has failed:
socketError
event triggers parameter payloaderrorCode
asRECONNECTION_FAILED
.- Checks if there are still any more fallback ports and transports to use.
- If there are is no more fallback ports and transports to use:
socketError
event triggers parameter payloaderrorCode
asRECONNECTION_ABORTED
.- ABORT and return error.
- Else:
- REPEAT attempt to retry socket connection to Signaling server step.
- If there are is no more fallback ports and transports to use:
- Attempts to retry socket connection to Signaling server.
- Else:
socketError
event triggers parameter payloaderrorCode
asCONNECTION_ABORTED
.- ABORT and return error.
- If there are still fallback ports and transports:
- Checks if there are fallback ports and transports to use.
- If socket connection to Signaling server has opened:
channelOpen
event triggers.
- If Socket connection fails:
- Checks if there is
options.manualGetUserMedia
requested- If it is requested:
mediaAccessRequired
event triggers.- If more than 30 seconds has passed and no
getUserMedia()
Stream orshareScreen()
Stream has been retrieved:- ABORT and return error.
- Else:
- If there is
options.audio
oroptions.video
requested:- Invoke
getUserMedia()
method.- If request has errors:
- ABORT and return error.
- If request has errors:
- Invoke
- If there is
- If it is requested:
- Starts the Room session
- If Room session has started successfully:
peerJoined
event triggers parameter payloadisSelf
value astrue
.- If MCU is enabled for the App Key provided in
init()
method and connected:serverPeerJoined
event triggersserverPeerType
asMCU
. MCU has to be present in the Room in order for Peer connections to commence.- Checks for any available Stream
- If
shareScreen()
Stream is available:incomingStream
event triggers parameter payloadisSelf
value astrue
andstream
asshareScreen()
Stream. User will be sendingshareScreen()
Stream to Peers.
- Else if
getUserMedia()
Stream is available:incomingStream
event triggers parameter payloadisSelf
value astrue
andstream
asgetUserMedia()
Stream. User will be sendinggetUserMedia()
Stream to Peers.
- Else:
- No Stream will be sent.
- If
- Else:
systemAction
event triggers parameter payloadaction
asREJECT
.- ABORT and return error.
- If Room session has started successfully:
Parameters:
-
room
{String} OptionalThe Room name.
- When not provided or is provided as an empty string, its value is the
options.defaultRoom
provided in theinit()
method. Note that if you are using credentials based authentication, you cannot switch the Room that is not the same as theoptions.defaultRoom
defined in theinit()
method.
- When not provided or is provided as an empty string, its value is the
-
options
{JSON} OptionalThe Room session configuration options.
-
userData
{JSON | String} OptionalThe User custom data. This can be set after Room session has started using the
setUserData()
method. -
useExactConstraints
{Boolean} OptionalThe
getUserMedia()
methodoptions.useExactConstraints
parameter settings. See theoptions.useExactConstraints
parameter in thegetUserMedia()
method for more information. -
audio
{Boolean | JSON} OptionalThe
getUserMedia()
methodoptions.audio
parameter settings. When value is defined astrue
or an object,getUserMedia()
method to be invoked to retrieve new Stream. Ifoptions.video
is not defined, it will be defined asfalse
. Object signature matches theoptions.audio
parameter in thegetUserMedia()
method. -
video
{Boolean | JSON} OptionalThe
getUserMedia()
methodoptions.video
parameter settings. When value is defined astrue
or an object,getUserMedia()
method to be invoked to retrieve new Stream. Ifoptions.audio
is not defined, it will be defined asfalse
. Object signature matches theoptions.video
parameter in thegetUserMedia()
method. -
voiceActivityDetection
{Boolean} OptionalDEFAULT:true
The flag if voice activity detection should be enabled. This can only be toggled if User is and for the offerer, which is determined if User's
peerInfo.config.priorityWeight
is higher than Peer's.This works hand-in-hand with the
options.disableComfortNoiseCodec
flag in theinit()
method and theoptions.audio.usedtx
setting ingetUserMedia()
method. VAD (voice activity detection) detects if there is an active voice in the Stream, and if there is no active voice in the Stream, theoptions.audio.usedtx
(if enabled) would prevent sending these empty bits. To prevent huge differences when there is a silence and an active voice later, the CN codec would produce an empty voice to make it sound better. -
bandwidth
{JSON} OptionalNote that this is currently not supported with Firefox browsers versions 48 and below as noted in an existing bugzilla ticket here.
The configuration to set the maximum streaming bandwidth to send to Peers. You can also use the preconfigured constantVIDEO_QUALITY
for recommended values.-
audio
{Number} OptionalThe maximum audio streaming bandwidth sent to Peers in kbps. Recommended values are50
to200
.50
is sufficient enough for an audio call. The higher you go if you want clearer audio and to be able to hear music streaming. -
video
{Number} OptionalThe maximum video streaming bandwidth sent to Peers. Recommended values are256
-500
for 180p quality,500
-1024
for 360p quality,1024
-2048
for 720p quality and2048
-4096
for 1080p quality. -
data
{Number} OptionalThe maximum data streaming bandwidth sent to Peers. This affects the P2P messaging insendP2PMessage()
method, and data transfers insendBlobData()
method andsendURLData()
method.
-
-
googleXBandwidth
{JSON} OptionalNote that this is an experimental configuration and may cause disruptions in connections or connectivity issues when toggled, or may not work depending on browser supports. Currently, this only toggles the video codec bandwidth configuration.
The configuration to set the experimental google video streaming bandwidth sent to Peers. Note that Peers may override the "receive from" streaming bandwidth depending on the Peers configuration.-
min
{Number} OptionalThe minimum experimental google video streaming bandwidth sent to Peers. This toggles the"x-google-min-bitrate"
flag in the session description. -
max
{Number} OptionalThe maximum experimental google video streaming bandwidth sent to Peers. This toggles the"x-google-max-bitrate"
flag in the session description.
-
-
manualGetUserMedia
{Boolean} OptionalThe flag if
joinRoom()
should triggermediaAccessRequired
event in which thegetUserMedia()
Stream orshareScreen()
Stream must be retrieved as a requirement before Room session may begin. This ignores theoptions.audio
andoptions.video
configuration. After 30 seconds without any Stream retrieved, this results in thecallback(error, ..)
result. -
sdpSettings
{JSON} OptionalNote that this is mainly used for debugging purposes and that it is an experimental flag, so it may cause disruptions in connections or connectivity issues when toggled. Note that it might not work with MCU enabled Peer connections or break MCU enabled Peer connections.
The configuration to set the session description settings.-
connection
{JSON} OptionalThe configuration to set the session description connection settings. Note that this configuration may disable the media streaming and these settings will be enabled for MCU server Peer connection regardless of the flags configured. -
connection.audio
{Boolean} OptionalDEFAULT:true
The configuration to enable audio session description connection. -
connection.video
{Boolean} OptionalDEFAULT:true
The configuration to enable video session description connection. -
connection.data
{Boolean} OptionalDEFAULT:true
The configuration to enable Datachannel session description connection. -
direction
{JSON} OptionalThe configuration to set the session description connection direction to enable or disable uploading and downloading audio or video media streaming. Note that this configuration does not prevent RTCP packets from being sent and received. -
direction.audio
{JSON} OptionalThe configuration to set the session description connection direction for audio streaming. -
direction.audio.send
{Boolean} OptionalDEFAULT:true
The flag if uploading audio streaming should be enabled when available. -
direction.audio.receive
{Boolean} OptionalDEFAULT:true
The flag if downloading audio streaming should be enabled when available. -
direction.video
{JSON} OptionalThe configuration to set the session description connection direction for video streaming. -
direction.video.send
{Boolean} OptionalDEFAULT:true
The flag if uploading video streaming should be enabled when available. -
direction.video.receive
{Boolean} OptionalDEFAULT:true
The flag if downloading video streaming should be enabled when available.
-
-
publishOnly
{JSON | Boolean} OptionalFor MCU enabled Peer connections, defining this flag would make Peer not know other Peers presence in the Room.
The config if Peer would publish only.
For non-MCU enable Peer connections, defining this flag would cause other Peers in the Room to not to send Stream to Peer, and overrides the configoptions.sdpSettings.direction.audio.receive
value tofalse
,options.sdpSettings.direction.video.receive
value tofalse
,options.sdpSettings.direction.video.send
value totrue
andoptions.sdpSettings.direction.audio.send
value totrue
.
Note that this feature is currently is beta, and for any enquiries on enabling and its support for MCU enabled Peer connections, please contact our support portal.
How does the publish only functionality work? Imagine several Skylink instances like A1, B1, C1 and A1 opening a new instance A2 with publish only enabled with configured A1 as parent.
Parent and child will not receive each other presence and stream because they are related to each other in the same client page, hence no uploading or downloading is required. If A2 did not configure A1 as the parent, A1 will receive A2.MCU enabled room MCU disabled room Presence Stream Presence Stream A1 B1, C1 B1, C1 B1, C1 B1, C1 B1 A1, C1, A2 A1, C1, A2 A1, C1, A2 A1, C1, A2 C1 B1, C1, A2 B1, C1, A2 B1, C1, A2 B1, C1, A2 A2 B1, C1 -
parentId
{String} OptionalDeprecation Warning! This property has been deprecated. Use
The parent Peer ID to match to when Peer is connected. This is useful for identification for users connecting the Room twice simultaneously for multi-streaming. If User Peer ID matches the parent Peer ID provided from Peer, User will not be connected to Peer. Parent will not be connected to (or receive the presence of) child, so will child will not be connected to (or receive the presence of) parent.options.parentId
instead.
-
-
parentId
{String} OptionalThe parent Peer ID to match to when Peer is connected. Note that configuring this value overrides the
options.publishOnly.parentId
value. This is useful for identification for users connecting the Room twice simultaneously for multi-streaming. If User Peer ID matches the parent Peer ID provided from Peer, User will not be connected to Peer. Parent will not be connected to (or receive the presence of) child, so will child will not be connected to (or receive the presence of) parent. -
peerConnection
{JSON} OptionalNote that this is mainly used for debugging purposes, so it may cause disruptions in connections or connectivity issues when configured.
The Peer connection constraints settings.-
bundlePolicy
{String} OptionalThe Peer connection media bundle policy. - When not provided, its value isBALANCED
. [Rel: Skylink.BUNDLE_POLICY] -
rtcpMuxPolicy
{String} OptionalThe Peer connection RTP and RTCP ICE candidates mux policy. - When not provided, its value isREQUIRE
. [Rel: Skylink.RTCP_MUX_POLICY] -
iceCandidatePoolSize
{Number} OptionalDEFAULT:0
The number of ICE candidates to gather before gathering it when setting local offer / answer session description. -
certificate
{String} OptionalThe type of certificate that Peer connection should generate and use when available. - When not provided, its value isAUTO
. [Rel: Skylink.PEER_CERTIFICATE] -
disableBundle
{String} OptionalDEFAULT:false
The flag if for each Peer connection instead of bundling all media connections into 1 connection, should have all of them negotiated as different separate media connections.
-
-
autoBandwidthAdjustment
{Boolean | JSON} OptionalDEFAULT:false
Note that this is an experimental feature which may be removed or changed in the future releases. This feature is also only available for non-MCU enabled Peer connections and Edge Peer connections.
The flag if Peer connections uploading and downloading bandwidth should be automatically adjusted each time based on a specified interval. Note this would causepeerRestart
event to be triggered for each specified interval.-
interval
{Number} OptionalDEFAULT:10
The interval each time to adjust bandwidth connections in seconds. Note that the minimum value is10
. -
limitAtPercentage
{Number} OptionalDEFAULT:100
The percentage of the average bandwidth to adjust to. E.g.avgBandwidth * (limitPercentage / 100)
. -
useUploadBwOnly
{Boolean} OptionalDEFAULT:false
The flag if average bandwidth computation should only consist of the upload bandwidth.
-
-
-
callback
{Function} OptionalThe callback function fired when request has completed. Function parameters signature is
function (error, success)
Function request completion is determined by thepeerJoined
event triggeringisSelf
parameter payload value astrue
for request success.-
error
{JSON}The error result in request. Defined as
null
when there are no errors in request-
error
{Error}The error received when starting Room session has failed. -
errorCode
{Number} OptionalThe currentinit()
method ready state. Defined asnull
when noinit()
method has not been called due to invalid configuration. [Rel: Skylink.READY_STATE_CHANGE] -
room
{String}The Room name.
-
-
success
{JSON}The success result in request. Defined as
null
when there are errors in request-
room
{String}The Room name. -
peerId
{String}The User's Room session Peer ID. -
peerInfo
{JSON}The User's current Room session information. Object signature matches thepeerInfo
parameter payload received in thepeerJoined
event.
-
-
leaveRoom
[stopMediaOptions=true]
,
[callback]
,
)
Note that this method will close any existing socket channel connection despite not being in the Room.Function that stops Room session.
Events Sequence:
- If Socket connection is opened:
channelClose
event triggers.
- Checks if User is in Room.
- If User is not in a Room:
- ABORT and return error.
- Else:
- If parameter
stopMediaOptions.userMedia
value istrue
:- Invoke
stopStream()
method. Regardless of request errors,leaveRoom()
will still proceed.
- Invoke
- If parameter
stopMediaOptions.screenshare
value istrue
:- Invoke
stopScreen()
method. Regardless of request errors,leaveRoom()
will still proceed.
- Invoke
peerLeft
event triggers for User and all connected Peers in Room.- If MCU is enabled for the App Key provided in
init()
method and connected:serverPeerLeft
event triggers parameter payloadserverPeerType
asMCU
.
- If parameter
- If User is not in a Room:
Parameters:
-
stopMediaOptions
{Boolean | JSON} OptionalDEFAULT:true
The flag if
leaveRoom()
should stop bothshareScreen()
Stream andgetUserMedia()
Stream.- When provided as a boolean, this sets both
stopMediaOptions.userMedia
andstopMediaOptions.screenshare
to its boolean value.
-
userMedia
{Boolean} OptionalDEFAULT:true
The flag if
leaveRoom()
should stopgetUserMedia()
Stream. This invokesstopStream()
method. -
screenshare
{Boolean} OptionalDEFAULT:true
The flag if
leaveRoom()
should stopshareScreen()
Stream. This invokesstopScreen()
method.
- When provided as a boolean, this sets both
-
callback
{Function} OptionalThe callback function fired when request has completed. Function parameters signature is
function (error, success)
Function request completion is determined by thepeerLeft
event triggeringisSelf
parameter payload value astrue
for request success.-
error
{Error | String}The error result in request. Defined as
null
when there are no errors in request Object signature is theleaveRoom()
error when stopping Room session. -
success
{JSON}The success result in request. Defined as
null
when there are errors in request-
peerId
{String}The User's Room session Peer ID. -
previousRoom
{String}The Room name.
-
-
lockRoom
()
Note that broadcasted events fromFunction that locks the current Room when in session to prevent other Peers from joining the Room.muteStream()
method,stopStream()
method,stopScreen()
method,sendMessage()
method,unlockRoom()
method andlockRoom()
method may be queued when sent within less than an interval.
Events Sequence:
- Requests to Signaling server to lock Room
roomLock
event triggers parameter payloadisLocked
value astrue
.
muteStream
options
,
)
Note that broadcasted events fromFunction that mutes bothmuteStream()
method,stopStream()
method,stopScreen()
method,sendMessage()
method,unlockRoom()
method andlockRoom()
method may be queued when sent within less than an interval.
getUserMedia()
Stream and
shareScreen()
Stream audio or video tracks.
Example:
// Example 1: Mute both audio and video tracks in all Streams skylinkDemo.muteStream({ audioMuted: true, videoMuted: true });
// Example 2: Mute only audio tracks in all Streams skylinkDemo.muteStream({ audioMuted: true, videoMuted: false });
// Example 3: Mute only video tracks in all Streams skylinkDemo.muteStream({ audioMuted: false, videoMuted: true });
Events Sequence:
- If provided parameter
options
is invalid:- ABORT and return error.
- Checks if there is any available Streams:
- If there is no available Streams:
- ABORT and return error.
- If User is in Room:
- Checks if there is audio tracks to mute / unmute:
- If there is audio tracks to mute / unmute:
- If
options.audioMuted
value is not the same as the currentpeerInfo.mediaStatus.audioMuted
: This can be retrieved withgetPeerInfo()
method.- For Peer only
peerUpdated
event triggers with parameter payloadisSelf
value asfalse
. - For Peer only
streamMuted
event triggers with parameter payloadisSelf
value asfalse
.
- For Peer only
- If
- If there is audio tracks to mute / unmute:
- Checks if there is video tracks to mute / unmute:
- If there is video tracks to mute / unmute:
- If
options.videoMuted
value is not the same as the currentpeerInfo.mediaStatus.videoMuted
: This can be retrieved withgetPeerInfo()
method.- For Peer only
peerUpdated
event triggers with parameter payloadisSelf
value asfalse
. - For Peer only
streamMuted
event triggers with parameter payloadisSelf
value asfalse
.
- For Peer only
- If
- If there is video tracks to mute / unmute:
- Checks if there is audio tracks to mute / unmute:
- If
options.audioMuted
value is not the same as the currentpeerInfo.mediaStatus.audioMuted
oroptions.videoMuted
value is not the same as the currentpeerInfo.mediaStatus.videoMuted
:localMediaMuted
event triggers.- If User is in Room:
streamMuted
event triggers with parameter payloadisSelf
value astrue
.peerUpdated
event triggers with parameter payloadisSelf
value astrue
.
- If there is no available Streams:
Parameters:
-
options
{JSON}The Streams muting options.
-
audioMuted
{Boolean} OptionalDEFAULT:true
The flag if all Streams audio tracks should be muted or not.
-
videoMuted
{Boolean} OptionalDEFAULT:true
The flag if all Strea.ms video tracks should be muted or not.
-
off
[eventName]
,
[callback]
,
)
Function that unsubscribes listeners from an event.
Example:
// Example 1: Unsubscribe all "peerJoined" event skylinkDemo.off("peerJoined");
// Example 2: Unsubscribe only one listener from "peerJoined event" var pJListener = function (peerId, peerInfo, isSelf) { console.info("peerJoined event has been triggered with:", peerId, peerInfo, isSelf); };
skylinkDemo.off("peerJoined", pJListener);
Events Sequence:
There is no event sequence for this method.Parameters:
-
eventName
{String} OptionalThe event.
- When not provided, all listeners to all events will be unsubscribed.
-
callback
{Function} OptionalThe listener to unsubscribe.
- When not provided, all listeners associated to the event will be unsubscribed.
on
eventName
,
callback
,
)
Function that subscribes a listener to an event.
Example:
// Example 1: Subscribing to "peerJoined" event skylinkDemo.on("peerJoined", function (peerId, peerInfo, isSelf) { console.info("peerJoined event has been triggered with:", peerId, peerInfo, isSelf); });
Events Sequence:
There is no event sequence for this method.Parameters:
-
eventName
{String}The event.
-
callback
{Function}The listener. This will be invoked when event is triggered.
once
eventName
,
callback
,
[condition]
,
[fireAlways=false]
,
)
Function that subscribes a listener to an event once.
Example:
// Example 1: Subscribing to "peerJoined" event that triggers without condition skylinkDemo.once("peerJoined", function (peerId, peerInfo, isSelf) { console.info("peerJoined event has been triggered once with:", peerId, peerInfo, isSelf); });
// Example 2: Subscribing to "incomingStream" event that triggers with condition skylinkDemo.once("incomingStream", function (peerId, stream, isSelf, peerInfo) { console.info("incomingStream event has been triggered with User stream:", stream); }, function (peerId, peerInfo, isSelf) { return isSelf; });
// Example 3: Subscribing to "dataTransferState" event that triggers always only when condition is satisfied skylinkDemo.once("dataTransferState", function (state, transferId, peerId, transferInfo) { console.info("Received data transfer from Peer:", transferInfo.data); }, function (state, transferId, peerId) { if (state === skylinkDemo.DATA_TRANSFER_STATE.UPLOAD_REQUEST) { skylinkDemo.acceptDataTransfer(peerId, transferId); } return state === skylinkDemo.DATA_TRANSFER_STATE.DOWNLOAD_COMPLETED; }, true);
Events Sequence:
There is no event sequence for this method.Parameters:
-
eventName
{String}The event.
-
callback
{Function}The listener. This will be invoked once when event is triggered and conditional function is satisfied.
-
condition
{Function} OptionalThe conditional function that will be invoked when event is triggered. Return
true
when invoked to satisfy condition. When not provided, the conditional function will always returntrue
. -
fireAlways
{Boolean} OptionalDEFAULT:false
The flag that indicates if
once()
should act likeon()
but only invoke listener only when conditional function is satisfied.
refreshConnection
[targetPeerId]
,
[iceRestart=false]
,
[options]
,
[callback]
,
)
Note that Edge browser does not support renegotiation. For MCU enabled Peer connections withFunction that refreshes Peer connections to update with the current streaming.options.mcuUseRenegoRestart
set tofalse
in theinit()
method, the restart functionality may differ, you may learn more about how to workaround it in this article here. For restarts with Peers connecting from Android, iOS or C++ SDKs, restarts might not work as written in in this article here. Note that this functionality should be used when Peer connection stream freezes during a connection. For a better user experience for only MCU enabled Peer connections, the functionality is throttled when invoked many times in less than the milliseconds interval configured in theinit()
method.
Example:
// Example 1: Refreshing a Peer connection function refreshFrozenVideoStream (peerId) { skylinkDemo.refreshConnection(peerId, function (error, success) { if (error) return; console.log("Refreshing connection for '" + peerId + "'"); }); }
// Example 2: Refreshing a list of Peer connections function refreshFrozenVideoStreamGroup (peerIdA, peerIdB) { skylinkDemo.refreshConnection([peerIdA, peerIdB], function (error, success) { if (error) { if (error.transferErrors[peerIdA]) { console.error("Failed refreshing connection for '" + peerIdA + "'"); } else { console.log("Refreshing connection for '" + peerIdA + "'"); } if (error.transferErrors[peerIdB]) { console.error("Failed refreshing connection for '" + peerIdB + "'"); } else { console.log("Refreshing connection for '" + peerIdB + "'"); } } else { console.log("Refreshing connection for '" + peerIdA + "' and '" + peerIdB + "'"); } }); }
// Example 3: Refreshing all Peer connections function refreshFrozenVideoStreamAll () { skylinkDemo.refreshConnection(function (error, success) { if (error) { for (var i = 0; i < error.listOfPeers.length; i++) { if (error.refreshErrors[error.listOfPeers[i]]) { console.error("Failed refreshing connection for '" + error.listOfPeers[i] + "'"); } else { console.info("Refreshing connection for '" + error.listOfPeers[i] + "'"); } } } else { console.log("Refreshing connection for all Peers", success.listOfPeers); } }); }
// Example 4: Refresh Peer connection when ICE connection has failed or disconnected // and do a ICE connection refresh (only for non-MCU case) skylinkDemo.on("iceConnectionState", function (state, peerId) { if (!usesMCUKey && [skylinkDemo.ICE_CONNECTION_STATE.FAILED, skylinkDemo.ICE_CONNECTION_STATE.DISCONNECTED].indexOf(state) > -1) { skylinkDemo.refreshConnection(peerId, true); } });
Events Sequence:
- Checks if MCU is enabled for App Key provided in
init()
method- If MCU is enabled:
- If there are connected Peers in the Room:
peerRestart
event triggers parameter payloadisSelfInitiateRestart
value astrue
for all connected Peer connections.serverPeerRestart
event triggers for connected MCU server Peer connection.
- If
options.mcuUseRenegoRestart
value isfalse
set in theinit()
method:-
Invokes
joinRoom()
methodrefreshConnection()
will retain the User session information except the Peer ID will be a different assigned ID due to restarting the Room session.- If request has errors
- ABORT and return error.
- If request has errors
-
Invokes
- If there are connected Peers in the Room:
- Else:
- If there are connected Peers in the Room:
- Refresh connections for all targeted Peers.
- If Peer connection exists:
peerRestart
event triggers parameter payloadisSelfInitiateRestart
value astrue
for all targeted Peer connections.
- Else:
- ABORT and return error.
- If Peer connection exists:
- Refresh connections for all targeted Peers.
- If there are connected Peers in the Room:
- If MCU is enabled:
Parameters:
-
targetPeerId
{String | Array} OptionalNote that this is ignored if MCU is enabled for the App Key provided in
The target Peer ID to refresh connection with.init()
method.refreshConnection()
will "refresh" all Peer connections. See the Event Sequence for more information.- When provided as an Array, it will refresh all connections with all the Peer IDs provided.
- When not provided, it will refresh all the currently connected Peers in the Room.
-
iceRestart
{Boolean} OptionalDEFAULT:false
Note that this flag will not be honoured for MCU enabled Peer connections where
The flag if ICE connections should restart when refreshing Peer connections. This is used when ICE connection state isoptions.mcuUseRenegoRestart
flag is set tofalse
as it is not necessary since for MCU "restart" case is to invokejoinRoom()
method again, or that it is not supported by the MCU.FAILED
orDISCONNECTED
, which state can be retrieved with theiceConnectionState
event. -
options
{JSON} OptionalNote that for MCU connections, the
The custom Peer configuration settings.bandwidth
orgoogleXBandwidth
settings will override for all Peers or the current Room connection session settings.-
bandwidth
{JSON} OptionalThe configuration to set the maximum streaming bandwidth to send to Peers. Object signature follows
joinRoom()
methodoptions.bandwidth
settings. -
googleXBandwidth
{JSON} OptionalThe configuration to set the experimental google video streaming bandwidth sent to Peers. Object signature follows
joinRoom()
methodoptions.googleXBandwidth
settings.
-
-
callback
{Function} OptionalThe callback function fired when request has completed. Function parameters signature is
function (error, success)
Function request completion is determined by thepeerRestart
event triggeringisSelfInitiateRestart
parameter payload value astrue
for all Peers targeted for request success.-
error
{JSON}The error result in request. Defined as
null
when there are no errors in request-
listOfPeers
{Array}The list of Peer IDs targeted. -
refreshErrors
{JSON}The list of Peer connection refresh errors. -
refreshErrors.#peerId
{Error | String}The Peer connection refresh error associated with the Peer ID defined in#peerId
property. If#peerId
value is"self"
, it means that it is the error when there is no Peer connections to refresh with. -
refreshSettings
{JSON}The list of Peer connection refresh settings. -
refreshSettings.#peerId
{JSON}The Peer connection refresh settings associated with the Peer ID defined in#peerId
property. -
refreshSettings.#peerId.iceRestart
{Boolean}The flag if ICE restart is enabled for this Peer connection refresh session. -
refreshSettings.#peerId.customSettings
{JSON}The Peer connection custom settings. Object signature followsgetPeersCustomSettings
method returned per#peerId
object.
-
-
success
{JSON}The success result in request. Defined as
null
when there are errors in request-
listOfPeers
{Array}The list of Peer IDs targeted. -
refreshSettings
{JSON}The list of Peer connection refresh settings. -
refreshSettings.#peerId
{JSON}The Peer connection refresh settings associated with the Peer ID defined in#peerId
property. -
refreshSettings.#peerId.iceRestart
{Boolean}The flag if ICE restart is enabled for this Peer connection refresh session. -
refreshSettings.#peerId.customSettings
{JSON}The Peer connection custom settings. Object signature followsgetPeersCustomSettings
method returned per#peerId
object.
-
-
refreshDatachannel
[peerId]
,
)
Function that refreshes the main messaging Datachannel.
Example:
// Example 1: Retrieve offerer and refresh datachannel: skylink.on("dataChannelState", function (state, peerId, error, channelName, channelType) { if (channelType === skylink.DATA_CHANNEL_TYPE.MESSAGING && state === skylink.DATA_CHANNEL_STATE.CLOSED) { var userWeight = skylink.getPeerInfo().config.priorityWeight; var peerWeight = skylink.getPeerInfo(peerId).config.priorityWeight; // Determine who is offerer because as per SM protocol, higher weight is offerer if (userWeight > peerWeight) { skylink.refreshDatachannel(peerId); } } });
Events Sequence:
There is no event sequence for this method.Parameters:
-
peerId
{String} OptionalThe target Peer ID to retrieve connection stats from.
sendBlobData
data
,
[timeout=60]
,
[targetPeerId]
,
[sendChunksAsBinary=false]
,
[callback]
,
)
Function that starts an uploading data transfer from User to Peers.
Example:
<body> <input type="radio" name="timeout" onchange="setTransferTimeout(0)"> 1s timeout (Default) <input type="radio" name="timeout" onchange="setTransferTimeout(120)"> 2s timeout <input type="radio" name="timeout" onchange="setTransferTimeout(300)"> 5s timeout <hr> <input type="file" onchange="uploadFile(this.files[0], this.getAttribute('data'))" data="peerId"> <input type="file" onchange="uploadFileGroup(this.files[0], this.getAttribute('data').split(',')))" data="peerIdA,peerIdB"> <input type="file" onchange="uploadFileAll(this.files[0])" data=""> <script> var transferTimeout = 0;
function setTransferTimeout (timeout) { transferTimeout = timeout; }
// Example 1: Upload data to a Peer function uploadFile (file, peerId) { var cb = function (error, success) { if (error) return; console.info("File has been transferred to '" + peerId + "' successfully"); }; if (transferTimeout > 0) { skylinkDemo.sendBlobData(file, peerId, transferTimeout, cb); } else { skylinkDemo.sendBlobData(file, peerId, cb); } }
// Example 2: Upload data to a list of Peers function uploadFileGroup (file, peerIds) { var cb = function (error, success) { var listOfPeers = error ? error.listOfPeers : success.listOfPeers; var listOfPeersErrors = error ? error.transferErrors : {}; for (var i = 0; i < listOfPeers.length; i++) { if (listOfPeersErrors[listOfPeers[i]]) { console.error("Failed file transfer to '" + listOfPeers[i] + "'"); } else { console.info("File has been transferred to '" + listOfPeers[i] + "' successfully"); } } }; if (transferTimeout > 0) { skylinkDemo.sendBlobData(file, peerIds, transferTimeout, cb); } else { skylinkDemo.sendBlobData(file, peerIds, cb); } }