Constructor
new Skylink(options)
Creates a SkylinkJS instance.
Parameters:
Name | Type | Description |
---|---|---|
options |
initOptions |
Skylink authentication and initialisation configuration options. |
Example
import Skylink from 'skylinkjs';
const initOptions = {
// Obtain your app key from https://console.temasys.io
appKey: 'temasys-appKey-XXXXX-XXXXXX',
defaultRoom: "Default_Room",
};
const skylink = new Skylink(initOptions);
Methods
deleteEncryptSecrets(roomName, secretIdopt)
Method that deletes an encrypt secret.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
roomName |
String |
The room name. |
|
secretId |
String |
<optional> |
The id of the secret to be deleted. If no secret id is provided, all secrets will be deleted. |
- Since:
-
- 2.0.0
- Source:
generateUUID() → {String}
Method that generates an UUID (Unique ID).
- Since:
-
- 0.5.9
- Source:
getConnectionStats(roomName, peerIdopt) → {Promise.<Array.<object.<(String|statistics)>>>}
Method that retrieves peer connection bandwidth and ICE connection stats.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
roomName |
String |
The room name. |
|
peerId |
String | Array |
<optional> |
The target peer id to retrieve connection stats from.
|
- Source:
Examples
Example 1: Retrieving connection statistics from all peers in a room
skylink.getConnectionStatus("Room_1")
.then((statistics) => {
// handle statistics
}
.catch((error) => {
// handle error
}
Example 2: Retrieving connection statistics from selected peers
const selectedPeers = ["peerId_1", "peerId_2"];
skylink.getConnectionStatus("Room_1", selectedPeers)
.then((statistics) => {
// handle statistics
}
.catch((error) => {
// handle error
}
getEncryptSecrets(roomName) → {Object|Object}
Method that returns all the secret and secret id pairs.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
- Since:
-
- 2.0.0
- Source:
getPeerInfo(roomName, peerIdopt) → {peerInfo|null}
Method that returns the user / peer current session information.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
roomName |
String |
The name of the room. |
||
peerId |
String | null |
<optional> |
null |
The peer id to return the current session information from.
|
- Source:
Examples
Example 1: Get peer current session information
const peerPeerInfo = skylink.getPeerInfo(peerId);
Example 2: Get user current session information
const userPeerInfo = skylink.getPeerInfo();
getPeers(roomName, showAllopt) → {Promise.<Object.<String, Array.<String>>>}
Method that retrieves the list of peer ids from rooms within the same App space.
Note that this feature requires"isPrivileged"
flag to be enabled for the App Key provided in theinitOptions
, as only Users connecting using the App Key with this flag enabled (which we call privileged Users / peers) can retrieve the list of peer ids from rooms within the same App space. What is a privileged key?
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
roomName |
String |
The room name |
||
showAll |
Boolean |
<optional> |
false |
The flag if Signaling server should also return the list of privileged peer ids. By default, the Signaling server does not include the list of privileged peer ids in the return result. |
- Since:
-
- 0.6.1
- Source:
Fires:
-
getPeersStateChangeEvent
with parameter payloadstate=ENQUIRED
upon callinggetPeers
method. -
getPeersStateChangeEvent
with parameter payloadstate=RECEIVED
when peer list is received from Signaling server.
Example
Example 1: Retrieve un-privileged peers
skylink.getPeers(location)
.then((result) => {
// do something
})
.catch((error) => {
// handle error
})
Example 2: Retrieve all (privileged and un-privileged) peers
skylink.getPeers(location, true)
.then((result) => {
// do something
})
.catch((error) => {
// handle error
})
getPeersCustomSettings(roomName) → {Object.<String, customSettings>|null}
Method that gets the list of current custom peer settings sent and set.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
- Since:
-
- 0.6.18
- Source:
Example
Example 1: Get the list of current peer custom settings from peers in a room.
const currentPeerSettings = skylink.getPeersCustomSettings("Room_1");
getPeersDataChannels(roomName) → {Object.<string, Object.<String, dataChannelInfo>>}
Method that gets the current list of connected peers data channel connections in the room.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
- Since:
-
- 0.6.18
- Source:
Example
Example 1: Get the list of current peers data channels in the same room
const channels = skylink.getPeersDataChannels("Room_1");
getPeersInRoom(roomName) → {JSON.<String, peerInfo>|null}
Method that gets the list of connected peers in the room.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The name of the room. |
- Source:
Example
Example 1: Get the list of currently connected peers in the same room
const peers = skylink.getPeersInRoom();
getPeersScreenshare(roomName) → {Object.<String, MediaStream>|null}
Method that returns the screenshare stream id of peers.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
- Since:
-
- 2.0.0
- Source:
getRecordings(roomName) → {recordingSessions|Object}
Method that retrieves the list of recording sessions.
Note that this feature requires MCU and recording to be enabled for the App Key provided in
initOptions
. If recording feature is not available to be enabled in the Temasys Developer Console,
please contact us on our support portal here.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
- Since:
-
- 0.6.16
- Source:
getScreenSources() → {Promise.<screenSources>}
Method that returns the screensharing sources.
- Since:
-
- 2.0.0
- Source:
getSelectedSecret(roomName, secretId) → {String}
Method that returns the secret used in encrypting and decrypting messages.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
secretId |
String |
The id of the secret. |
- Since:
-
- 2.0.0
- Source:
getStoredMessages(roomName)
Method that retrieves the message history from server if Persistent Message feature is enabled for the key.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The name of the room. |
- Since:
-
- 2.1
- Source:
Fires:
Example
Example 1: Retrieving stored messages
// add event listener to catch storedMessages event
SkylinkEventManager.addEventListener(SkylinkConstants.EVENTS.STORED_MESSAGES, (evt) => {
const { storedMessages } = evt.detail;
storedMessages.content.forEach((message) => {
// do something
})
});
let getStoredMessages = (roomName) => {
this.skylink.getStoredMessages(roomName);
}
getStreams(roomName) → {streamList|null}
Method that returns all active user streams including screenshare stream if present.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
- Since:
-
- 2.0.0
- Source:
getStreamSources() → {Promise.<streamSources>}
Method that returns the camera and microphone sources.
- Source:
getUserData(roomName, peerIdopt) → {Object|null}
Method that returns the user / peer current custom data.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
roomName |
String |
The room name. |
|
peerId |
String |
<optional> |
The peer id to return the current custom data from.
|
- Source:
Examples
Example 1: Get peer current custom data
const peerUserData = skylink.getUserData(peerId);
Example 2: Get user current custom data
const userUserData = skylink.getUserData();
getUserMedia(roomName, optionsopt) → {Promise.<MediaStreams>}
Method that retrieves camera stream.
Resolves with an array of MediaStreams
. First item in array is MediaStream
of kind audio and second item is
MediaStream
of kind video.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
roomName |
String | null | null |
The room name.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
JSON |
<optional> |
The camera stream configuration options.
Properties
|
- Since:
-
- 0.5.6
- Source:
Fires:
-
If retrieval of fallback audio stream is successful:
-mediaAccessSuccessEvent
with parameter payloadisScreensharing=false
andisAudioFallback=false
if initial retrieval is successful. -
If initial retrieval is unsuccessful:
Fallback to retrieve audio only stream is triggered (configured ininitOptions
audioFallback
)
-mediaAccessFallbackEvent
with parameter payloadstate=FALLBACKING
,isScreensharing=false
andisAudioFallback=true
andoptions.video=true
andoptions.audio=true
.
No fallback to retrieve audio only stream
-mediaAccessErrorEvent
with parameter payloadisScreensharing=false
andisAudioFallbackError=false
. -
If retrieval of fallback audio stream is successful:
-mediaAccessSuccessEvent
with parameter payloadisScreensharing=false
andisAudioFallback=true
. -
If retrieval of fallback audio stream is unsuccessful:
-mediaAccessFallbackEvent
with parameter payloadstate=ERROR
,isScreensharing=false
andisAudioFallback=true
.
-mediaAccessErrorEvent
with parameter payloadisScreensharing=false
andisAudioFallbackError=true
.
Examples
Example 1: Get both audio and video after joinRoom
skylink.getUserMedia(roomName, {
audio: true,
video: true,
}).then((streams) => // do something)
.catch((error) => // handle error);
Example 2: Get only audio
skylink.getUserMedia(roomName, {
audio: true,
video: false,
}).then((streams) => // do something)
.catch((error) => // handle error);
Example 3: Configure resolution for video
skylink.getUserMedia(roomName, {
audio: true,
video: { resolution: skylinkConstants.VIDEO_RESOLUTION.HD },
}).then((streams) => // do something)
.catch((error) => // handle error);
Example 4: Configure stereo flag for OPUS codec audio (OPUS is always used by default)
this.skylink.getUserMedia(roomName, {
audio: {
stereo: true,
},
video: true,
}).then((streams) => // do something)
.catch((error) => // handle error);
Example 5: Get both audio and video before joinRoom
// Note: the prefetched stream must be maintained independently
skylink.getUserMedia({
audio: true,
video: true,
}).then((streams) => // do something)
.catch((error) => // handle error);
Example 6: Get media sources before joinRoom - only available on Chrome browsers
const audioInputDevices = [];
const videoInputDevices = [];
navigator.mediaDevices.enumerateDevices().then((devices) => {
devices.forEach((device) => {
if (device.kind === "audioinput") {
audioInputDevices.push(device);
}
if (device.kind === "videoinput") {
videoInputDevices.push(device);
}
})
}).catch((error) => // handle error);
skylink.getUserMedia(roomName, {
audio: {
deviceId: audioInputDevices[0].deviceId,
},
video: {
deviceId: videoInputDevices[0].deviceId,
}
}).then((streams) => // do something)
.catch((error) => // handle error);
(async) joinRoom(optionsopt, prefetchedStreamopt) → {Promise.<MediaStreams>}
Method that starts a room session.
Resolves with an array of MediaStreams
or null if pre-fetched
stream was passed into joinRoom
method. First item in array is MediaStream
of kind audio and second item is
MediaStream
of kind video.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
joinRoomOptions |
<optional> |
The options available to join the room and configure the session. |
prefetchedStream |
MediaStream |
<optional> |
The pre-fetched media stream object obtained when the user calls |
- Source:
Examples
Example 1: Calling joinRoom with options
const joinRoomOptions = {
audio: true,
video: true,
roomName: "Room_1",
userData: {
username: "GuestUser_1"
},
};
skylink.joinRoom(joinRoomOptions)
.then((streams) => {
if (streams[0]) {
window.attachMediaStream(audioEl, streams[0]); // first item in array is an audio stream
}
if (streams[1]) {
window.attachMediaStream(videoEl, streams[1]); // second item in array is a video stream
}
})
.catch((error) => {
// handle error
});
Example 2: Retrieving a pre-fetched stream before calling joinRoom
// REF: getUserMedia
const prefetchedStream = skylink.getUserMedia();
skylink.joinRoom(prefetchedStream)
.catch((error) => {
// handle error
});
leaveAllRooms() → {Promise.<Array.<String>>}
Method that stops all room sessions.
- Since:
-
- 2.0.0
- Source:
leaveRoom(roomName) → {Promise.<String>}
Method that stops the room session.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name to leave. |
- Since:
-
- 0.5.5
- Source:
Fires:
-
peerLeft
on the remote end of the connection.
Example
Example 1:
// add event listener to catch peerLeft events when remote peer leaves room
SkylinkEventManager.addEventListener(SkylinkConstants.EVENTS.PEER_LEFT, (evt) => {
const { detail } = evt;
// handle remote peer left
});
skylink.leaveRoom(roomName)
.then((roomName) => {
// handle local peer left
})
.catch((error) => // handle error);
lockRoom(roomName) → {Boolean}
Method that locks a room.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
- Since:
-
- 0.5.0
- Source:
Fires:
-
roomLockEvent
with payload parametersisLocked=true
when the room is successfully locked.
Example
// add event listener to listen for room locked state when peer tries to join a locked room
skylinkEventManager.addEventListener(SkylinkEvents.SYSTEM_ACTION, (evt) => {
const { detail } = evt;
if (detail.reason === SkylinkConstants.SYSTEM_ACTION.LOCKED') {
// handle event
}
}
// add event listener to listen for room locked/unlocked event after calling lockRoom method
skylinkEventManager.addEventListener(SkylinkEvents.ROOM_LOCK, (evt) => {
const { detail } = evt;
if (detail.isLocked) {
// handle room lock event
} else {
// handle room unlock event
}
}
skylink.lockRoom(roomName);
muteStreams(roomName, options, streamIdopt) → {null}
Method that mutes both userMedia
[getUserMedia
] stream and
screen
[shareScreen
] stream.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
roomName |
String |
The room name. |
||||||||||||||||
options |
JSON |
The streams muting options. Properties
|
||||||||||||||||
streamId |
String |
<optional> |
The id of the stream to mute. |
- Since:
-
- 0.5.7
- Source:
Fires:
-
On local peer:
localMediaMutedEvent
,streamMuted
,peerUpdatedEvent
with payload parametersisSelf=true
andisAudio=true
if a local audio stream is muted orisVideo
if local video stream is muted. -
On remote peer:
streamMuted
,peerUpdatedEvent
with with parameter payloadisSelf=false
andisAudio=true
if a remote audio stream is muted orisVideo
if remote video stream is muted.
Examples
Example 1: Mute both audio and video tracks in all streams
skylink.muteStreams(roomName, {
audioMuted: true,
videoMuted: true
});
Example 2: Mute only audio tracks in all streams
skylink.muteStreams(roomName, {
audioMuted: true,
videoMuted: false
});
Example 3: Mute only video tracks in all streams
skylink.muteStreams(roomName, {
audioMuted: false,
videoMuted: true
});
refreshConnection(roomName, targetPeerIdopt, iceRestartopt, optionsopt) → {Promise.<refreshConnectionResolve>}
Method that refreshes peer connections to update with the current streaming.
Note that Edge browser does not support renegotiation. For MCU enabled peer connections withoptions.mcuUseRenegoRestart
set tofalse
in theinitOptions
, the restart method may differ, you may learn more about how to workaround it in this article here. For restarts with peers connecting from Android, iOS or C++ SDKs, restarts might not work as written in this article here. Note that this functionality should be used when peer connection stream freezes during a connection. For a better user experience for only MCU enabled peer connections, the method is throttled when invoked many times in less than the milliseconds interval configured ininitOptions
.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
roomName |
String |
The name of the room. |
||||||||||||||
targetPeerId |
String | Array |
<optional> |
Note that this is ignored if MCU is enabled for the App Key provided in
|
|||||||||||||
iceRestart |
Boolean |
<optional> |
false |
Note that this flag will not be honoured for MCU enabled peer connections whereThe flag if ICE connections should restart when refreshing peer connections. This is used when ICE connection state is FAILED or DISCONNECTED , which state
can be retrieved with the iceConnectionStateEvent
|
||||||||||||
options |
JSON |
<optional> |
Note that for MCU connections, theThe custom peer configuration settings. Properties
|
- Since:
-
- 0.5.5
- Source:
Examples
Example 1: Refreshing a peer connection
skylink.refreshConnection(roomName, peerId)
.then((result) => {
const failedRefreshIds = Object.keys(result.refreshErrors);
failedRefreshIds.forEach((peerId) => {
// handle error
});
});
Example 2: Refreshing a list of peer connections
let selectedPeers = ["peerID_1", "peerID_2"];
skylink.refreshConnection(roomName, selectedPeers)
.then((result) => {
const failedRefreshIds = Object.keys(result.refreshErrors);
failedRefreshIds.forEach((peerId) => {
// handle error
});
});
Example 3: Refreshing all peer connections
skylink.refreshConnection(roomName)
.then((result) => {
const failedRefreshIds = Object.keys(result.refreshErrors);
failedRefreshIds.forEach((peerId) => {
// handle error
});
});
refreshDatachannel(roomName, peerId) → {null}
Method that refreshes the main messaging data channel.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
peerId |
String |
The target peer id of the peer data channel to refresh. |
- Since:
-
- 0.6.30
- Source:
sendMessage(roomName, message, targetPeerIdopt)
Function that sends a message to peers via the Signaling socket connection.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
roomName |
String |
room name to send the message. |
|
message |
String | JSON |
The message. |
|
targetPeerId |
String | Array |
<optional> |
The target peer id to send message to.
|
- Since:
-
- 0.4.0
- Source:
Fires:
Examples
Example 1: Broadcasting to all peers
let sendMessage = (roomName) => {
const message = "Hi!";
const selectedPeers = this.state[location]['selectedPeers'];
this.skylink.sendMessage(roomName, message, selectedPeers);
}
Example 2: Broadcasting to selected peers
let sendMessage = (roomName) => {
const message = "Hi all!";
const selectedPeers = ["PeerID_1", "PeerID_2"];
this.skylink.sendMessage(roomName, message, selectedPeers);
}
sendP2PMessage(roomNameopt, message, targetPeerIdopt)
Method that sends a message to peers via the data channel connection.
Consider using sendURLData
if you are sending large strings to peers.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
roomName |
String |
<optional> |
The name of the room the message is intended for. When not provided, the message will be broadcast to all rooms where targetPeerId(s) are found (if provided). Note when roomName is provided, targetPeerId should be provided as null. |
message |
String | JSON |
The message. |
|
targetPeerId |
String | Array |
<optional> |
The target peer id to send message to. When provided as an Array, it will send the message to only peers which ids are in the list. When not provided, it will broadcast the message to all connected peers with data channel connection in a room. |
- Source:
Fires:
Examples
Example 1: Broadcasting to all peers in all rooms
const message = "Hello everyone!";
skylink.sendP2PMessage(message);
Example 2: Broadcasting to all peers in a room
const message = "Hello everyone!";
const roomName = "Room_1";
skylink.sendP2PMessage(message, null, roomName);
Example 3: Sending message to a peer in all rooms
const message = "Hello!";
const targetPeerId = "peerId";
skylink.sendP2PMessage(message, targetPeerId);
Example 4: Sending message to a peer in a room
const message = "Hello!";
const targetPeerId = "peerId";
const roomName = "Room_1";
skylink.sendP2PMessage(message, targetPeerId, roomName);
Example 5: Sending message to selected Peers in a room
const message = "Hello!";
const selectedPeers = ["peerId_1", "peerId_2"];
const roomName = "Room_1";
skylink.sendP2PMessage(message, selectedPeers, roomName);
// Listen for onIncomingMessage event
skylink.addEventListener(SkylinkEvents.ON_INCOMING_MESSAGE, (evt) => {
const detail = evt.detail;
if (detail.isSelf) {
// handle message from self
} else {
// handle message from remote peer
}
}
sendStream(roomName, options) → {Promise.<MediaStreams>}
Method that sends a new userMedia
stream to all connected peers in a room.
Resolves with an array of MediaStreams
. First item in array is MediaStream
of kind audio and second item is
MediaStream
of kind video.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
options |
JSON | MediaStream |
The
|
- Since:
-
- 0.5.6
- Source:
Fires:
-
SkylinkEvents.event:mediaAccessSuccess
with parameter payloadisScreensharing=false
andisAudioFallback=false
ifuserMedia
options
is passed intosendStream
method.event: -
SkylinkEvents.event:onIncomingStream
with parameter payloadisSelf=true
andstream
asuserMedia
stream.event: -
SkylinkEvents.event:peerUpdated
with parameter payloadisSelf=true
.
Example
Example 1: Send new MediaStream with audio and video
let sendStream = (roomName) => {
const options = { audio: true, video: true };
// Add listener to incomingStream event
SkylinkEventManager.addEventListener(SkylinkConstants.EVENTS.ON_INCOMING_STREAM, (evt) => {
const { detail } = evt;
window.attachMediaStream(localVideoEl, detail.stream);
})
skylink.sendStream(roomName, options)
// streams can also be obtained from resolved promise
.then((streams) => {
if (streams[0]) {
window.attachMediaStream(audioEl, streams[0]); // first item in array is an audio stream
}
if (streams[1]) {
window.attachMediaStream(videoEl, streams[1]); // second item in array is a video stream
}
})
.catch((error) => { console.error(error) });
}
Example 2: Use pre-fetched media streams
const prefetchedStreams = null;
skylink.getUserMedia(null, {
audio: { stereo: true },
video: true,
})
.then((streams) => {
prefetchedStream = streams
});
skylink.sendStream(roomName, prefetchedStreams)
.catch((error) => { console.error(error) });
}
setEncryptSecret(roomName, secret, secretId)
Method that stores a secret and secret id pair used for encrypting and decrypting messages.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
secret |
String |
A secret to use for encrypting and decrypting messages. |
secretId |
String |
The id of the secret. |
- Since:
-
- 2.0.0
- Source:
setSelectedSecret(roomName, secretId)
Method that sets the secret to be used in encrypting and decrypting messages.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
secretId |
String |
The id of the secret to be used for encrypting and decrypting messages. |
- Since:
-
- 2.0.0
- Source:
setUserData(roomName, userData)
Method that overwrites the user current custom data.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
userData |
JSON | String |
The updated custom data. |
- Source:
Fires:
-
peerUpdatedEvent
event if peer is in room withisSelf=true
.
Example
Example 1: Update user custom data after joinRoom()
// add event listener to catch setUserData changes
SkylinkEventManager.addEventListener(SkylinkConstants.peerUpdated, (evt) => {
const { detail } = evt;
// do something
});
const userData = "afterjoin";
skylink.setUserData(userData);
shareScreen(roomName, replaceUserMediaStream, streamIdopt) → {MediaStream|null}
Method that returns starts screenshare and returns the stream.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
roomName |
String |
The room name. |
|
replaceUserMediaStream |
Boolean |
The flag if screenshare replaces the |
|
streamId |
String |
<optional> |
The stream id of the |
- Since:
-
- 2.0.0
- Source:
Example
Example 1: Replace selected stream with screen share stream
let shareScreenReplace = () => {
// Retrieve all userMedia streams
const streamList = skylink.getStreams(roomName);
skylink.shareScreen(roomName, true, Object.keys(streamList.userMedia)[0]).then((screenStream) => {
window.attachMediaStream(localVideoElement, screenStream);
});
}
startRecording(roomName) → {Promise.<String>}
Method that starts a recording session.
Note that this feature requires MCU and recording to be enabled for the App Key provided in
initOptions
. If recording feature is not available to
be enabled in the Temasys Developer Console, please contact us on our support portal here.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
- Since:
-
- 0.6.16
- Source:
Fires:
-
recordingStateEvent
with payloadstate=START
if recording has started successfully. -
recordingStateEvent
with payloaderror
if an error occurred during recording.
Example
Example 1: Start a recording session
skylink.startRecording(roomName)
.then(recordingId => {
// do something
})
.catch(error => {
// handle error
});
startRTMPSession(roomName, streamId, endpoint) → {Promise.<String>}
Method that starts a RTMP session. [Beta]
Note that this feature requires MCU to be enabled for the App Key provided in the
initOptions
.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
streamId |
String |
The stream id to live stream for the session. |
endpoint |
String |
The RTMP endpoint. |
- Since:
-
- 0.6.36
- Source:
Fires:
-
rtmpStateEvent
with parameter payloadstate=START
.
Example
Example 1: Start a rtmp session
skylink.startRTMPSession(roomName, streamId, endpoint)
.then(rtmpId => {
// do something
})
.catch(error => {
// handle error
});
stopRecording(roomName) → {Promise.<String>}
Method that stops a recording session.
- Note that this feature requires MCU and recording to be enabled for the App Key provided in the
initOptions
. If recording feature is not available to be enabled in the Temasys Developer Console, please contact us on our support portal here.- It is mandatory for the recording session to have elapsed for more than 4 minutes before calling
stopRecording
method.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
- Since:
-
- 0.6.16
- Source:
Fires:
-
recordingStateEvent
with payloadstate=STOP
if recording has stopped successfully. -
recordingStateEvent
with payloaderror
if an error occurred during recording.
Example
Example 1: Stop the recording session
skylink.stopRecording(roomName)
.then(recordingId => {
// do something
})
.catch(error => {
// handle error
});
stopRTMPSession(roomName, rtmpId) → {Promise.<String>}
Method that stops a RTMP session. [Beta]
Note that this feature requires MCU to be enabled for the App Key provided in initOptions
.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
rtmpId |
String |
The RTMP session id. |
- Since:
-
- 0.6.36
- Source:
Fires:
-
rtmpStateEvent
with parameter payloadstate=STOP
.
Example
Example 1: Stop rtmp session
skylink.stopRTMPSession(roomName, rtmpId)
.then(rtmpId => {
// do something
})
.catch(error => {
// handle error
});
stopScreen(roomName) → {null}
Method that stops the screen share stream returned from shareScreen
method.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
- Since:
-
- 0.6.0
- Source:
Fires:
-
mediaAccessStoppedEvent
with parameter payloadisScreensharing
value astrue
andisAudioFallback
value asfalse
if there is a screen stream -
streamEndedEvent
with parameter payloadisSelf
value astrue
andisScreensharing
value astrue
if user is in the room -
peerUpdatedEvent
with parameter payloadisSelf
value astrue
-
onIncomingStreamEvent
with parameter payloadisSelf
value astrue
andstream
asSkylink#event:getUserMedia
stream if there is an existinguserMedia
stream
stopStreams(roomName, streamId) → {Promise}
Method that stops the userMedia
stream returned from getUserMedia
method.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
streamId |
String |
The stream id of the stream to stop. If streamId is not set, all |
- Since:
-
- 0.5.6
- Source:
Fires:
-
mediaAccessStoppedEvent
with parameter payloadisSelf=true
andisScreensharing=false
if there is agetUserMedia
stream. -
streamEndedEvent
with parameter payloadisSelf=true
andisScreensharing=false
if there is agetUserMedia
stream and user is in a room. -
peerUpdatedEvent
with parameter payloadisSelf=true
.
unlockRoom(roomName) → {Boolean}
Method that unlocks a room.
Parameters:
Name | Type | Description |
---|---|---|
roomName |
String |
The room name. |
- Since:
-
- 0.5.0
- Source:
Fires:
-
roomLockEvent
with payload parametersisLocked=false
when the room is successfully locked.