Skylink Class
Defined in: source/template/header.js:109
Available since 0.5.0
Before using Skylink
Please invoke init() method first to initialise the Application Key before using any functionalities in Skylink.If you do not have an Application Key, you may register for a Skylink platform developer account to create one.
To get started you may visit the getting started page, or alternatively fork a ready made demo application that uses Skylink Web SDK at getaroom.io.
For tips on using skylink and troubleshooting you can visit our support portal.
Skylink
()
Example:
// Here's a simple example on how you can start using Skylink var SkylinkDemo = new Skylink();
// Subscribe all events first before init() 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."); } } });
// never call joinRoom in readyStateChange event subscription. // call joinRoom after init() callback if you want to joinRoom instantly. SkylinkDemo.on("readyStateChange", function (state, room) { console.log("Room (" + room + ") state: ", room); })
// always remember to call init() SkylinkDemo.init("YOUR_APP_KEY_HERE", function (error, success) { // do a check for error or success if (error) { console.error("Init failed: ", error); } else { SkylinkDemo.joinRoom("my_room", { userData: "My Username", audio: true, video: true }); } });
_ACKProtocolHandler
peerId
,
data
,
channelName
,
)
Handles the ACK Protocol request received from the DataChannel connection.
Triggers:
dataTransferStateParameters:
-
peerId
{String}The Peer ID associated with the DataChannel connection.
-
data
{JSON}The data object received from the DataChannel connection. This should contain the
ACK
payload.-
ackN
{Number}The ACK response of the current data transfer. If
0
, it means that the request has been accepted and the sending Peer has to send the first data transfer packet (chunk). If it's greater than0
, it means that the previous data transfer packet (chunk) has been received and is expecting for the next data transfer packet. The number always increment based on the number of data packets the receiving end has received. If it's-1
, it means that the data transfer request has been rejected and the data transfer will be terminated. -
sender
{String}The Peer ID of sender.
-
type
{String}Protocol step
"ACK"
.
-
-
channelName
{String}The DataChannel connection ID associated with the transfer.
_addIceCandidateFromQueue
targetMid
,
)
Adds the list of ICE candidates bufferred before RTCPeerConnection.setRemoteDescription
is called associated with the Peer connection.
Parameters:
-
targetMid
{String}The Peer ID to add the associated bufferred ICE candidates.
_addIceCandidateToQueue
targetMid
,
candidate
,
)
Buffers an ICE candidate object associated with a Peer connection
to prevent disruption to ICE connection when ICE candidate
is received before RTCPeerConnection.setRemoteDescription
is called.
Parameters:
-
targetMid
{String}The Peer ID associated with the ICE candidate object.
-
candidate
{Object}The constructed ICE candidate object.
_addLocalMediaStreams
peerId
,
)
Sends self selected Stream object to current Peer connections. If _mediaScreen is not empty, it will send the screensharing stream, else it will send the _mediaStream if is not empty. If self does not have any Stream object to send, it will a connection without any remote Stream sent to the Peer connection.
Parameters:
-
peerId
{String}The Peer ID of the connection to send Stream object to.
_addPeer
targetMid
,
peerBrowser
,
[toOffer=false]
,
[restartConn=false]
,
[receiveOnly=false]
,
[isSS=false]
,
)
Connects to the Peer.
Parameters:
-
targetMid
{String}The Peer ID to connect to.
-
peerBrowser
{JSON}The Peer platform agent information.
-
agent
{String}The Peer platform browser or agent name.
-
version
{Number}The Peer platform browser or agent version.
-
os
{Number}The Peer platform name.
-
-
toOffer
{Boolean} OptionalDEFAULT: falseThe flag that indicates if the Peer connection should be start connection as an offerer or as an answerer.
-
restartConn
{Boolean} OptionalDEFAULT: falseThe flag that indicates if the Peer connection is part of restart functionality use-case.
-
receiveOnly
{Boolean} OptionalDEFAULT: falseThe flag that indicates if the Peer connection would send Stream or not (receive only).
-
isSS
{Boolean} OptionalDEFAULT: falseThe flag that indicates if the Peer connection Stream sent is a screensharing stream or not.
_addSDPStereo
sdpLines
,
)
Modifies the array of session description received to enable stereo in the audio streaming connection.
Parameters:
-
sdpLines
{Array}The array of lines in the session description.
Returns:
The updated array of lines in the session description with the stereo feature.
_answerHandler
message
,
)
Handles the ANSWER Protocol message event received from the platform signaling.
Triggers:
handshakeProgressParameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
ANSWER
payload.-
rid
{String}The room ID for identification to the platform signaling connection.
-
sdp
{String}The generated answer session description.
-
mid
{String}The Peer ID associated with this message.
-
target
{String}The targeted Peer ID to receive the message object.
-
type
{String}Protocol step
"answer"
.
-
_approachEventHandler
message
,
)
Handles the APPROACH message event received from the platform signaling.
Parameters:
-
message
{JSON}The message object received from platform signaling.
-
type
{String}Protocol step
"approach"
. -
target
{Object}The peer to initiate the handshake to
-
_assembleDataURL
dataURLArray
,
)
Assembles the data string chunks of a chunked dataURL binary string (base64) into the original dataURL binary string (base64).
Parameters:
-
dataURLArray
{Array}The array of chunked dataURL binary strings (base64) based on the dataURL string provided.
Returns:
The original huge dataURL binary string (base64).
_base64ToBlob
dataURL
,
)
Converts a binary string (base64) derived from
dataURL conversion
to a Blob data object.
Author<EMAIL_ADDRESS>#6850276
Parameters:
-
dataURL
{String}The binary string (base64) to convert.
Returns:
The converted Blob data object.
_blobToBase64
data
,
callback
,
)
Converts a Blob data object into a binary string (base64) using dataURL conversion
Parameters:
-
data
{Blob}The Blob data object to convert.
-
callback
{Function}The callback triggered when Blob data conversion to binary string (base64) has completed.
-
data
{String}The converted binary string (base64).
-
_byeHandler
message
,
)
Handles the BYE Protocol message event received from the platform signaling.
Triggers:
peerLeftParameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
BYE
payload.-
rid
{String}The room ID for identification to the platform signaling connection.
-
mid
{String}The Peer ID associated with this message.
-
type
{String}Protocol step
"bye"
.
-
_CANCELProtocolHandler
senderPeerId
,
data
,
channelName
,
)
Handles the CANCEL Protocol request received from the DataChannel connection.
Triggers:
dataTransferStateParameters:
-
senderPeerId
{String}The Peer ID associated with the DataChannel connection.
-
data
{JSON}The data object received from the DataChannel connection. This should contain the
CANCEL
payload.-
name
{String}The transfer data object name.
-
content
{String}The reason for termination as a message.
-
sender
{String}The Peer ID of the sender.
-
type
{String}Protocol step
"CANCEL"
.
-
-
channelName
{String}The DataChannel connection ID associated with the transfer.
_candidateHandler
message
,
)
Handles the CANDIDATE Protocol message event received from the platform signaling.
Parameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
CANDIDATE
payload.-
rid
{String}The room ID for identification to the platform signaling connection.
-
mid
{String}The Peer ID associated with this message.
-
id
{String}The ICE candidate identifier of the "media stream identification" for the m-line this candidate is associated with if present. The value is retrieved from
RTCIceCandidate.sdpMid
. -
label
{String}The ICE candidate index (starting at zero) of the m-line in the SDP this candidate is associated with. The value is retrieved from
RTCIceCandidate.sdpMLineIndex
. -
candidate
{String}The ICE candidate candidate-attribute. The value is retrieved from
RTCIceCandidate.candidate
. -
target
{String}The targeted Peer ID to receive the message object.
-
type
{String}Protocol step:
"candidate"
.
-
_chunkBlobData
blob
,
chunkSize
,
)
Chunks a huge Blob data object into smaller Blob data object chunks
based on the chunk sizes provided.
If provided Blob data object is smaller than chunk sizes, it will return an array
length of 1
with the Blob data object.
Parameters:
-
blob
{Blob}The huge Blob binary data object.
-
chunkSize
{Number}The chunk size that the Blob binary data should be cut into.
Returns:
The array of chunked Blob data objects based on the Blob data object provided.
_chunkDataURL
dataURL
,
chunkSize
,
)
Chunks a huge dataURL binary string (base64)
into smaller strings based on the chunk length provided.
If provided dataURL binary string (base64)
is smaller than chunk length, it will return an array
length of 1
with the dataURL string.
Parameters:
-
dataURL
{String}The huge dataURL binary string (base64).
-
chunkSize
{Number}The string (chunk) length that the dataURL binary string (base64) should be cut into.
Returns:
The array of chunked dataURL binary strings (base64) based on the dataURL string provided.
_clearAllStoredLogsFn
[logLevel]
,
)
Clears the stored Skylink console logs in _storedLogs.
Parameters:
-
logLevel
{Number} OptionalThe specific log level of Skylink console logs that should be cleared. If value is not provided, it will clear all stored console logs. [Rel: Skylink.LOG_LEVEL]
_clearDataChannelTimeout
peerId
,
[isSender=false]
,
channelName
,
)
Stops and clears the waitig timeout for the associated DataChannel connection.
Parameters:
-
peerId
{String}The Peer ID associated with the DataChannel connection.
-
isSender
{Boolean} OptionalDEFAULT: falseThe flag thats indicates if the response is related to a downloading or uploading data transfer.
-
channelName
{String}The DataChannel connection ID.
_closeChannel
()
Disconnects the current socket connection with the platform signaling.
_closeDataChannel
peerId
,
[channelName]
,
)
Stops DataChannel connections associated with a Peer connection and remove any object references to the DataChannel connection(s).
Triggers:
dataChannelStateParameters:
-
peerId
{String}The Peer ID associated with the DataChannel connection(s) to close.
-
channelName
{String} OptionalThe targeted DataChannel
channelName
to close the connection with. IfchannelName
is not provided, all associated DataChannel connections with the Peer connection would be closed.
_condition
eventName
,
callback
,
[checkFirst]
,
[condition]
,
[fireAlways=false]
,
)
Checks if the first condition is already met before doing an event
handler subscription to wait for the second condition to be met.
This method will do a event subscription with
once() as this
_condition()
would only trigger once, unless fireAlways
is set to true
.
Parameters:
-
eventName
{String}The Skylink event name to subscribe to.
-
callback
{Function}The event handler to subscribe to the associated Skylink event name to trigger once the condition has met. If
fireAlways
option is set totrue
, this will always be fired when condition is met. -
checkFirst
{Function} OptionalThe first condition to check before doing an event subscription to wait for second condition to meet. Return in the first condition function
true
to pass as meeting the condition. If the first condition is met, the event handler would be triggered and the event handler will not be subscribed to the event or wait for second condition to pass. -
condition
{Function} OptionalThe second condition function that once the it has been met, it will trigger the event handler once. Return in the second condition function
true
to pass as meeting the condition. If the second condition is met, the event handler would be triggered and depending iffireAlways
option is set totrue
, this will always be fired when condition is met. -
fireAlways
{Boolean} OptionalDEFAULT: falseThe flag that indicates if Skylink should interrupt the second condition function once the function has been triggered to not unsubscribe the event handler but to always trigger when the second condition has been met.
_createDataChannel
peerId
,
channelType
,
[dataChannel]
,
customChannelName
,
)
Starts a DataChannel connection with a Peer connection. If the DataChannel is provided in the parameter, it simply appends event handlers to check the current state of the DataChannel.
Triggers:
dataChannelStateParameters:
-
peerId
{String}The Peer ID to start the DataChannel with or associate the provided DataChannel object connection with.
-
channelType
{String}The DataChannel functionality type. [Rel: Skylink.DATA_CHANNEL_TYPE]
-
dataChannel
{Object} OptionalThe RTCDataChannel object received in the Peer connection
.ondatachannel
event. -
customChannelName
{String}The custom RTCDataChannel label name to identify the different opened channels.
Returns:
The DataChannel connection object associated with the provided Peer ID.
_createPeerConnection
targetMid
,
[isScreenSharing=false]
,
)
Creates a Peer connection. This does not start the handshake connection but creates the Peer connection object ready for connection.
Parameters:
-
targetMid
{String}The Peer ID to create the connection object with.
-
isScreenSharing
{Boolean} OptionalDEFAULT: falseThe flag that indicates if the Peer connection Stream sent is a screensharing stream or not.
Returns:
The Peer connection object associated with the provided ID.
_createSocket
type
,
)
Starts a socket.io connection with the platform signaling.
Parameters:
-
type
{String}The transport type of socket.io connection to use.
"WebSocket"
: Uses the WebSocket connection.
options.transports = ["websocket"]
"Polling"
: Uses the Polling connection.
options.transports = ["xhr-polling", "jsonp-polling", "polling"]
_dataChannelProtocolHandler
data
,
senderPeerId
,
channelName
,
channelType
,
)
Routes the data received to the relevant Protocol handler based on the data received.
Parameters:
-
data
{String | Object}The data received from the DataChannel connection.
-
senderPeerId
{String}The Peer ID associated with the DataChannel connection.
-
channelName
{String}The DataChannel connection ID.
-
channelType
{String}The DataChannel connection functionality type. [Rel: Skylink.DATA_CHANNEL_TYPE]
_DATAProtocolHandler
senderPeerId
,
dataString
,
dataType
,
channelName
,
)
Handles the DATA Protocol request received from the DataChannel connection. In this handler, it actually handles and manipulates the received data transfer packet.
Triggers:
dataTransferStateParameters:
-
senderPeerId
{String}The Peer ID associated with the DataChannel connection.
-
dataString
{ArrayBuffer | Blob | String}The data transfer packet (chunk) received.
-
dataType
{String}The data transfer packet (chunk) data type received. [Rel: Skylink.DATA_TRANSFER_DATA_TYPE]
-
channelName
{String}The DataChannel connection ID associated with the transfer.
_doAnswer
targetMid
,
)
Responses to the OFFER
session description received and
creates an ANSWER
session description to sent
to the associated Peer to complete the WebRTC handshake layer.
Parameters:
-
targetMid
{String}The Peer ID to send the
ANSWER
to.
_doOffer
targetMid
,
peerBrowser
,
)
Starts to initiate the WebRTC layer of handshake connection by
creating the OFFER
session description and then
sending it to the associated Peer.
The offerer status may be shifted to the other peer depending on
when version of browser that is initiating the connection
to what version of browser to.
Parameters:
-
targetMid
{String}The Peer ID to send the
OFFER
to. -
peerBrowser
{JSON}The Peer platform agent information.
-
name
{String}The Peer platform browser or agent name.
-
version
{Number}The Peer platform browser or agent version.
-
os
{Number}The Peer platform name.
-
_enterHandler
message
,
)
Handles the ENTER Protocol message event received from the platform signaling.
Triggers:
handshakeProgress, peerJoinedParameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
ENTER
payload.-
rid
{String}The room ID for identification to the platform signaling connection.
-
mid
{String}The Peer ID associated with this message.
-
receiveOnly
{Boolean} OptionalDEFAULT: falseThe flag that indicates if the Peer connection would send Stream or not (receive only).
-
userInfo
{JSON}The peer information associated with the Peer Connection.
-
userData
{String | JSON}The custom user data information set by developer. This custom user data can also be set in setUserData(). -
settings
{JSON}The Peer Stream streaming settings information. If both audio and video option isfalse
, there should be no receiving remote Stream object from this associated Peer. -
settings.audio
{Boolean | JSON} OptionalDEFAULT: false The Peer Stream streaming audio settings. Iffalse
, it means that audio streaming is disabled in the remote Stream of the Peer. -
settings.audio.stereo
{Boolean} OptionalThe flag that indicates if stereo should be enabled in the Peer connection Stream audio streaming. -
settings.video
{Boolean | JSON} OptionalDEFAULT: false The Peer Stream streaming video settings. Iffalse
, it means that video streaming is disabled in the remote Stream of the Peer. -
settings.video.resolution
{JSON} OptionalThe Peer Stream streaming video resolution settings. Setting the resolution may not force set the resolution provided as it depends on the how the browser handles the resolution. [Rel: Skylink.VIDEO_RESOLUTION] -
settings.video.resolution.width
{Number} OptionalThe Peer Stream streaming video resolution width. -
settings.video.resolution.height
{Number} OptionalThe Peer Stream streaming video resolution height. -
settings.video.frameRate
{Number} OptionalThe Peer Stream streaming video maximum frameRate. -
settings.video.screenshare
{Boolean} OptionalDEFAULT: false The flag that indicates if the Peer connection Stream object sent is a screensharing stream or not. -
settings.bandwidth
{String} OptionalThe Peer streaming bandwidth settings. Setting the bandwidth flags may not force set the bandwidth for each connection stream channels as it depends on how the browser handles the bandwidth bitrate. Values are configured in kb/s. -
settings.bandwidth.audio
{String} OptionalThe configured audio stream channel for the remote Stream object bandwidth that audio streaming should use in kb/s. -
settings.bandwidth.video
{String} OptionalThe configured video stream channel for the remote Stream object bandwidth that video streaming should use in kb/s. -
settings.bandwidth.data
{String} OptionalThe configured datachannel channel for the DataChannel connection bandwidth that datachannel connection per packet should be able use in kb/s. -
mediaStatus
{JSON}The Peer Stream mute settings for both audio and video streamings. -
mediaStatus.audioMuted
{Boolean} OptionalDEFAULT: true The flag that indicates if the remote Stream object audio streaming is muted. If there is no audio streaming enabled for the Peer, by default, it is set totrue
. -
mediaStatus.videoMuted
{Boolean} OptionalDEFAULT: true The flag that indicates if the remote Stream object video streaming is muted. If there is no video streaming enabled for the Peer, by default, it is set totrue
.
-
-
agent.name
{String}The Peer platform browser or agent name.
-
version
{Number}The Peer platform browser or agent version.
-
os
{Number}The Peer platform name.
-
sessionType
{String}The Peer connection remote Stream streaming session type. If value is
"stream"
, the Stream streaming session is normal user media streaming, else if it is"screensharing"
, the Stream streaming session is screensharing session. -
type
{String}Protocol step
"enter"
.
-
_ERRORProtocolHandler
senderPeerId
,
data
,
channelName
,
)
Handles the ERROR Protocol request received from the DataChannel connection.
Triggers:
dataTransferStateParameters:
-
senderPeerId
{String}The Peer ID associated with the DataChannel connection.
-
data
{JSON}The data object received from the DataChannel connection. This should contain the
ERROR
payload.-
name
{String}The transfer data object name.
-
content
{String}The error message.
-
isUploadError
{Boolean} OptionalDEFAULT: falseThe flag thats indicates if the response is related to a downloading or uploading data transfer.
-
sender
{String}The Peer ID of the sender.
-
type
{String}Protocol step
"ERROR"
.
-
-
channelName
{String}The DataChannel connection ID associated with the transfer.
_getStoredLogsFn
[logLevel]
,
)
Gets the stored Skylink console logs from _storedLogs.
Parameters:
-
logLevel
{Number} OptionalThe specific log level of Skylink console logs that should be returned. If value is not provided, it will return all stored console logs. [Rel: Skylink.LOG_LEVEL]
Returns:
The array of stored console logs based on the log level provided.
_initSelectedRoom
[room]
,
callback
,
)
Starts loading the required connection information to start connection based on the selected room in joinRoom().
Triggers:
readyStateChangeParameters:
-
room
{String} OptionalThe room to retrieve required connection information to start connection. If room is not provided, the room would default to the the
defaultRoom
option set in init() settings. -
callback
{Function}The callback fired after required connection information has been retrieved successfully with the provided media settings or have met with an exception.
-
error
{Object}The error object received in the callback. If received as
null
, it means that there is no errors.
-
_inRoomHandler
message
,
message
,
)
Handles the IN_ROOM Protocol message event received from the platform signaling.
Triggers:
peerJoinedParameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
IN_ROOM
payload. -
message
{JSON}Expected IN_ROOM data object format.
-
{String}
The room ID for identification to the platform signaling connection.
-
{String}
The self session socket connection ID. This is used by the signalling socket connection as ID to target self and the peers Peer ID.
-
{JSON}
The Peer connection iceServers configuration.
-
{String}
Protocol step:
"inRoom"
.
-
_introduceErrorEventHandler
message
,
)
Handles the INTRODUCE_ERROR message event received from the platform signaling.
Parameters:
-
message
{JSON}The message object received from platform signaling.
-
type
{String}Protocol step
"introduceError"
. -
reason
{Object}The error message.
-
sendingPeerId
{Object}Id of the peer initiating the handshake
-
receivingPeerId
{Object}Id of the peer receiving the handshake
-
_loadInfo
()
Starts loading the required dependencies and then retrieve the required connection information from the platform server.
Triggers:
readyStateChange_logFn
logLevel
,
message
,
[0]
,
[debugObject]
,
)
Handles the Skylink logs and stores the console log message in
_storedLogs
if _enableDebugStack is
set to true
and prints out the log to the Web console.
Parameters:
-
logLevel
{String}The console log message log level. [Rel: Skylink.LOG_LEVEL]
-
message
{Array | String}The console log message contents.
-
1
{String}The interface the message is associated with.
-
2
{String | Array}Any additional message information that the message is associated with.
-
3:
{String}The console log message message data.
-
-
0
{String} OptionalThe Peer ID the message is associated with.
-
debugObject
{Object | String} OptionalThe console debugging message object to accompany and display that associates with the console log message.
_MESSAGEProtocolHandler
peerId
,
data
,
channelName
,
)
Handles the MESSAGE Protocol request received from the DataChannel connection.
Triggers:
incomingMessageParameters:
-
peerId
{String}The Peer ID associated with the DataChannel connection.
-
data
{JSON}The data object received from the DataChannel connection. This should contain the
MESSAGE
payload.-
target
{String}The targeted Peer ID to receive the message object.
-
data
{String | JSON}The message object.
-
sender
{String}The Peer ID of the sender.
-
type
{String}Protocol step
"MESSAGE"
.
-
-
channelName
{String}The DataChannel connection ID associated with the transfer.
_muteAudioEventHandler
message
,
)
Handles the MUTE_AUDIO Protocol message event received from the platform signaling.
Triggers:
peerUpdatedParameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
MUTE_AUDIO
payload.-
rid
{String}The room ID for identification to the platform signaling connection.
-
mid
{String}The Peer ID associated with this message.
-
muted
{Boolean}The flag that indicates if the remote Stream object audio streaming is muted.
-
type
{String}Protocol step
"muteAudioEvent"
.
-
_muteLocalMediaStreams
()
Handles the muting of audio and video streams in _mediaStream, _mediaScreen and _mediaScreenClone,
Returns:
The information of the self MediaStream object attached to Skylink if they have the specified tracks for the stream settings.
return.hasAudioTracks
: The flag that indicates if self MediaStream has audio tracksreturn.hasVideoTracks
: The flag that indicates if self MediaStream has video tracks
_muteVideoEventHandler
message
,
)
Handles the MUTE_VIDEO Protocol message event received from the platform signaling.
Triggers:
peerUpdatedParameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
MUTE_VIDEO
payload.-
rid
{String}The room ID for identification to the platform signaling connection.
-
mid
{String}The Peer ID associated with this message.
-
muted
{String}The flag that indicates if the remote Stream object video streaming is muted.
-
type
{String}Protocol step
"muteVideoEvent"
.
-
_offerHandler
message
,
)
Handles the OFFER Protocol message event received from the platform signaling.
Triggers:
handshakeProgressParameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
OFFER
payload.-
rid
{String}The room ID for identification to the platform signaling connection.
-
mid
{String}The Peer ID associated with this message.
-
sdp
{String}The generated offer session description.
-
target
{String}The targeted Peer ID to receive the message object.
-
type
{String}Protocol step
"offer"
.
-
_onAddIceCandidateFailure
error
,
)
Handles the event when adding an ICE candidate has failed. This is mainly to prevent JShint errors.
Parameters:
-
error
{Object}The error received in the failure callback in
RTCPeerConnection.addIceCandidate(candidate, successCb, failureCb)
.
_onAddIceCandidateSuccess
()
Handles the event when adding an ICE candidate has been added successfully. This is mainly to prevent JShint errors.
_onIceCandidate
targetMid
,
event
,
)
Handles the ICE candidate object received from associated Peer connection to send the ICE candidate object or wait for all gathering to complete before sending the candidate to prevent trickle ICE.
Triggers:
candidateGenerationStateParameters:
-
targetMid
{String}The Peer ID associated with the ICE candidate object received.
-
event
{Event}The event object received in the
RTCPeerConnection. onicecandidate
to parse the ICE candidate and determine if gathering has completed.
_onRemoteStreamAdded
targetMid
,
event
,
[isScreenSharing=false]
,
)
Handles the event when remote MediaStream is received from Peer connection.
Triggers:
incomingStreamParameters:
-
targetMid
{String}The Peer ID associated with the remote Stream object received.
-
event
{Event}The event object received in the
RTCPeerConnection. onaddstream
. -
isScreenSharing
{Boolean} OptionalDEFAULT: falseThe flag that indicates if Peer connection Stream object is a screensharing stream or not.
_onUserMediaError
error
,
[isScreenSharing=false]
,
[audioFallback=false]
,
)
Handles the event when access to self user media MediaStream has failed.
Triggers:
mediaAccessErrorParameters:
-
error
{Object}The error object thrown that caused the failure.
-
isScreenSharing
{Boolean} OptionalDEFAULT: falseThe flag that indicates if self Stream object is a screensharing stream or not.
-
audioFallback
{Boolean} OptionalDEFAULT: falseThe flag that indicates if stage of stream media error should do an audio fallback.
_onUserMediaSuccess
stream
,
[isScreenSharing=false]
,
)
Handles the event when access to self user media MediaStream is successful.
Triggers:
mediaAccessSuccessParameters:
-
stream
{MediaStream}The self user MediaStream object.
-
isScreenSharing
{Boolean} OptionalDEFAULT: falseThe flag that indicates if self Stream object is a screensharing stream or not.
_openChannel
()
Connects to the socket connection endpoint URI to platform signaling that is constructed with
_signalingServerProtocol,
_signalingServer and
_signalingServerPort.
Example format: protocol//serverUrl:port
.
Once URI is formed, it will start a new socket.io connection with
_createSocket().
Triggers:
channelMessage, channelOpen, channelError, channelClose_parseAudioStreamSettings
[options=false]
,
)
Parses the audio stream settings for self provided.
Parameters:
-
options
{Boolean | JSON} OptionalDEFAULT: falseThe flag that indicates if self user media MediaStream would have audio streaming.
-
mute
{Boolean} OptionalDEFAULT: falseThe flag that indicates if the self Stream object audio streaming is muted.
-
optional
{Array} OptionalThe optional constraints for audio streaming in self user media Stream object. Some of the values are set by the
audio.optional
setting in getUserMedia().
-
Returns:
The parsed audio stream settings for self.
return.settings
: The output audio stream settings information for selfreturn.userMedia
: The output audio MediaStreamConstraints to be passed into getUserMedia()
_parseBandwidthSettings
[options]
,
)
Parses the streaming bandwidth settings for self provided.
Parameters:
-
options
{String} OptionalThe self streaming bandwidth settings. Setting the bandwidth flags may not force set the bandwidth for each connection stream channels as it depends on how the browser handles the bandwidth bitrate. Values are configured in kb/s.
-
audio
{String} OptionalThe configured audio stream channel for self connection Stream object bandwidth that audio streaming should use in kb/s.
-
video
{String} OptionalThe configured video stream channel for the self connection Stream object bandwidth that video streaming should use in kb/s.
-
data
{String} OptionalThe configured datachannel channel for self DataChannel connection bandwidth that datachannel connection per packet should be able use in kb/s.
-
_parseDefaultMediaStreamSettings
defaults
,
)
Parses the default stream settings received from the platform signaling.
Parameters:
-
defaults
{JSON}The default user media settings.
-
maxHeight
{Number} OptionalThe default user media MediaStream video streaming resolution maximum height.
-
maxWidth
{Number} OptionalThe default user media MediaStream video streaming resolution maximum width.
-
_parseInfo
info
,
)
Parses the connection information retrieved from the platform server and stores them into the relevant attributes in _room and _user.
Triggers:
readyStateChangeParameters:
-
info
{JSON}The HTTP response data if the HTTP status code is
200
(which means HTTP OK code)-
pc_constraints
{String}The RTCPeerConnection constraints. The data is in JSON stringified string and requires converting the JSON string to an JSON object to use the object.
-
media_constraints
{String}The getUserMedia() MediaStreamConstraints. The data is in JSON stringified string and requires converting the JSON string to an JSON object to use the object.
-
offer_constraints
{String}The RTCPeerConnection RTCOfferOptions. The data is in JSON stringified string and requires converting the JSON string to an JSON object to use the object.
-
bandwidth
{String}The self streaming bandwidth settings. Setting the bandwidth flags may not force set the bandwidth for each connection stream channels as it depends on how the browser handles the bandwidth bitrate. Values are configured in kb/s.
-
audio
{String}The default audio stream channel for self Stream object bandwidth that audio streaming should use in kb/s. -
video
{String}The default video stream channel for self Stream object bandwidth that video streaming should use in kb/s. -
data
{String}The default datachannel channel for the DataChannel connection bandwidth that datachannel connection per packet should be able use in kb/s.
-
-
cid
{String}The Skylink server connection key for starting the selected room connection.
-
apiOwner
{String}The Skylink server Application Key owner string for the selected room.
-
httpPortList
{Array}The list of HTTP ports for reconnection retries.
-
(#index)
{Number}The HTTP port that Skylink could reattempt to establish for a signaling connection withhttp:
protocol.
-
-
httpsPortList
{Array}The list of HTTPS ports for reconnection retries.
-
(#index)
{Number}The HTTPS port that Skylink could reattempt to establish for a signaling connection withhttps:
protocol or when {{#crossLink "Skylink/_forceSSL:attribute"}}_forceSSL{{/crossLink}} is enabled.
-
-
ipSigserver
{String}The platform signaling endpoint URI to open socket connection with.
-
roomCred
{String}The generated room token given by the platform server for starting the platform signaling connection.
-
room_key
{String}For success state. The room ID for identification to the platform signaling connection.
-
start
{String}The start datetime stamp (in The startDateTime in (ISO 8601 format) that the call has started sent by the platform server as an indication for the starting datetime of the platform signaling connection to self.
-
timeStamp
{String}The self session timestamp.
-
userCred
{String}The self session access token.
-
username
{String}The self session ID.
-
_parseMediaStreamSettings
[options]
,
)
Parses the provided stream settings for self provided.
Parameters:
-
options
{JSON} OptionalThe self Stream streaming settings. If both audio and video option is
false
, there should be no audio and video stream sending from self connection.-
audio
{Boolean | JSON} OptionalDEFAULT: falseThe self Stream streaming audio settings. If
false
, it means that audio streaming is disabled in the self Stream. If this option is set totrue
or is defined with settings, getUserMedia() will be invoked. Self will not connect to the room unless the Stream audio user media access is given.-
stereo
{Boolean} OptionalDEFAULT: false The flag that indicates if stereo should be enabled in self connection Stream audio streaming. -
mute
{Boolean} OptionalDEFAULT: false The flag that indicates if the self Stream object audio streaming is muted.
-
-
video
{Boolean | JSON} OptionalDEFAULT: falseThe self Stream streaming video settings. If
false
, it means that video streaming is disabled in the self Stream. If this option is set totrue
or is defined with settings, getUserMedia() will be invoked. Self will not connect to the room unless the Stream video user media access is given.-
mute
{Boolean} OptionalDEFAULT: false The flag that indicates if the self Stream object video streaming is muted. -
resolution
{JSON} OptionalThe self Stream streaming video resolution settings. Setting the resolution may not force set the resolution provided as it depends on the how the browser handles the resolution. [Rel: Skylink.VIDEO_RESOLUTION] -
resolution.width
{Number} OptionalThe self Stream streaming video resolution width. -
resolution.height
{Number} OptionalThe self Stream streaming video resolution height. -
frameRate
{Number} OptionalDEFAULT: 50 The self Stream streaming video maximum frameRate.
-
-
bandwidth
{JSON} OptionalThe self streaming bandwidth settings. Setting the bandwidth flags may not force set the bandwidth for each connection stream channels as it depends on how the browser handles the bandwidth bitrate. Values are configured in kb/s.
-
audio
{Number} OptionalThe configured audio stream channel for the self Stream object bandwidth that audio streaming should use in kb/s. -
video
{Number} OptionalThe configured video stream channel for the self Stream object bandwidth that video streaming should use in kb/s. -
data
{Number} OptionalThe configured datachannel channel for the DataChannel connection bandwidth that datachannel connection per packet should be able use in kb/s.
-
-
_parseMutedSettings
[options]
,
[audio.stereo=false]
,
)
Parses the mediaStatus
settings for self provided.
Parameters:
-
options
{JSON} OptionalThe self Stream streaming settings.
-
userData
{String | JSON} OptionalThe custom user data information set by developer. This custom user data can also be set in setUserData().
-
audio
{Boolean | JSON} OptionalDEFAULT: falseThe self Stream streaming audio settings. If
false
, it means that audio streaming is disabled in the self Stream. If this option is set totrue
or is defined with settings, getUserMedia() will be invoked. Self will not connect to the room unless the Stream audio user media access is given.-
mute
{Boolean} OptionalDEFAULT: false The flag that indicates if the self Stream object audio streaming is muted.
-
-
video
{Boolean | JSON} OptionalDEFAULT: falseThe self Stream streaming video settings. If
false
, it means that video streaming is disabled in the self Stream. If this option is set totrue
or is defined with settings, getUserMedia() will be invoked. Self will not connect to the room unless the Stream video user media access is given.-
mute
{Boolean} OptionalDEFAULT: false The flag that indicates if the self Stream object video streaming is muted. -
resolution
{JSON} OptionalThe self Stream streaming video resolution settings. Setting the resolution may not force set the resolution provided as it depends on the how the browser handles the resolution. [Rel: Skylink.VIDEO_RESOLUTION] -
resolution.width
{Number} OptionalThe self Stream streaming video resolution width. -
resolution.height
{Number} OptionalThe self Stream streaming video resolution height. -
frameRate
{Number} OptionalDEFAULT: 50 The self Stream streaming video maximum frameRate.
-
-
-
audio.stereo
{Boolean} OptionalDEFAULT: falseThe default flag that indicates if stereo should be enabled in self connection Stream audio streaming.
Returns:
The parsed mediaStatus
settings for self.
return.audioMuted
: The flag that indicates if self connection Stream object audio streaming is muted. If there is no audio streaming enabled for self connection, by default, it is set totrue
.return.videoMuted
: The flag that indicates if self connection Stream object video streaming is muted. If there is no video streaming enabled for self connection, by default, it is set totrue
.
_parseUserData
[userData]
,
)
Parses the custom user data information for self provided.
Parameters:
-
userData
{JSON} OptionalThe custom (or updated) user data information for self provided.
_parseVideoStreamSettings
[options=false]
,
)
Parses the video stream settings for self provided.
Parameters:
-
options
{Boolean | JSON} OptionalDEFAULT: falseThe self Stream streaming video settings. If
false
, it means that video streaming is disabled in the remote Stream of self connection.-
resolution
{JSON} OptionalThe self Stream streaming video resolution settings. Setting the resolution may not force set the resolution provided as it depends on the how the browser handles the resolution. [Rel: Skylink.VIDEO_RESOLUTION]
-
width
{Number} OptionalThe self Stream streaming video resolution width. -
height
{Number} OptionalThe self Stream streaming video resolution height.
-
-
frameRate
{Number} OptionalThe self Stream streaming video maximum frameRate.
-
mute
{Boolean} OptionalDEFAULT: falseThe flag that indicates if the self Stream object video streaming is muted.
-
optional
{Array} OptionalThe optional constraints for video streaming in self user media Stream object. Some of the values are set by the
video.optional
setting in getUserMedia().
-
Returns:
The parsed video stream settings for self.
return.settings
: The output video stream settings information for selfreturn.userMedia
: The output video MediaStreamConstraints to be passed into getUserMedia()
_peerListEventHandler
message.type
,
message
,
)
Handles the PEER_LIST message event received from the platform signaling.
Parameters:
-
message.type
{String}Protocol step:
"peerList"
. -
message
{JSON}The message object received from platform signaling.
-
type
{String}Protocol step:
"peerList"
. -
result
{Object}The received resulting object E.g.
{room1: [peer1, peer2], room2: ...}
.
-
_printAllStoredLogsFn
()
Prints all the stored Skylink console logs into the Web console from _storedLogs.
_privateMessageHandler
message
,
)
Handles the PRIVATE_MESSAGE Protocol message event received from the platform signaling.
Triggers:
incomingMessageParameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
PRIVATE_MESSAGE
payload.-
data
{JSON | String}The Message object.
-
rid
{String}The room ID for identification to the platform signaling connection.
-
cid
{String}The Skylink server connection key for the selected room.
-
mid
{String}The Peer ID associated with this message.
-
target
{String}The targeted Peer ID to receive the message object.
-
type
{String}Protocol step:
"private"
.
-
_processingSingleMessage
message
,
)
Routes the data received to the relevant Protocol handler based on the socket message received.
Parameters:
-
message
{JSON}The message object received.
_processSigMessage
messageString
,
)
Parses any GROUP
type of message received and split them up to
send them to Skylink/_processSingleMessage:method
to handle the individual message object received.
If the message is not GROUP
type of message received, it will send
it directly to Skylink/_processSingleMessage:method
Parameters:
-
messageString
{String}The message object in JSON string.
_publicMessageHandler
message
,
)
Handles the PUBLIC_MESSAGE Protocol message event received from the platform signaling.
Triggers:
incomingMessageParameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
PUBLIC_MESSAGE
payload.-
rid
{String}The room ID for identification to the platform signaling connection.
-
mid
{String}The Peer ID associated with this message.
-
cid
{String}The Skylink server connection key for the selected room.
-
muted
{String}The flag to indicate if the User's audio stream is muted or not.
-
type
{String}Protocol step:
"public"
.
-
_redirectHandler
message
,
)
Handles the REDIRECT message event received from the platform signaling.
Triggers:
systemActionParameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
REDIRECT
payload.-
rid
{String}The room ID for identification to the platform signaling connection.
-
info
{String}The message received from the platform signaling when the system action and reason is given.
-
action
{String}The system action that is received from the platform signaling. [Rel: Skylink.SYSTEM_ACTION]
-
reason
{String}The reason received from the platform signaling behind the system action given. [Rel: Skylink.SYSTEM_ACTION_REASON]
-
type
{String}Protocol step
"redirect"
.
-
_removePeer
peerId
,
)
Disconnects the Peer connection and remove object references associated.
Triggers:
peerLeftParameters:
-
peerId
{String}The Peer ID to disconnect the connection with.
_removeSDPFirefoxH264Pref
sdpLines
,
)
Modifies the array of session description received to remove the Firefox 32 H262 preference to prevent breaking connection with nsupported browsers.
Parameters:
-
sdpLines
{Array}The array of lines in the session description.
Returns:
The updated array of lines in the session description removed of the Firefox 32 H262 preference.
_requestServerInfo
method
,
url
,
callback
,
params
,
)
Starts a HTTP /GET
REST call to the platform server to
retrieve the required connection information.
Parameters:
-
method
{String}The HTTP method. The value should be provided as
"GET"
. -
url
{String}The HTTP URI to invoke the REST call to. The value should be _path.
-
callback
{Function}The callback fired The callback fired after the
HTTP /GET
REST call has a response from the platform server.-
status
{Number}The HTTP status code of the HTTP response given by the platform server.
-
response
{JSON}The HTTP response data after the platform server has responded with the HTTP request.
-
success
{Boolean}The response from the platform server if Application Key connection retrieval is successful and validated or not. -
pc_constraints
{String}For success state. The RTCPeerConnection constraints that would be configured in {{#crossLink "Skylink/_room:attribute"}}_room.peerConstraints{{/crossLink}} in {{#crossLink "Skylink/_parseInfo:method"}}_parseInfo(){{/crossLink}}. The data is in JSON stringified string and requires converting the JSON string to an JSON object to use the object. -
media_constraints
{String}For success state. The getUserMedia() MediaStreamConstraints that would be configured in {{#crossLink "Skylink/_room:attribute"}}_room.mediaConstraints{{/crossLink}} in {{#crossLink "Skylink/_parseInfo:method"}}_parseInfo(){{/crossLink}}. The data is in JSON stringified string and requires converting the JSON string to an JSON object to use the object. -
offer_constraints
{String}For success state. The RTCPeerConnection RTCOfferOptions that would be configured in {{#crossLink "Skylink/_room:attribute"}}_room.offerConstraints{{/crossLink}} in {{#crossLink "Skylink/_parseInfo:method"}}_parseInfo(){{/crossLink}}. The data is in JSON stringified string and requires converting the JSON string to an JSON object to use the object. -
bandwidth
{String}For success state. The self streaming bandwidth settings. Setting the bandwidth flags may not force set the bandwidth for each connection stream channels as it depends on how the browser handles the bandwidth bitrate. Values are configured in kb/s. -
bandwidth.audio
{String}The default audio stream channel for self Stream object bandwidth that audio streaming should use in kb/s. -
bandwidth.video
{String}The default video stream channel for self Stream object bandwidth that video streaming should use in kb/s. -
bandwidth.data
{String}The default datachannel channel for the DataChannel connection bandwidth that datachannel connection per packet should be able use in kb/s. -
cid
{String}For success state. The Skylink server connection key for the selected room. This would be stored in {{#crossLink "Skylink/_key:attribute"}}_key{{/crossLink}} in {{#crossLink "Skylink/_parseInfo:method"}}_parseInfo(){{/crossLink}}. -
apiOwner
{String}For success state. The Skylink server Application Key owner string for the selected room. This would be stored in {{#crossLink "Skylink/_appKeyOwner:attribute"}}_appKeyOwner{{/crossLink}} in {{#crossLink "Skylink/_parseInfo:method"}}_parseInfo(){{/crossLink}}. -
httpPortList
{Array}For success state. The list of HTTP ports for reconnection retries. This would be stored in {{#crossLink "Skylink/_socketPorts:attribute"}}_socketPorts.http:{{/crossLink}}. -
httpPortList.(#index)
{Number}The HTTP port that Skylink could reattempt to establish for a signaling connection withhttp:
protocol. -
httpsPortList
{Array}For success state. The list of HTTPS ports for reconnection retries. This would be stored in {{#crossLink "Skylink/_socketPorts:attribute"}}_socketPorts.https:{{/crossLink}}. -
httpsPortList.(#index)
{Number}The HTTPS port that Skylink could reattempt to establish for a signaling connection withhttps:
protocol or when {{#crossLink "Skylink/_forceSSL:attribute"}}_forceSSL{{/crossLink}} is enabled. -
ipSigserver
{String}For success state. The platform signaling endpoint URI to open socket connection with. This would be stored in {{#crossLink "Skylink/_signalingServer:attribute"}}_signalingServer{{/crossLink}}. -
roomCred
{String}For success state. The generated room token given by the platform server for starting the platform signaling connection. This would be stored in {{#crossLink "Skylink/_room:attribute"}}_room.token{{/crossLink}}. -
room_key
{String}For success state. The room ID for identification to the platform signaling connection. This would be stored in {{#crossLink "Skylink/_room:attribute"}}_room.id{{/crossLink}}. -
start
{String}For success state. The start datetime stamp (in The startDateTime in [(ISO 8601 format)](https://en.wikipedia.org/wiki/ISO_8601) that the call has started sent by the platform server as an indication for the starting datetime of the platform signaling connection to self. This would be stored in {{#crossLink "Skylink/_room:attribute"}}_room.startDateTime{{/crossLink}}. -
timeStamp
{String}For success state. The self session timestamp. This would be stored in {{#crossLink "Skylink/_user:attribute"}}_user.timeStamp{{/crossLink}} -
userCred
{String}For success state. The self session access token. This would be stored in {{#crossLink "Skylink/_user:attribute"}}_user.token{{/crossLink}}. -
username
{String}For success state. The self session ID. This would be stored in {{#crossLink "Skylink/_user:attribute"}}_user.username{{/crossLink}}. -
info
{String}For failure state. The error message thrown by the platform server. -
error
{Number}For failure state. The error code of the error thrown by the platform server.
-
-
-
params
{JSON}HTTP Params The HTTP data parameters that would be
application/json;charset=UTF-8
encoded when sent to the platform server.
_restartHandler
message
,
)
Handles the RESTART Protocol message event received from the platform signaling.
Triggers:
handshakeProgress, peerRestartParameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
RESTART
payload.-
rid
{String}The room ID for identification to the platform signaling connection.
-
mid
{String}The Peer ID associated with this message.
-
receiveOnly
{Boolean} OptionalDEFAULT: falseThe flag that indicates if the Peer connection would send Stream or not (receive only).
-
enableIceTrickle
{Boolean} OptionalDEFAULT: falseThe flag that indicates if PeerConnections should enable trickling of ICE to connect the ICE connection.
-
enableDataChannel
{Boolean} OptionalDEFAULT: falseThe flag that indicates if Peer connection should have any DataChannel connections.
-
userInfo
{JSON}The peer information associated with the Peer Connection.
-
userData
{String | JSON}The custom user data information set by developer. This custom user data can also be set in setUserData(). -
settings
{JSON}The Peer Stream streaming settings information. If both audio and video option isfalse
, there should be no receiving remote Stream object from this associated Peer. -
settings.audio
{Boolean | JSON} OptionalDEFAULT: false The Peer Stream streaming audio settings. Iffalse
, it means that audio streaming is disabled in the remote Stream of the Peer. -
settings.audio.stereo
{Boolean} OptionalThe flag that indicates if stereo should be enabled in the Peer connection Stream audio streaming. -
settings.video
{Boolean | JSON} OptionalDEFAULT: false The Peer Stream streaming video settings. Iffalse
, it means that video streaming is disabled in the remote Stream of the Peer. -
settings.video.resolution
{JSON} OptionalThe Peer Stream streaming video resolution settings. Setting the resolution may not force set the resolution provided as it depends on the how the browser handles the resolution. [Rel: Skylink.VIDEO_RESOLUTION] -
settings.video.resolution.width
{Number} OptionalThe Peer Stream streaming video resolution width. -
settings.video.resolution.height
{Number} OptionalThe Peer Stream streaming video resolution height. -
settings.video.frameRate
{Number} OptionalThe Peer Stream streaming video maximum frameRate. -
settings.video.screenshare
{Boolean} OptionalDEFAULT: false The flag that indicates if the Peer connection Stream object sent is a screensharing stream or not. -
settings.bandwidth
{String} OptionalThe Peer streaming bandwidth settings. Setting the bandwidth flags may not force set the bandwidth for each connection stream channels as it depends on how the browser handles the bandwidth bitrate. Values are configured in kb/s. -
settings.bandwidth.audio
{String} OptionalThe configured audio stream channel for the remote Stream object bandwidth that audio streaming should use in kb/s. -
settings.bandwidth.video
{String} OptionalThe configured video stream channel for the remote Stream object bandwidth that video streaming should use in kb/s. -
settings.bandwidth.data
{String} OptionalThe configured datachannel channel for the DataChannel connection bandwidth that datachannel connection per packet should be able use in kb/s. -
mediaStatus
{JSON}The Peer Stream mute settings for both audio and video streamings. -
mediaStatus.audioMuted
{Boolean} OptionalDEFAULT: true The flag that indicates if the remote Stream object audio streaming is muted. If there is no audio streaming enabled for the Peer, by default, it is set totrue
. -
mediaStatus.videoMuted
{Boolean} OptionalDEFAULT: true The flag that indicates if the remote Stream object video streaming is muted. If there is no video streaming enabled for the Peer, by default, it is set totrue
.
-
-
agent.name
{String}The Peer platform browser or agent name.
-
version
{Number}The Peer platform browser or agent version.
-
os
{Number}The Peer platform name.
-
target
{String}The targeted Peer ID to receive the message object.
-
weight
{Number}The generated handshake reconnection weight for associated Peer.
-
lastRestart
{Number}The datetime stamp generated using Date.now() (in ms) used to throttle the Peer reconnection functionality to prevent less Peer reconnection handshaking errors.
-
isConnectionRestart
{Boolean}The flag that indicates whether the restarting action is caused by ICE connection or handshake connection failure. Currently, this feature works the same as
message.explict
parameter. -
explict
{Boolean}The flag that indicates whether the restart functionality is invoked by the application or by Skylink when the ICE connection fails to establish a "healthy" connection state. Currently, this feature works the same as
message.isConnectionRestart
parameter. -
sessionType
{String}The Peer connection remote Stream streaming session type. If value is
"stream"
, the Stream streaming session is normal user media streaming, else if it is"screensharing"
, the Stream streaming session is screensharing session. -
type
{String}Protocol step
"restart"
.
-
_restartMCUConnection
[callback]
,
)
Restarts all Peers connection in a MCU connection environment. This would require the current user to leave the room and restart all current existing Peers connection.
Triggers:
peerRestart, serverPeerRestart, peerJoined, peerLeft, serverPeerJoinedParameters:
-
callback
{Function} OptionalThe callback fired after all targeted Peers connection has been initiated with refresh or have met with an exception. The callback signature is
function (error, success)
.-
error
{JSON}The error object received in the callback. If received as
null
, it means that there is no errors.-
listOfPeers
{Array}The list of Peers that the refresh connection had been initiated with. -
refreshErrors
{JSON}The list of errors occurred based on per Peer basis. -
refreshErrors.(#peerId)
{Object | String}The Peer ID associated with the error that occurred when refreshing the connection.
-
-
success
{JSON}The success object received in the callback. If received as
null
, it means that there are errors.-
listOfPeers
{Array}The list of Peers that the refresh connection had been initiated with.
-
-
_restartPeerConnection
peerId
,
isSelfInitiatedRestart
,
isConnectionRestart
,
callback
,
[explict=false]
,
)
Restarts a Peer connection in a P2P environment. This is usually done for replacing the previous Stream attached and restarting the connection with a new one, or when the ICE connection has issues streaming video/audio stream in the remote Stream which requires a refresh in the ICE connection.
Parameters:
-
peerId
{String}The Peer ID to restart the connection with.
-
isSelfInitiatedRestart
{Boolean}The flag that indicates if the restart action was caused by self.
-
isConnectionRestart
{Boolean}The flag that indicates whether the restarting action is caused by ICE connection or handshake connection failure. Currently, this feature works the same as
explict
parameter. -
callback
{Function}The callback fired after the Peer connection has been succesfully initiated with a restart. Set this value to
null
if you do not want to pass in any callbacks. -
explict
{Boolean} OptionalDEFAULT: falseThe flag that indicates whether the restart functionality is invoked by the application or by Skylink when the ICE connection fails to establish a "healthy" connection state. Currently, this feature works the same as
isConnectionRestart
parameter.
_roomLockEventHandler
message
,
)
Handles the ROOM_LOCK Protocol message event received from the platform signaling.
Triggers:
roomLockParameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
ROOM_LOCK
payload.-
rid
{String}The room ID for identification to the platform signaling connection.
-
mid
{String}The Peer ID associated with this message.
-
lock
{String}The flag that indicates if the currently joined room is locked.
-
type
{String}Protocol step
"roomLockEvent"
.
-
_sendBlobDataToPeer
data
,
dataInfo
,
[targetPeerId=null]
,
)
Starts a data transfer with a Peer. If multi-transfer is supported,
Skylink would open a new DataChannel connection with Peer to start
data transfer. If mutli-transfer is not supported in
_INTEROP_MULTI_TRANSFERS,
the data transfer would start in the
DATA_CHANNEL_TYPE.MESSAGING
channel instead.
Parameters:
-
data
{Blob}The Blob data object to send.
-
dataInfo
{JSON}The data transfer information.
-
transferId
{String}The transfer ID of the data transfer.
-
name
{String}The transfer Blob data object name.
-
timeout
{Number} OptionalDEFAULT: 60The timeout set to await in seconds for response from DataChannel connection.
-
size
{Number}The Blob data binary size expected to be received in the receiving end.
-
isPrivate
{Boolean} OptionalDEFAULT: falseThe flag to indicate if the data transfer is a private transfer to the Peer directly and not broadcasted to all Peers.
-
-
targetPeerId
{String | Array} OptionalDEFAULT: nullThe receiving Peer ID. Array is used for MCU connection where multi-targeted Peers are used. By default, the value is
null
, which indicates that the data transfer is requested with all connected Peers.
Returns:
The DataChannel connection ID associated with the transfer. If returned
as null
or empty, it indicates an error.
_sendChannelMessage
message
,
)
Sends socket message over the platform signaling socket connection.
Parameters:
-
message
{JSON}The socket message object.
-
type
{String}Required. Protocol type of the socket message object.
-
_sendDataChannelMessage
peerId
,
data
,
[channelName="main"]
,
)
Sends data over the DataChannel connection associated
with the Peer connection.
The current supported data type is string
. Blob
,
ArrayBuffer
types support is not yet currently handled or
implemented.
Triggers:
dataChannelStateParameters:
-
peerId
{String}The Peer ID to send the data to the associated DataChannel connection.
-
data
{JSON | String}The data to send over.
string
is only used to send binary data string over.JSON
is primarily used for the DT Protocol that Skylink follows for P2P messaging and transfers. -
channelName
{String} OptionalDEFAULT: "main"The DataChannel channelName of the connection to send the data over to. The datachannel to send messages to. By default, if the DataChannel
channelName
is not provided, the DataChannel connection associated with the channelName"main"
would be used.
_setDataChannelTimeout
peerId
,
timeout
,
[isSender=false]
,
channelName
,
)
Sets a waiting timeout for every response sent to DataChannel connection receiving end. Once the timeout has ended, a timeout error will be thrown and data transfer will be terminated.
Parameters:
-
peerId
{String}The Peer ID associated with the DataChannel connection.
-
timeout
{Number}The waiting timeout in seconds.
-
isSender
{Boolean} OptionalDEFAULT: falseThe flag thats indicates if the response is related to a downloading or uploading data transfer.
-
channelName
{String}The DataChannel connection ID.
_setIceServers
config
,
)
Reconfigures the RTCConfiguration.iceServers
that is
to be passed in constructing the new RTCPeerConnection
object to remove (disable) STUN or remove TURN (disable) server
connections based on the
init()
configuration passed in.
Parameters:
-
config
{JSON}The RTCConfiguration that is to be passed for constructing the new RTCPeerConnection object.
Returns:
The updated RTCConfiguration object based on the configuration settings in the init() method.
_setLocalAndSendMessage
targetMid
,
sessionDescription
,
)
Sets the WebRTC handshake layer session description into the
Peer RTCPeerConnection
object
RTCPeerConnection.setLocalDescription()
associated
with the Peer connection.
Triggers:
handshakeProgressParameters:
-
targetMid
{String}The Peer ID to send the session description to after setting into the associated
RTCPeerConnection
object. -
sessionDescription
{JSON}The
OFFER
or anANSWER
session description to set to the associated Peer after setting into theRTCPeerConnection
object.
_setSDPAudioCodec
sdpLines
,
)
Modifies the array of session description received to configure the selected audio codec to use in the audio streaming connection.
Parameters:
-
sdpLines
{Array}The array of lines in the session description.
Returns:
The updated array of lines in the session description with the selected audio codec.
_setSDPBitrate
sdpLines
,
)
Modifies the array of session description received to set a custom bandwidth bitrate (in kbps) in the streaming connection. Setting the bandwidth flags may not force set the bandwidth for each connection stream channels as it depends on how the browser handles the bandwidth bitrate.
Parameters:
-
sdpLines
{Array}The array of lines in the session description.
Returns:
The updated array of lines in the session description with custom bandwidth bitrate (in kbps) settings.
_setSDPVideoCodec
sdpLines
,
)
Modifies the array of session description received to configure the selected video codec to use in the video streaming connection.
Parameters:
-
sdpLines
{Array}The array of lines in the session description.
Returns:
The updated array of lines in the session description with the selected video codec.
_setSDPVideoResolution
sdpLines
,
)
BROKEN (not in use). Modifies the array of session description received to set a custom video resolution in the video streaming connection.
Parameters:
-
sdpLines
{Array}The array of lines in the session description.
Returns:
The updated array of lines in the session description with the custom video resolution.
_startDataTransfer
data
,
dataInfo
,
[listOfPeers]
,
[callback]
,
)
Starts the actual data transfers with the array of Peers provided and based on the data transfer type to start the DataChannel connection data transfer.
Parameters:
-
data
{Blob | String}The transfer data object.
-
dataInfo
{JSON}The transfer data object information.
-
name
{String} OptionalDEFAULT: transferIdThe transfer data object name. If there is no name based on the Blob given, the name would be the transfer ID.
-
size
{Number}The transfer data size.
-
transferId
{String}The data transfer ID.
-
dataType
{String}The type of data transfer initiated. Available types are
"dataURL"
and"blob"
. -
timeout
{String}The waiting timeout in seconds that the DataChannel connection data transfer should wait before throwing an exception and terminating the data transfer.
-
isPrivate
{Boolean}The flag to indicate if the data transfer is a private transfer to the Peer directly and not broadcasted to all Peers.
-
-
listOfPeers
{Array} OptionalThe array of targeted Peer to transfer the data object to.
-
callback
{Function} OptionalThe callback fired after all the data transfers is completed successfully or met with an exception. The callback signature is
function (error, success)
.-
error
{JSON}The error object received in the callback. If received as
null
, it means that there is no errors.-
state
{String} OptionalDEFAULT: null Deprecated. The dataTransferState when the error has occurred. This only triggers for a single targeted Peer data transfer. -
error
{Object | String} OptionalDEFAULT: null Deprecated. The error received when the data transfer fails. This only triggers for single targeted Peer data transfer. -
transferId
{String}The transfer ID of the failed data transfer. -
peerId
{String} OptionalDEFAULT: null The single targeted Peer ID for the data transfer. This only triggers for single targeted Peer data transfer. -
listOfPeers
{Array}The list of Peer that the data transfer has been initiated with. -
isPrivate
{Boolean}The flag to indicate if the data transfer is a private transfer to the Peer directly and not broadcasted to all Peers. -
transferErrors
{JSON}The list of errors occurred based on per Peer basis. -
transferErrors.(#peerId)
{Object | String}The error that occurred when having a DataChannel connection data transfer with associated Peer. -
transferInfo
{JSON}The transfer data object information. -
transferInfo.name
{String} OptionalDEFAULT: transferId The transfer data object name. If there is no name based on the Blob given, the name would be the transfer ID. -
transferInfo.size
{Number}The transfer data size. -
transferInfo.transferId
{String}The data transfer ID. -
transferInfo.dataType
{String}The type of data transfer initiated. The received type would be"blob"
. -
transferInfo.timeout
{String}The waiting timeout in seconds that the DataChannel connection data transfer should wait before throwing an exception and terminating the data transfer. -
transferInfo.isPrivate
{Boolean}The flag to indicate if the data transfer is a private transfer to the Peer directly and not broadcasted to all Peers.
-
-
success
{JSON}The success object received in the callback. If received as
null
, it means that there are errors.-
state
{String} OptionalDEFAULT: null Deprecated. The dataTransferState when the data transfer has been completed successfully. This only triggers for a single targeted Peer data transfer. -
transferId
{String}The transfer ID of the successful data transfer. -
peerId
{String} OptionalDEFAULT: null The single targeted Peer ID for the data transfer. This only triggers for single targeted Peer data transfer. -
listOfPeers
{Array}The list of Peer that the data transfer has been initiated with. -
isPrivate
{Boolean}The flag to indicate if the data transfer is a private transfer to the Peer directly and not broadcasted to all Peers. -
transferInfo
{JSON}The transfer data object information. -
transferInfo.name
{String} OptionalDEFAULT: transferId The transfer data object name. If there is no name based on the Blob given, the name would be the transfer ID. -
transferInfo.size
{Number}The transfer data size. -
transferInfo.transferId
{String}The data transfer ID. -
transferInfo.dataType
{String}The type of data transfer initiated. The received type would be"blob"
. -
transferInfo.timeout
{String}The waiting timeout in seconds that the DataChannel connection data transfer should wait before throwing an exception and terminating the data transfer. -
transferInfo.isPrivate
{Boolean}The flag to indicate if the data transfer is a private transfer to the Peer directly and not broadcasted to all Peers.
-
-
_startPeerConnectionHealthCheck
peerId
,
[toOffer=false]
,
)
Starts the waiting timeout for a "healthy" connection with associated Peer connection. It waits for any existing Peer "healthy" state in successful _peerConnectionHealth. If timeout has reached it's limit and does not have any "healthy" connection state with Peer connection, it will restart the connection again with _restartPeerConnection(). This sets the timeout object associated with the Peer into Skylink/_peerConnectionHealthTimers.
Parameters:
-
peerId
{String}The Peer ID to start a waiting timeout for a "healthy" connection.
-
toOffer
{Boolean} OptionalDEFAULT: falseThe flag that indicates if Peer connection is an offerer or an answerer for an accurate timeout waiting time.
_stopLocalMediaStreams
options
,
)
Handles the stopping of audio and video streams.
Parameters:
-
options
{Boolean | JSON}The stop attached Stream options for Skylink when leaving the room.
-
userMedia
{Boolean} OptionalDEFAULT: falseThe flag that indicates if leaving the room should automatically stop and clear the existing user media stream attached to skylink. This would trigger
mediaAccessStopped
for this Stream if available. -
screenshare
{Boolean} OptionalDEFAULT: falseThe flag that indicates if leaving the room should automatically stop and clear the existing screensharing stream attached to skylink. This would trigger
mediaAccessStopped
for this Stream if available.
-
_stopPeerConnectionHealthCheck
peerId
,
)
Stops the waiting timeout for a "healthy" connection associated with the Peer.
Parameters:
-
peerId
{String}The Peer ID to stop a waiting timeout for a "healthy" connection.
_streamEventHandler
message
,
)
Handles the STREAM Protocol message event received from the platform signaling.
Triggers:
streamEndedParameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
STREAM
payload.-
rid
{String}The room ID for identification to the platform signaling connection.
-
mid
{String}The Peer ID associated with this message.
-
status
{String}The Peer connection remote Stream streaming current status.
ended
: The Peer connection remote Stream streaming has ended
-
cid
{String}The Skylink server connection key for the selected room.
-
sessionType
{String}The Peer connection remote Stream streaming session type. If value is
"stream"
, the Stream streaming session is normal user media streaming, else if it is"screensharing"
, the Stream streaming session is screensharing session. -
type
{String}Protocol step
"stream"
.
-
_throttle
func
,
wait
,
)
Returns a wrapper of the original function, which fires only once during a specified amount of time.
Parameters:
-
func
{Function}The function that should be throttled.
-
wait
{Number}The amount of time that function need to throttled (in ms).
Returns:
The throttled function.
_trigger
eventName
,
)
Triggers event subscription handlers that is associated with the event name. on() event subscription handlers will be triggered always, but once() event subscription hadlers will only be triggered once the condition is met.
Parameters:
-
eventName
{String}The Skylink event name to trigger that would trigger event subscription handlers associated to the event name with the
arguments
parameters payload.
_updateUserEventHandler
message
,
)
Handles the UPDATE_USER Protocol message event received from the platform signaling.
Triggers:
peerUpdatedParameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
UPDATE_USER
payload.-
rid
{String}The room ID for identification to the platform signaling connection.
-
mid
{String}The Peer ID associated with this message.
-
userData
{JSON | String}The updated Peer information custom user data.
-
type
{String}Protocol step
"updateUserEvent"
.
-
_wait
callback
,
condition
,
[intervalTime=50]
,
)
Starts the interval check for the condition provided to meet before clearing
the interval and triggering the callback provided.
This utilises setInterval()
function.
Parameters:
-
callback
{Function}The callback fired after the condition provided has been met.
-
condition
{Function}The condition function that once the condition has been met, trigger the callback. Return in the condition function
true
to pass as meeting the condition. -
intervalTime
{Number} OptionalDEFAULT: 50The interval loop timeout that the interval check should iterate based on the timeout provided (in ms). By default, if the value is not configured, it is
50
ms.
_waitForLocalMediaStream
callback
,
callback
,
[options]
,
)
Waits for self MediaStream object to be attached to Skylink based on the options provided before firing the callback to indicate that self Stream object is received. This will stop any currently attached Stream object to Skylink.
Triggers:
mediaAccessSuccess, mediaAccessError, mediaAccessRequiredParameters:
-
callback
{Function}The callback fired after self MediaStream object is attached to Skylink based on the options provided.
-
error
{Object} OptionalDEFAULT: nullThe callback error that is defined when there's an error.
-
-
callback
{Function}The callback fired after self MediaStream object is attached to Skylink based on the options provided successfully or met with an exception. The callback signature is
function (error)
.-
{Object}
The error object received in the callback. If received as
undefined
, it means that there is no errors.
-
-
options
{JSON} OptionalThe self Stream streaming settings. If both audio and video option is
false
, there should be no audio and video stream sending from self connection.-
audio
{Boolean | JSON} OptionalDEFAULT: falseThe self Stream streaming audio settings. If
false
, it means that audio streaming is disabled in the self Stream. If this option is set totrue
or is defined with settings, getUserMedia() will be invoked. Self will not connect to the room unless the Stream audio user media access is given.-
stereo
{Boolean} OptionalDEFAULT: false The flag that indicates if stereo should be enabled in self connection Stream audio streaming. -
mute
{Boolean} OptionalDEFAULT: false The flag that indicates if the self Stream object audio streaming is muted.
-
-
video
{Boolean | JSON} OptionalDEFAULT: falseThe self Stream streaming video settings. If
false
, it means that video streaming is disabled in the self Stream. If this option is set totrue
or is defined with settings, getUserMedia() will be invoked. Self will not connect to the room unless the Stream video user media access is given.-
mute
{Boolean} OptionalDEFAULT: false The flag that indicates if the self Stream object video streaming is muted. -
resolution
{JSON} OptionalThe self Stream streaming video resolution settings. Setting the resolution may not force set the resolution provided as it depends on the how the browser handles the resolution. [Rel: Skylink.VIDEO_RESOLUTION] -
resolution.width
{Number} OptionalThe self Stream streaming video resolution width. -
resolution.height
{Number} OptionalThe self Stream streaming video resolution height. -
frameRate
{Number} OptionalDEFAULT: 50 The self Stream streaming video maximum frameRate.
-
-
bandwidth
{String} OptionalThe self streaming bandwidth settings. Setting the bandwidth flags may not force set the bandwidth for each connection stream channels as it depends on how the browser handles the bandwidth bitrate. Values are configured in kb/s.
-
audio
{String} OptionalThe configured audio stream channel for the self Stream object bandwidth that audio streaming should use in kb/s. -
video
{String} OptionalThe configured video stream channel for the self Stream object bandwidth that video streaming should use in kb/s. -
data
{String} OptionalThe configured datachannel channel for the DataChannel connection bandwidth that datachannel connection per packet should be able use in kb/s.
-
-
_waitForOpenChannel
[options]
,
callback
,
)
Waits for the signaling socket channel connection to be ready before starting the room connection with the Skylink signaling platform.
Triggers:
peerJoined, incomingStream, mediaAccessRequiredParameters:
-
options
{JSON} OptionalThe connection settings for self connection in the room. If both audio and video option is
false
, there should be no audio and video stream sending from self connection.-
userData
{String | JSON} OptionalThe custom user data information set by developer. This custom user data can also be set in setUserData().
-
audio
{Boolean | JSON} OptionalDEFAULT: falseThe self Stream streaming audio settings. If
false
, it means that audio streaming is disabled in the self Stream. If this option is set totrue
or is defined with settings, getUserMedia() will be invoked. Self will not connect to the room unless the Stream audio user media access is given.-
stereo
{Boolean} OptionalThe flag that indicates if stereo should be enabled in self connection Stream audio streaming. -
mute
{Boolean} OptionalDEFAULT: false The flag that indicates if the self Stream object audio streaming is muted.
-
-
video
{Boolean | JSON} OptionalDEFAULT: falseThe self Stream streaming video settings. If
false
, it means that video streaming is disabled in the self Stream. If this option is set totrue
or is defined with settings, getUserMedia() will be invoked. Self will not connect to the room unless the Stream video user media access is given.-
mute
{Boolean} OptionalDEFAULT: false The flag that indicates if the self Stream object video streaming is muted. -
resolution
{JSON} OptionalThe self Stream streaming video resolution settings. Setting the resolution may not force set the resolution provided as it depends on the how the browser handles the resolution. [Rel: Skylink.VIDEO_RESOLUTION] -
resolution.width
{Number} OptionalThe self Stream streaming video resolution width. -
resolution.height
{Number} OptionalThe self Stream streaming video resolution height. -
frameRate
{Number} OptionalDEFAULT: 50 The self Stream streaming video maximum frameRate.
-
-
bandwidth
{String} OptionalThe self streaming bandwidth settings. Setting the bandwidth flags may not force set the bandwidth for each connection stream channels as it depends on how the browser handles the bandwidth bitrate. Values are configured in kb/s.
-
audio
{String} OptionalDEFAULT: 50 The configured audio stream channel for the self Stream object bandwidth that audio streaming should use in kb/s. -
video
{String} OptionalDEFAULT: 256 The configured video stream channel for the self Stream object bandwidth that video streaming should use in kb/s. -
data
{String} OptionalDEFAULT: 1638400 The configured datachannel channel for the DataChannel connection bandwidth that datachannel connection per packet should be able use in kb/s.
-
-
manualGetUserMedia
{Boolean} OptionalThe flag that indicates if
joinRoom()
should not invoke getUserMedia() automatically but allow the developer's application to invoke getUserMedia() manually in the application. When user media access is required, the event mediaAccessRequired will be triggered.
-
-
callback
{Function}The callback fired after signaling socket channel connection has opened successfully with relevant user media being available according to the settings or met with an exception. The callback signature is
function (error)
.-
error
{Object}The error object received in the callback. If received as
undefined
, it means that there is no errors.
-
_welcomeHandler
message
,
)
Handles the WELCOME Protocol message event received from the platform signaling.
Triggers:
handshakeProgress, peerJoinedParameters:
-
message
{JSON}The message object received from platform signaling. This should contain the
WELCOME
payload.-
rid
{String}The room ID for identification to the platform signaling connection.
-
mid
{String}The Peer ID associated with this message.
-
receiveOnly
{Boolean} OptionalDEFAULT: falseThe flag that indicates if the Peer connection would send Stream or not (receive only).
-
enableIceTrickle
{Boolean} OptionalDEFAULT: falseThe flag that indicates if PeerConnections should enable trickling of ICE to connect the ICE connection.
-
enableDataChannel
{Boolean} OptionalDEFAULT: falseThe flag that indicates if Peer connection should have any DataChannel connections.
-
userInfo.userData
{String | JSON}The custom user data information set by developer. This custom user data can also be set in setUserData().
-
userInfo.settings
{JSON}The Peer Stream streaming settings information. If both audio and video option is
false
, there should be no receiving remote Stream object from this associated Peer. -
userInfo.settings.audio
{Boolean | JSON} OptionalDEFAULT: falseThe Peer Stream streaming audio settings. If
false
, it means that audio streaming is disabled in the remote Stream of the Peer. -
userInfo.settings.audio.stereo
{Boolean} OptionalThe flag that indicates if stereo should be enabled in the Peer connection Stream audio streaming.
-
userInfo.settings.video
{Boolean | JSON} OptionalDEFAULT: falseThe Peer Stream streaming video settings. If
false
, it means that video streaming is disabled in the remote Stream of the Peer. -
userInfo.settings.video.resolution
{JSON} OptionalThe Peer Stream streaming video resolution settings. Setting the resolution may not force set the resolution provided as it depends on the how the browser handles the resolution. [Rel: Skylink.VIDEO_RESOLUTION]
-
userInfo.settings.video.resolution.width
{Number} OptionalThe Peer Stream streaming video resolution width.
-
userInfo.settings.video.resolution.height
{Number} OptionalThe Peer Stream streaming video resolution height.
-
userInfo.settings.video.frameRate
{Number} OptionalThe Peer Stream streaming video maximum frameRate.
-
userInfo.settings.video.screenshare
{Boolean} OptionalDEFAULT: falseThe flag that indicates if the Peer connection Stream object sent is a screensharing stream or not.
-
userInfo.settings.bandwidth
{String} OptionalThe Peer streaming bandwidth settings. Setting the bandwidth flags may not force set the bandwidth for each connection stream channels as it depends on how the browser handles the bandwidth bitrate. Values are configured in kb/s.
-
userInfo.settings.bandwidth.audio
{String} OptionalThe configured audio stream channel for the remote Stream object bandwidth that audio streaming should use in kb/s.
-
userInfo.settings.bandwidth.video
{String} OptionalThe configured video stream channel for the remote Stream object bandwidth that video streaming should use in kb/s.
-
userInfo.settings.bandwidth.data
{String} OptionalThe configured datachannel channel for the DataChannel connection bandwidth that datachannel connection per packet should be able use in kb/s.
-
userInfo.mediaStatus
{JSON}The Peer Stream mute settings for both audio and video streamings.
-
userInfo.mediaStatus.audioMuted
{Boolean} OptionalDEFAULT: trueThe flag that indicates if the remote Stream object audio streaming is muted. If there is no audio streaming enabled for the Peer, by default, it is set to
true
. -
userInfo.mediaStatus.videoMuted
{Boolean} OptionalDEFAULT: trueThe flag that indicates if the remote Stream object video streaming is muted. If there is no video streaming enabled for the Peer, by default, it is set to
true
. -
agent.name
{String}The Peer platform browser or agent name.
-
version
{Number}The Peer platform browser or agent version.
-
os
{Number}The Peer platform name.
-
type
{String}Protocol step
"enter"
. -
target
{String}The targeted Peer ID to receive the message object.
-
weight
{Number}The generated handshake connection weight for associated Peer.
-
sessionType
{String}The Peer connection remote Stream streaming session type. If value is
"stream"
, the Stream streaming session is normal user media streaming, else if it is"screensharing"
, the Stream streaming session is screensharing session. -
type
{String}Protocol step
"welcome"
.
-
_WRQProtocolHandler
senderPeerId
,
data
,
channelName
,
)
Handles the WRQ Protocol request received from the DataChannel connection.
Triggers:
dataTransferStateParameters:
-
senderPeerId
{String}The Peer ID associated with the DataChannel connection.
-
data
{JSON}The data object received from the DataChannel connection. This should contain the
WRQ
payload.-
agent
{String}The sender Peer platform browser or agent name.
-
version
{Number}The sender Peer platform browser or agent version.
-
name
{String}The transfer data object name.
-
size
{Number}The transfer data object expected received size.
-
chunkSize
{Number}The expected data transfer packet (chunk) size.
-
timeout
{Number}The timeout set to await in seconds for response from DataChannel connection.
-
isPrivate
{Boolean}The flag to indicate if the data transfer is a private transfer to the Peer connection directly and not broadcasted to all Peers conneciton.
-
sender
{String}The Peer ID of the sender.
-
type
{String}Protocol step
"WRQ"
.
-
-
channelName
{String}The DataChannel connection ID associated with the transfer.
acceptDataTransfer
peerId
,
transferId
,
[accept=false]
,
)
Responds to a data transfer request by a Peer.
Triggers:
dataTransferState, incomingDataRequest, incomingDataParameters:
-
peerId
{String}The sender Peer ID.
-
transferId
{String}The data transfer ID of the data transfer request to accept or reject.
-
accept
{Boolean} OptionalDEFAULT: falseThe flag that indicates
true
as a response to accept the data transfer andfalse
as a response to reject the data transfer request.
cancelBlobTransfer
peerId
,
transferId
,
)
source/data-transfer.js:1968
Available since 0.5.7
Terminates a current data transfer with Peer.
Triggers:
dataTransferStateParameters:
-
peerId
{String}The Peer ID associated with the data transfer.
-
transferId
{String}The data transfer ID of the data transfer request to terminate the request.
cancelDataTransfer
peerId
,
transferId
,
)
Terminates a current data transfer with Peer.
Triggers:
dataTransferStateParameters:
-
peerId
{String}The Peer ID associated with the data transfer.
-
transferId
{String}The data transfer ID of the data transfer request to terminate the request.
disableAudio
()
source/stream-media.js:1996
Available since 0.5.5
Mutes the currently attached Stream object audio stream.
Triggers:
streamMuted, peerUpdatedExample:
SkylinkDemo.disableAudio();
disableVideo
()
Mutes the currently attached Stream object video stream.
Triggers:
streamMuted, peerUpdatedExample:
SkylinkDemo.disableVideo();
enableAudio
()
source/stream-media.js:1978
Available since 0.5.5
Unmutes the currently attached Stream object audio stream.
Triggers:
streamMuted, peerUpdatedExample:
SkylinkDemo.enableAudio();
enableVideo
()
source/stream-media.js:2014
Available since 0.5.5
Unmutes the currently attached Stream object video stream.
Triggers:
streamMuted, peerUpdatedExample:
SkylinkDemo.enableVideo();
generateUUID
()
Helper function that generates an Unique ID (UUID) string.
Returns:
Generated Unique ID (UUID) string.
Example:
// Get Unique ID (UUID) var uuid = SkylinkDemo.generateUUID();
getPeerInfo
[peerId]
,
)
Gets the Peer information. If an invalid Peer ID is provided, or no Peer ID is provided, the method will return the self peer information.
Parameters:
-
peerId
{String} OptionalThe Peer information to retrieve the data from. If the Peer ID is not provided, it will return the self Peer information.
Returns:
The Peer information. The parameters relates to the
peerInfo
payload given in the
peerJoined event.
Example:
// Example 1: To get other peer's information var peerInfo = SkylinkDemo.getPeerInfo(peerId);
// Example 2: To get own information var userInfo = SkylinkDemo.getPeerInfo();
getPeers
[showAll=false]
,
[callback]
,
)
Retrieves the list of rooms and peers under the same realm based on the Application Key configured in init() from the platform signaling. This will only work if self is a privileged Peer.
Triggers:
getPeersStateChangeParameters:
-
showAll
{Boolean} OptionalDEFAULT: falseThe flag that indicates if returned list should also include privileged peers in the list. By default, the value is
false
. -
callback
{Function} OptionalThe callback fired after the receiving the current list of Peers from platform signaling or have met with an exception. The callback signature is
function (error, success)
.-
error
{Object}The error object received in the callback. This is the exception thrown that caused the failure for getting self user media. If received as
null
, it means that there is no errors. -
success
{JSON}The success object received in the callback. If received as
null
, it means that there are errors.
-
Example:
// To get list of unprivileged peers only SkylinkDemo.getPeers();
// To get list of all peers, including other privileged peers SkylinkDemo.getPeers(true);
// To get a list of unprivileged peers then invoke the callback SkylinkDemo.getPeers(function(error, success){ if (error){ console.log("Error happened. Can not retrieve list of peers"); } else{ console.log("Success fully retrieved list of peers", success); } });
// To get a list of all peers then invoke the callback SkylinkDemo.getPeers(true, function(error, success){ if (error){ console.log("Error happened. Can not retrieve list of peers"); } else{ console.log("Success fully retrieved list of peers", success); } });
getUserData
()
Gets the current custom user data information for self. You may set the current customer user data information for self in setUserData().
Returns:
The custom (or updated) user data information for self set.
Example:
// Example 1: To get other peer's userData var peerData = SkylinkDemo.getUserData(peerId);
// Example 2: To get own userData var userData = SkylinkDemo.getUserData();
getUserMedia
[options]
,
[callback]
,
)
Gets self user media Stream object to attach to Skylink. Do not invoke this function when user has already joined a room as this may affect any currently attached stream. You may use sendStream() instead if self is already in the room, and allows application to attach application own MediaStream object to Skylink.
Triggers:
mediaAccessSuccess, mediaAccessErrorParameters:
-
options
{JSON} OptionalThe self Stream streaming settings for the new Stream object attached to Skylink. If this parameter is not provided, the options value would be
{ audio: true, video: true }
.-
audio
{Boolean | JSON} OptionalDEFAULT: falseThe self Stream streaming audio settings. If
false
, it means that audio streaming is disabled in the self Stream. If this option is set totrue
or is defined with settings, getUserMedia() will be invoked. Self will not connect to the room unless the Stream audio user media access is given.-
stereo
{Boolean} OptionalDEFAULT: false The flag that indicates if stereo should be enabled in self connection Stream audio streaming. -
mute
{Boolean} OptionalDEFAULT: false The flag that indicates if the self Stream object audio streaming is muted. -
optional
{Array} OptionalThe optional constraints for audio streaming in self user media Stream object. This follows theoptional
setting in theMediaStreamConstraints
whengetUserMedia()
is invoked. Tampering this may cause errors in retrieval of self user media Stream object. Refer to this [site for more reference](http://www.sitepoint.com/introduction-getusermedia-api/).
-
-
video
{Boolean | JSON} OptionalDEFAULT: falseThe self Stream streaming video settings. If
false
, it means that video streaming is disabled in the self Stream. If this option is set totrue
or is defined with settings, getUserMedia() will be invoked. Self will not connect to the room unless the Stream video user media access is given.-
mute
{Boolean} OptionalDEFAULT: false The flag that indicates if the self Stream object video streaming is muted. -
resolution
{JSON} OptionalThe self Stream streaming video resolution settings. Setting the resolution may not force set the resolution provided as it depends on the how the browser handles the resolution. [Rel: Skylink.VIDEO_RESOLUTION] -
resolution.width
{Number} OptionalThe self Stream streaming video resolution width. This sets themaxWidth
of thevideo
constraints passed ingetUserMedia()
. -
resolution.height
{Number} OptionalThe self Stream streaming video resolution height. This sets themaxHeight
of thevideo
constraints passed ingetUserMedia()
. -
frameRate
{Number} OptionalDEFAULT: 50 The self Stream streaming video maximum frameRate. This sets themaxFramerate
of thevideo
constraints passed ingetUserMedia()
. -
optional
{Array} OptionalThe optional constraints for video streaming in self user media Stream object. This follows theoptional
setting in theMediaStreamConstraints
whengetUserMedia()
is invoked. Tampering this may cause errors in retrieval of self user media Stream object. Refer to this [site for more reference](http://www.sitepoint.com/introduction-getusermedia-api/).
-
-
-
callback
{Function} OptionalThe callback fired after Skylink has gained access to self media stream and attached it successfully with the provided media settings or have met with an exception. The callback signature is
function (error, success)
.-
error
{Object}The error object received in the callback. This is the exception thrown that caused the failure for getting self user media. If received as
null
, it means that there is no errors. -
success
{Object}The success object received in the callback. The self user media MediaStream object. To display the MediaStream object to a
video
oraudio
, simply invoke:
attachMediaStream(domElement, stream);
. If received asnull
, it means that there are errors.
-
Example:
// Default is to get both audio and video // Example 1: Get both audio and video by default. SkylinkDemo.getUserMedia();
// Example 2: Get the audio stream only SkylinkDemo.getUserMedia({ video: false, audio: true });
// Example 3: Set the stream settings for the audio and video SkylinkDemo.getUserMedia({ video: { resolution: SkylinkDemo.VIDEO_RESOLUTION.HD, frameRate: 50 }, audio: { stereo: true } });
// Example 4: Get user media with callback SkylinkDemo.getUserMedia({ video: false, audio: true },function(error,success){ if (error){ console.log(error); } else{ console.log(success); } });
init
options
,
[callback]
,
)
Initialises and configures Skylink to begin any connection. NOTE that this is the first method that has to be called before using any other functionalities other than debugging features like setLogLevel() and setDebugMode() and after all event subscriptions like on() or once() has been made. This is where the Application Key is configured and attached to Skylink for usage.
Triggers:
readyStateChangeParameters:
-
options
{String | JSON}The configuration settings for Skylink. If provided options is a typeof
string
, it will be interpreted as the Application Key being provided.-
appKey
{String}Previously known as
apiKey
. The Application Key that Skylink uses for initialising and connecting rooms. -
defaultRoom
{String} OptionalDEFAULT: options.appKeyThe default room that Skylink should connect to if there is no room provided in joinRoom(). If this value is not provided, the default room value would be the Application Key provided.
-
roomServer
{String} OptionalThe platform server URL that Skylink makes a
HTTP /GET
to retrieve the connection information required. This is a debugging feature, and it's not advisable to manipulate this value unless you are using a beta platform server. -
region
{String} OptionalDeprecated feature. The regional server that Skylink should connect to for fastest connectivity. [Rel: Skylink.REGIONAL_SERVER]
-
enableIceTrickle
{Boolean} OptionalDEFAULT: trueDebugging Feature. The flag that indicates if PeerConnections should enable trickling of ICE to connect the ICE connection. Configuring this value to
false
may result in a slower connection but a more stable connection. -
enableDataChannel
{Boolean} OptionalDEFAULT: trueDebugging feature. The flag that indicates if PeerConnections should have any DataChannel connections. Configuring this value to
false
may result in failure to use features like sendBlobData(), sendP2PMessage() and sendURLData() or any DataChannel connection related services. -
enableTURNServer
{Boolean} OptionalDEFAULT: trueDebugging feature. The flag that indicates if PeerConnections connection should use any TURN server connection. Tampering this flag may disable any successful Peer connection that is behind any firewalls, so set this value at your own risk.
-
enableSTUNServer
{Boolean} OptionalDEFAULT: trueDebugging feature. The flag that indicates if PeerConnections connection should use any STUN server connection. Tampering this flag may cause issues to connections, so set this value at your own risk.
-
forceTURN
{Boolean} OptionalDEFAULT: falseThe flag that indicates if PeerConnections connection should only use TURN server connection which enables a quicker connectivity. This configuration will override the settings for
enableTURNServer
andenableSTUNServer
and setenableTURNServer
astrue
andenableSTUNServer
asfalse
if the value is set totrue
. -
usePublicSTUN
{Boolean} OptionalDEFAULT: trueThe flag that indicates if PeerConnections connection should enable usage of public STUN server connection connectivity. This configuration would not work if
enableSTUNServer
is set tofalse
orforceTURN
is set totrue
. -
TURNServerTransport
{Boolean} OptionalDEFAULT: Skylink.TURN_TRANSPORT.ANYDebugging feature. The TURN server transport to enable for TURN server connections. Tampering this flag may cause issues to connections, so set this value at your own risk. [Rel: Skylink.TURN_TRANSPORT]
-
credentials
{JSON} OptionalThe credentials configured for starting a new persistent room meeting or connecting with Application Keys that do not use CORS authentication. Setting the
startDateTime
or theduration
will not affect the actual duration for non persistent rooms. This feature would only affect connections with Application Keys that is configured for persistent room feature. To enable persistent room or disable CORS, you may set it in the developer console. CORS may be disabled by setting the platform to"Other"
.-
startDateTime
{String}The room start datetime stamp in ISO 8601 format. This will start a new meeting based on the starting datetime stamp in the room that was selected to join for Application Key that is configured with persistent room feature. You may use Date.toISOString() to retrieve ISO 8601 formatted date time stamp. The start date time of the room will not affect non persistent room connection. -
duration
{Number}The duration (in hours) that the room duration should be in. This will set the duration starting from the providedstartDateTime
onwards and after the duration is over, the meeting is over and the room is closed for Application Key that is configured with persistent room feature. The duration will not affect non persistent room connection.The duration of the meeting in hours.
E.g.0.5
for half an hour,1.4
for 1 hour and 24 minutes -
credentials
{String}The room credentials for Application Key. This is required for rooms connecting without CORS verification or starting a new persistent room meeting.
To generate the credentials:
- Concatenate a string that consists of the room name
the room meeting duration (in hours) and the start date timestamp (in ISO 8601 format).
Formatroom + "_" + duration + "_" + startDateTimeStamp
- Hash the concatenated string with the Application Key token using
SHA-1.
You may use the CryptoJS.HmacSHA1 function to do so.
Examplevar hash = CryptoJS.HmacSHA1(concatenatedString, token);
- Convert the hash to a Base64 encoded string. You may use the
CryptoJS.enc.Base64 function
to do so.
Examplevar base64String = hash.toString(CryptoJS.enc.Base64);
- Encode the Base64 encoded string to a URI component using UTF-8 encoding with
encodeURIComponent().
Examplevar credentials = encodeURIComponent(base64String);
- Concatenate a string that consists of the room name
the room meeting duration (in hours) and the start date timestamp (in ISO 8601 format).
-
-
audioFallback
{Boolean} OptionalDEFAULT: falseThe flag that indicates if there is a failure in getUserMedia() in retrieving user media video stream, it should fallback to retrieve audio stream only. This would not work for joinRoom() except getUserMedia().
-
forceSSL
{Boolean} OptionalDEFAULT: falseThe flag to enforce an SSL platform signaling and platform server connection. If self domain accessing protocol is
https:
, SSL connections would be automatically used. This flag is mostly used for self domain accessing protocol that ishttp:
and enforcing the SSL connections for platform signaling and platform server connection. -
audioCodec
{String} OptionalDEFAULT: Skylink.AUDIO_CODEC.AUTODebugging Feature. The preferred audio codec that Peer connection streaming audio codec should use in the connection when available. If not available, the default codec would be the browser generated session description selected codec. [Rel: Skylink.AUDIO_CODEC]
-
videoCodec
{String} OptionalDEFAULT: Skylink.VIDEO_CODEC.AUTODebugging Feature. The preferred video codec that Peer connection streaming video codec should use in the connection when available. If not available, the default codec would be the browser generated session description selected codec. [Rel: Skylink.VIDEO_CODEC]
-
socketTimeout
{Number} OptionalDEFAULT: 20000The timeout that the socket connection should throw a timeout exception when socket fails to receive a response from connection. Depending on the max retries left based on the availability of ports given by the platform server, the socket will reattempt to establish a socket connection with the signaling server.
The mininum timeout value is5000
. -
forceTURNSSL
{Boolean} OptionalDEFAULT: falseThe flag to enforce an SSL TURN server connection. If self domain accessing protocol is
https:
, SSL connections would be automatically used. This flag is mostly used for self domain accessing protocol that ishttp:
and enforcing the SSL connections for TURN server connection. This will configure TURN server connection using port443
only and ifturns:
protocol is supported, it will useturns:
protocol.
-
-
callback
{Function} OptionalThe callback fired after Skylink has been initialised successfully or have met with an exception. The callback signature is
function (error, success)
.-
error
{JSON}The error object received in the callback. If received as
null
, it means that there is no errors.-
errorCode
{Number}The READY_STATE_CHANGE_ERROR if there is an readyStateChange event error that caused the failure for initialising Skylink. [Rel: Skylink.READY_STATE_CHANGE_ERROR] -
error
{Object}The exception thrown that caused the failure for initialising Skylink. -
status
{Number}The XMLHttpRequest status code received when exception is thrown that caused the failure for initialising Skylink.
-
-
success
{JSON}The success object received in the callback. If received as
null
, it means that there are errors.-
appKey
{String}Previously known asapiKey
. The Application Key that Skylink uses for initialising and connecting rooms. -
defaultRoom
{String}The default room that Skylink should connect to if there is no room provided in joinRoom(). -
roomServer
{String}The platform server URL that Skylink makes aHTTP /GET
to retrieve the connection information required. -
enableIceTrickle
{Boolean}The flag that indicates if PeerConnections should enable trickling of ICE to connect the ICE connection. -
enableDataChannel
{Boolean}The flag that indicates if PeerConnections should have any DataChannel connections. -
enableTURNServer
{Boolean}The flag that indicates if PeerConnections connection should use any TURN server connection. -
enableSTUNServer
{Boolean}The flag that indicates if PeerConnections connection should use any STUN server connection. -
TURNServerTransport
{Boolean}The TURN server transport to enable for TURN server connections. [Rel: Skylink.TURN_TRANSPORT] -
serverRegion
{String} OptionalThe regional server that Skylink should connect to for fastest connectivity. [Rel: Skylink.REGIONAL_SERVER] -
audioFallback
{Boolean}The flag that indicates if there is a failure in getUserMedia() in retrieving user media video stream, it should fallback to retrieve audio stream only. -
forceSSL
{Boolean}The flag to enforce an SSL platform signaling and platform server connection. If self domain accessing protocol ishttps:
, SSL connections would be automatically used. -
audioCodec
{String}The preferred audio codec that Peer connection streaming audio codec should use in the connection when available. [Rel: Skylink.AUDIO_CODEC] -
videoCodec
{String}The preferred video codec that Peer connection streaming video codec should use in the connection when available. [Rel: Skylink.VIDEO_CODEC] -
socketTimeout
{Number}The timeout that the socket connection should throw a timeout exception when socket fails to receive a response from connection. Depending on the max retries left based on the availability of ports given by the platform server, the socket will reattempt to establish a socket connection with the signaling server. -
forceTURNSSL
{Boolean}The flag to enforce an SSL TURN server connection. If self domain accessing protocol ishttps:
, SSL connections would be automatically used. This will configure TURN server connection using port443
only and ifturns:
protocol is supported, it will useturns:
protocol. -
forceTURN
{Boolean}The flag that indicates if PeerConnections connection should only use TURN server connection which enables a quicker connectivity. This configuration will override the settings forenableTURNServer
andenableSTUNServer
and setenableTURNServer
astrue
andenableSTUNServer
asfalse
if the value is set totrue
. -
usePublicSTUN
{Boolean}The flag that indicates if PeerConnections connection should enable usage of public STUN server connection connectivity. This configuration would not work ifenableSTUNServer
is set tofalse
orforceTURN
is set totrue
.
-
-
Example:
// Note: Default room is appKey when no room // Example 1: To initalize without setting any default room. SkylinkDemo.init("YOUR_APP_KEY_HERE");
// Example 2: To initialize with appKey and defaultRoom SkylinkDemo.init({ appKey: "YOUR_APP_KEY_HERE", defaultRoom: "mainHangout" });
// Example 3: To initialize with credentials to set startDateTime and // duration of the room var hash = CryptoJS.HmacSHA1(roomname + "" + duration + "" + (new Date()).toISOString(), token); var credentials = encodeURIComponent(hash.toString(CryptoJS.enc.Base64)); SkylinkDemo.init({ appKey: "YOUR_APP_KEY_HERE", defaultRoom: "mainHangout" credentials: { startDateTime: (new Date()).toISOString(), duration: 500, credentials: credentials } });
// Example 4: To initialize with callback SkylinkDemo.init("YOUR_APP_KEY_HERE", function(error,success){ if (error){ console.error("Init failed:", error); } else{ console.info("Init succeed:", success); } });
introducePeer
sendingPeerId
,
receivingPeerId
,
)
Introduces two Peers to each other to start a connection with each other. This will only work if self is a privileged Peer.
Triggers:
introduceStateChangeParameters:
-
sendingPeerId
{String}The Peer ID of the peer that initiates the connection with the introduced Peer.
-
receivingPeerId
{String}The Peer ID of the introduced peer who would be introduced to the initiator Peer.
joinRoom
[room]
,
[options]
,
[callback]
,
)
Connects self to the selected room.
By default, if room parameter is not provided, it will
connect to the default room provided in
init() defaultRoom
settings.
If any existing user media streams attached in Skylink, like for an example, calling
getUserMedia() or
sendStream() before
joinRoom()
, self would actually send the current attached user media stream
attached. To stop the current attached Stream, please invoke
stopStream() before
joinRoom()
is invoked.
Triggers:
readyStateChange, peerJoined, mediaAccessRequiredParameters:
-
room
{String} OptionalThe room for self to join to. If room is not provided, the room would default to the the
defaultRoom
option set in init() settings. -
options
{JSON} OptionalThe connection settings for self connection in the room. If both audio and video option is
false
, there should be no audio and video stream sending from self connection.-
userData
{String | JSON} OptionalThe custom user data information set by developer. This custom user data can also be set in setUserData().
-
audio
{Boolean | JSON} OptionalDEFAULT: falseThe self Stream streaming audio settings. If
false
, it means that audio streaming is disabled in the self Stream. If this option is set totrue
or is defined with settings, getUserMedia() will be invoked. Self will not connect to the room unless the Stream audio user media access is given.-
stereo
{Boolean} OptionalThe flag that indicates if stereo should be enabled in self connection Stream audio streaming. -
mute
{Boolean} OptionalDEFAULT: false The flag that indicates if the self Stream object audio streaming is muted. -
optional
{Array} OptionalThe optional constraints for audio streaming in self user media Stream object. This follows theoptional
setting in theMediaStreamConstraints
whengetUserMedia()
is invoked. Tampering this may cause errors in retrieval of self user media Stream object. Refer to this [site for more reference](http://www.sitepoint.com/introduction-getusermedia-api/).
-
-
video
{Boolean | JSON} OptionalDEFAULT: falseThe self Stream streaming video settings. If
false
, it means that video streaming is disabled in the self Stream. If this option is set totrue
or is defined with settings, getUserMedia() will be invoked. Self will not connect to the room unless the Stream video user media access is given.-
mute
{Boolean} OptionalDEFAULT: false The flag that indicates if the self Stream object video streaming is muted. -
optional
{Array} OptionalThe optional constraints for video streaming in self user media Stream object. This follows theoptional
setting in theMediaStreamConstraints
whengetUserMedia()
is invoked. Tampering this may cause errors in retrieval of self user media Stream object. Refer to this [site for more reference](http://www.sitepoint.com/introduction-getusermedia-api/). -
resolution
{JSON} OptionalThe self Stream streaming video resolution settings. Setting the resolution may not force set the resolution provided as it depends on the how the browser handles the resolution. [Rel: Skylink.VIDEO_RESOLUTION] -
resolution.width
{Number} OptionalThe self Stream streaming video resolution width. -
resolution.height
{Number} OptionalThe self Stream streaming video resolution height. -
frameRate
{Number} OptionalDEFAULT: 50 The self Stream streaming video maximum frameRate.
-
-
bandwidth
{String} OptionalThe self streaming bandwidth settings. Setting the bandwidth flags may not force set the bandwidth for each connection stream channels as it depends on how the browser handles the bandwidth bitrate. Values are configured in kb/s.
-
audio
{String} OptionalDEFAULT: 50 The configured audio stream channel for the self Stream object bandwidth that audio streaming should use in kb/s. -
video
{String} OptionalDEFAULT: 256 The configured video stream channel for the self Stream object bandwidth that video streaming should use in kb/s. -
data
{String} OptionalDEFAULT: 1638400 The configured datachannel channel for the DataChannel connection bandwidth that datachannel connection per packet should be able use in kb/s.
-
-
manualGetUserMedia
{Boolean} OptionalThe flag that indicates if
joinRoom()
should not invoke getUserMedia() automatically but allow the developer's application to invoke getUserMedia() manually in the application. When user media access is required, the event mediaAccessRequired will be triggered.
-
-
callback
{Function} OptionalThe callback fired after self has joined the room successfully with the provided media settings or have met with an exception. The callback signature is
function (error, success)
.-
error
{JSON}The error object received in the callback. If received as
null
, it means that there is no errors.-
error
{Array}The exception thrown that caused the failure for joining the room. -
errorCode
{JSON}The READY_STATE_CHANGE_ERROR if there is an readyStateChange event error that caused the failure for joining the room. [Rel: Skylink.READY_STATE_CHANGE_ERROR] -
room
{Object | String}The selected room that self is trying to join to.
-
-
success
{JSON}The success object received in the callback. If received as
null
, it means that there are errors.-
room
{Array}The selected room that self has succesfully joined to. -
peerId
{String}The self Peer ID that would be reflected remotely to peers in the room. -
peerInfo
{JSON}The connection settings for self connection in the room. If both audio and video option isfalse
, there should be no audio and video stream sending from self connection. -
peerInfo.userData
{String | JSON}The custom user data information set by developer. This custom user data can also be set in setUserData(). -
peerInfo.audio
{Boolean | JSON} OptionalDEFAULT: false The self Stream streaming audio settings. Iffalse
, it means that audio streaming is disabled in the self Stream. If this option is set totrue
or is defined with settings, getUserMedia() will be invoked. Self will not connect to the room unless the Stream audio user media access is given. -
peerInfo.audio.stereo
{Boolean} OptionalThe flag that indicates if stereo should be enabled in self connection Stream audio streaming. -
peerInfo.video
{Boolean | JSON} OptionalDEFAULT: false The self Stream streaming video settings. Iffalse
, it means that video streaming is disabled in the self Stream. If this option is set totrue
or is defined with settings, getUserMedia() will be invoked. Self will not connect to the room unless the Stream video user media access is given. -
peerInfo.video.resolution
{JSON} OptionalThe self Stream streaming video resolution settings. Setting the resolution may not force set the resolution provided as it depends on the how the browser handles the resolution. [Rel: Skylink.VIDEO_RESOLUTION] -
peerInfo.video.resolution.width
{Number} OptionalThe self Stream streaming video resolution width. -
peerInfo.video.resolution.height
{Number} OptionalThe self Stream streaming video resolution height. -
peerInfo.video.frameRate
{Number} OptionalDEFAULT: 50 The self Stream streaming video maximum frameRate. -
peerInfo.video.screenshare
{Boolean} OptionalDEFAULT: false The flag that indicates if the self connection Stream object sent is a screensharing stream or not. -
peerInfo.bandwidth
{String} OptionalThe self streaming bandwidth settings. Setting the bandwidth flags may not force set the bandwidth for each connection stream channels as it depends on how the browser handles the bandwidth bitrate. Values are configured in kb/s. -
peerInfo.bandwidth.audio
{String} OptionalDEFAULT: 50 The configured audio stream channel for the self Stream object bandwidth that audio streaming should use in kb/s. -
peerInfo.bandwidth.video
{String} OptionalDEFAULT: 256 The configured video stream channel for the self Stream object bandwidth that video streaming should use in kb/s. -
peerInfo.bandwidth.data
{String} OptionalDEFAULT: 1638400 The configured datachannel channel for the DataChannel connection bandwidth that datachannel connection per packet should be able use in kb/s. -
peerInfo.mediaStatus
{JSON}The self Stream mute settings for both audio and video streamings. -
peerInfo.mediaStatus.audioMuted
{Boolean} OptionalDEFAULT: true The flag that indicates if the self Stream object audio streaming is muted. If there is no audio streaming enabled for the self, by default, it is set totrue
. -
peerInfo.mediaStatus.videoMuted
{Boolean} OptionalDEFAULT: true The flag that indicates if the self Stream object video streaming is muted. If there is no video streaming enabled for the Peer connection, by default, it is set totrue
. -
peerInfo.agent
{JSON}The self platform agent information. -
peerInfo.agent.name
{String}The self platform browser or agent name. -
peerInfo.agent.version
{Number}The self platform browser or agent version. -
peerInfo.agent.os
{Number}The self platform name. -
peerInfo.room
{String}The current room that the self is in.
-
-
Example:
// To just join the default room without any video or audio // Note that calling joinRoom without any parameters // still sends any available existing MediaStreams allowed. // See Examples 2, 3, 4 and 5 etc to prevent video or audio stream SkylinkDemo.joinRoom();
// To just join the default room with bandwidth settings SkylinkDemo.joinRoom({ bandwidth: { data: 14440 } });
// Example 1: To call getUserMedia and joinRoom seperately SkylinkDemo.getUserMedia(); SkylinkDemo.on("mediaAccessSuccess", function (stream)) { attachMediaStream($(".localVideo")[0], stream); SkylinkDemo.joinRoom(); });
// Example 2: Join a room without any video or audio SkylinkDemo.joinRoom("room_a");
// Example 3: Join a room with audio only SkylinkDemo.joinRoom("room_b", { audio: true, video: false });
// Example 4: Join a room with prefixed video width and height settings SkylinkDemo.joinRoom("room_c", { audio: true, video: { resolution: { width: 640, height: 320 } } });
// Example 5: Join a room with userData and settings with audio, video // and bandwidth SkylinkDemo.joinRoom({ userData: { item1: "My custom data", item2: "Put whatever, string or JSON or array" }, audio: { stereo: true }, video: { resolution: SkylinkDemo.VIDEO_RESOLUTION.VGA, frameRate: 50 }, bandwidth: { audio: 48, video: 256, data: 14480 } });
//Example 6: joinRoom with callback SkylinkDemo.joinRoom(function(error, success){ if (error){ console.log("Error happened. Can not join room"); } else{ console.log("Successfully joined room"); } });
leaveRoom
[stopMediaOptions=true]
,
[callback]
,
)
Disconnects self from current connected room.
Triggers:
peerLeft, channelClose, streamEndedParameters:
-
stopMediaOptions
{Boolean | JSON} OptionalDEFAULT: trueThe stop attached Stream options for Skylink when leaving the room. If provided options is a typeof
boolean
, it will be interpreted as bothuserMedia
andscreenshare
Streams would be stopped.-
userMedia
{Boolean} OptionalDEFAULT: trueThe flag that indicates if leaving the room should automatically stop and clear the existing user media stream attached to skylink. This would trigger
mediaAccessStopped
for this Stream if available. -
screenshare
{Boolean} OptionalDEFAULT: trueThe flag that indicates if leaving the room should automatically stop and clear the existing screensharing stream attached to skylink. This would trigger
mediaAccessStopped
for this Stream if available.
-
-
callback
{Function} OptionalThe callback fired after self has left the room successfully or have met with an exception. The callback signature is
function (error, success)
.-
error
{Object}The error object received in the callback. If received as
null
, it means that there is no errors. -
success
{JSON}The success object received in the callback. If received as
null
, it means that there are errors.-
peerId
{String}The assigned previous Peer ID to self given when self was still connected to the room. -
previousRoom
{String}The room self was disconnected from.
-
-
Example:
//Example 1: Just leaveRoom SkylinkDemo.leaveRoom();
//Example 2: leaveRoom with callback SkylinkDemo.leaveRoom(function(error, success){ if (error){ console.log("Error happened"); } else{ console.log("Successfully left room"); } });
lockRoom
()
Locks the currently connected room to prevent other peers from joining the room.
Triggers:
roomLockExample:
SkylinkDemo.lockRoom();
muteStream
options
,
)
Mutes the currently attached Stream object in Skylink.
Triggers:
streamMuted, peerUpdatedParameters:
-
options
{JSON}The self Stream streaming muted settings.
-
audioMuted
{Boolean} OptionalDEFAULT: trueThe flag that indicates if self connection Stream object audio streaming is muted. If there is no audio streaming enabled for self connection, by default, it is set to
true
. -
videoMuted
{Boolean} OptionalDEFAULT: trueThe flag that indicates if self connection Stream object video streaming is muted. If there is no video streaming enabled for self connection, by default, it is set to
true
.
-
Example:
SkylinkDemo.muteStream({ audioMuted: true, videoMuted: false });
off
eventName
,
[callback]
,
)
Unsubscribes an event handler associated to the event name.
Parameters:
-
eventName
{String}The Skylink event name to unsubscribe to.
-
callback
{Function} OptionalThe event handler to unsubscribe to the associated Skylink event name. If the event handler is not provided, Skylink would unsubscribe all event handlers subscribed to the associated event name.
Example:
// Example 1: Unsubscribe all event handlers related to the event SkylinkDemo.off("peerJoined");
// Example 2: Unsubscribe to one event handler SkylinkDemo.off("peerJoined", callback);
on
eventName
,
callback
,
)
Subscribes an event handler associated to the event name. This event handler will always be triggered when the event name is triggered. If you are looking for subscription event handler to be triggered once, check out once() event subscription.
Parameters:
-
eventName
{String}The Skylink event name to subscribe to.
-
callback
{Function}The event handler to subsribe to the associated Skylink event name that would be triggered once the event name is triggered.
Example:
SkylinkDemo.on("peerJoined", function (peerId, peerInfo) { alert(peerId + " has joined the room"); });
once
eventName
,
callback
,
[condition]
,
[fireAlways=false]
,
)
Subscribes an event handler associated to the event name that would only be triggered once the provided condition function has been met.
Parameters:
-
eventName
{String}The Skylink event name to subscribe to.
-
callback
{Function}The event handler to subscribe to the associated Skylink event name to trigger once the condition has met. If
fireAlways
option is set toetrue
, this will always be fired when condition is met. -
condition
{Function} OptionalThe condition function that once the condition has been met, trigger the event handler once. Return in the condition function
true
to pass as meeting the condition. If the condition function is not provided, the event handler will be triggered once the Skylink event name is triggered. -
fireAlways
{Boolean} OptionalDEFAULT: falseThe flag that indicates if Skylink should interrupt this
once()
function once the function has been triggered to not unsubscribe the event handler but to always trigger when the condition has been met.
Example:
SkylinkDemo.once("peerConnectionState", function (state, peerId) { alert("Peer has left"); }, function (state, peerId) { return state === SkylinkDemo.PEER_CONNECTION_STATE.CLOSED; });
refreshConnection
[targetPeerId]
,
[callback]
,
)
Refreshes a Peer connection.
- This feature can be used to refresh a Peer connection when the remote Stream received does not stream any audio/video stream.
- If there are more than 1 refresh during 5 seconds or refresh is less than 3 seconds since the last refresh initiated by the other peer, it will be aborted.
- As for MCU connection, the restart mechanism makes the self user leave and join the currently connected room again.
Triggers:
peerRestart, serverPeerRestart, peerJoined, peerLeft, serverPeerJoined, serverPeerLeftParameters:
-
targetPeerId
{String | Array} OptionalThe array of targeted Peers connection to refresh the connection with.
-
callback
{Function} OptionalThe callback fired after all targeted Peers connection has been initiated with refresh or have met with an exception. The callback signature is
function (error, success)
.-
error
{JSON}The error object received in the callback. If received as
null
, it means that there is no errors.-
listOfPeers
{Array}The list of Peers that the refresh connection had been initiated with. -
refreshErrors
{JSON}The list of errors occurred based on per Peer basis. -
refreshErrors.(#peerId)
{Object | String}The Peer ID that is associated with the error that occurred when refreshing the connection.
-
-
success
{JSON}The success object received in the callback. If received as
null
, it means that there are errors.-
listOfPeers
{Array}The list of Peers that the refresh connection had been initiated with.
-
-
Example:
SkylinkDemo.on("iceConnectionState", function (state, peerId)) { if (iceConnectionState === SkylinkDemo.ICE_CONNECTION_STATE.FAILED) { // Do a refresh SkylinkDemo.refreshConnection(peerId); } });
respondBlobRequest
peerId
,
transferId
,
[accept=false]
,
)
source/data-transfer.js:1865
Available since 0.5.0
Responds to a data transfer request by a Peer.
Triggers:
dataTransferState, incomingDataRequest, incomingDataParameters:
-
peerId
{String}The sender Peer ID.
-
transferId
{String}The data transfer ID of the data transfer request to accept or reject.
-
accept
{Boolean} OptionalDEFAULT: falseThe flag that indicates
true
as a response to accept the data transfer andfalse
as a response to reject the data transfer request.
sendBlobData
data
,
[timeout=60]
,
[targetPeerId]
,
[callback]
,
)
Starts a data transfer with Peers using the DataChannel connections with Blob.
- You can transfer files using the
input
fileupload object and accessing the receiving files using FileUpload files property. - The File object inherits from the Blob interface which is passable in this method as a Blob object.
- The receiving Peers have the option to accept or reject the data transfer with acceptDataTransfer().
- For Peers connecting from our mobile platforms
(iOS / Android),
the DataChannel connection channel type would be
DATA_CHANNEL_TYPE.MESSAGING
.
For Peers connecting from the Web platform, the DataChannel connection channel type would beDATA_CHANNEL_TYPE.DATA
.
Triggers:
incomingData, incomingDataRequest, dataTransferState, dataChannelStateParameters:
-
data
{Blob}The Blob data object to transfer to Peer.
-
timeout
{Number} OptionalDEFAULT: 60The waiting timeout in seconds that the DataChannel connection data transfer should wait before throwing an exception and terminating the data transfer.
-
targetPeerId
{String | Array} OptionalThe array of targeted Peers to transfer the data object to. Alternatively, you may provide this parameter as a string to a specific targeted Peer to transfer the data object.
-
callback
{Function} OptionalThe callback fired after all the data transfers is completed successfully or met with an exception. The callback signature is
function (error, success)
.-
error
{JSON}The error object received in the callback. If received as
null
, it means that there is no errors.-
state
{String} OptionalDEFAULT: null Deprecated. The dataTransferState when the error has occurred. This only triggers for a single targeted Peer data transfer. -
error
{Object | String} OptionalDEFAULT: null Deprecated. The error received when the data transfer fails. This only triggers for single targeted Peer data transfer. -
transferId
{String}The transfer ID of the failed data transfer. -
peerId
{String} OptionalDEFAULT: null The single targeted Peer ID for the data transfer. This only triggers for single targeted Peer data transfer. -
listOfPeers
{Array}The list of Peer that the data transfer has been initiated with. -
isPrivate
{Boolean}The flag to indicate if the data transfer is a private transfer to the Peer directly and not broadcasted to all Peers. -
transferErrors
{JSON}The list of errors occurred based on per Peer basis. -
transferErrors.(#peerId)