Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

skylinkjs

Temasys2.9kApache-2.02.7.2

Temasys Web SDK is an open-source client-side library for your web-browser that enables any website to easily leverage the capabilities of WebRTC and its direct data streaming powers between peers for audio/video conferencing or file transfer.

webrtc, real-time, p2p

readme

SKYLINK WEB SDK 2.7.2

Temasys SkylinkJS Web SDK is an open-source client-side library for your web-browser that enables any website to easily leverage the capabilities of WebRTC and its direct data streaming powers between peers for audio/video conferencing.

You'll need a Temasys Account, and an App key to use this. Register here to get your App key.

Supported Browsers

Features Chrome Firefox Safari Edge (Chromium)
Platforms: Win, Mac, Linux, Android Win, Mac, Linux, Android Mac, iOS Win, Mac
Minimum Recommended Versions: 72 66 13 80
Screensharing Yes Yes Yes Yes
Video Call Yes Yes Yes Yes
Audio Call Yes Yes Yes Yes
Messaging Yes Yes Yes Yes
  • (+) Latest browser versions indicates the last tested browser version. It should work with the updated next versions, but if it doesn't, open a bug ticket.

Read more

MCU Behaviour

  • There are certain considerations to note when using an MCU key. Read more here

Need help or want something changed?

Current versions and stability

  • We recommend that you always use the latest versions of the Temasys SkylinkJS Web SDK as WebRTC is still evolving and we adapt to changes very frequently.
  • It is advised to not attach any event handlers to the WebRTC APIs as doing so may override the handlers set in SkylinkJS and result in unexpected behaviour.

Latest version: 2.7.2

How to build your own Temasys SkylinkJS Web SDK

Using Git command line tools, execute the following:

Node version: 20.14.0 (lts/iron)

# 1. Clone or download this repository via git terminal.

git clone https://github.com/Temasys/SkylinkJS.git

# 2. Install all required dependencies. Use (sudo npm install) if required.

npm install

# 3. Run the start script to start a local webserver to access the demo and doc folders. This will popup Chrome (Mac). You can configure a different browser in the start.sh file. Alternatively, you can run (sh start.sh)

npm start # Note that this runs in Chrome currently.

What's included in the repository?

  • demos : Reference Code Examples.
  • docs : Generated documentation for the Temasys Web SDK.
  • temasys-jsdoc-template : Templates used documentation.
  • publish : Production version of the library as well as minified variants
  • src : Temasys Web SDK source

License

APACHE 2.0

changelog

Migration

Description

  • The following guide will help you move your current application code to our new Skylink 2.x SDK.

Migrating from 0.6.x / 0.9.x to 2.x

  • While Skylink 2.x is a major version bump and indicates breaking changes, we kept changes you have to make to a minimum.

Motivations

  • There have been many rapid and welcomed changes on the WebRTC front. In light of that, an update of our SDK was timely and necessary in order to take full advantage of these new changes.

New features

  • Our new SDK is module based with full compatibility with ES6
  • All callbacks have been promisified
  • Multiple rooms support

Importing the SDK

SDK 0.6.x / 0.9.x

Method 1: Include in script tag of index.html

<script src="./path/to/skylink.complete.js"></script>

SDK 2.x

Method 1: Import as type module in script tag of index.html

 <script type="module">
    import Skylink, { SkylinkEventManager, SkylinkLogger, SkylinkConstants } from 'https://cdn.temasys.io/skylink/skylinkjs/latest/skylink.complete.js'; 
    window.Skylink = Skylink; // assign to the window object if Skylink needs to be accessed in other scripts
 </script>
 <script src="index.js" type="module"></script>
  • access Skylink class in index.js or directly in the script tag
    const skylink = new Skylink(config);
    Method 2: Import in index.js
  • from cdn
    import Skylink, { SkylinkEventManager, SkylinkLogger, SkylinkConstants } from 'https://cdn.temasys.io/skylink/skylinkjs/latest/skylink.complete.js';
    const skylink = new Skylink(config);
  • from NPM module
    import Skylink, { SkylinkEventManager, SkylinkLogger, SkylinkConstants } from 'skylinkjs';
    const skylink = new Skylink(config);
  • reference index.js as type module in index.html
    <script src="index.js" type="module"></script>

Including dependencies

SDK 0.6.x / 0.9.x

socket.io and adapterjs dependency is bundled into skylink.complete.js

SDK 2.x

socket.io dependency is no longer bundled into skylink.complete.js

Include socket.io in script tag.

 <script src="./path/to/socket.io.js"></script>

socket.io.js can be obtained from the socket.io cdn. Check that the version is 2.2.0

SDK 0.6.x / 0.9.x

Step 1: Instantiate Skylink

skylink = new Skylink();

Step 2: Init Skylink with config and call joinRoom in success callback function

const config = {
    appKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX',
    defaultRoom: 'skylinkRoom',
    enableDataChannel: true,
    forceSSL: true,
};

const joinRoomOptions = {
    audio: { stereo: true },
    video: true,
};

skylink.init(config, function (error, success) {
    if (success) {
        skylink.joinRoom(joinRoomOptions);
    }
});

Step 3: Listen on 'incomingStream' event with isSelf=true for self MediaStream

skylink.on('incomingStream', function(peerId, stream, isSelf, peerInfo) {
    // do something
});

Step 4: Listen on 'peerJoined' event with isSelf=true for self join room success outcome

skylink.on('peerJoined', function(peerId, peerInfo, isSelf) {
    // do something
});

SDK 2.x

Step 1: Instantiate Skylink and init with config

const config = {
    appKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX',
    defaultRoom: 'skylinkRoom',
    enableDataChannel: true,
    forceSSL: true,
};

skylink = new Skylink(config);

Step 2: Call joinRoom with options and obtain MediaStreams from Promise resolve

const joinRoomOptions = {
    audio: { stereo: true },
    video: true,
};

skylink.joinRoom(joinRoomOptions)
.then((streams) => {
    // if there is an audio stream
    if (streams[0]) {
        window.attachMediaStream(audioEl, streams[0]);
    }
    // if there is a video stream
    if (streams[1]) {
        window.attachMediaStream(videoEl, streams[1]);
    }
})
.catch();

Step 3: Listen on 'peerJoined' event with isSelf=true for self join room success outcome

SkylinkEventManager.addEventListener(SkylinkConstants.EVENTS.PEER_JOINED, (evt) => {
    const { isSelf, peerId, peerInfo } = evt.detail;
    // do something
});

Event Handling

SDK 0.6.x / 0.9.x

Subscribing to an event

skylink.on('peerJoined', function(peerId, peerInfo, isSelf) {
    // do something
});

Unsubscribing from an event

skylink.off('peerJoined');

SDK 2.x

Subscribing to an event

const peerJoinedHandler = (evt) => {
    const { isSelf, peerId, peerInfo } = evt.detail;
    // do something
};

SkylinkEventManager.addEventListener(SkylinkConstants.EVENTS.PEER_JOINED, peerJoinedHandler);

Unsubscribing from an event

SkylinkEventManager.removeEventListener(SkylinkConstants.EVENTS.PEER_JOINED, peerJoinedHandler);

Logging

SDK 0.6.x / 0.9.x

skylink.setLogLevel(skylink.LOG_LEVEL.DEBUG);

SDK 2.x

SkylinkLogger.setLevel(SkylinkLogger.logLevels.DEBUG);

Changed APIs

Key Description
UNCHANGED Params unchanged
NEW New method
PARAM Params changed
RENAME Method renamed
PROMISIFIED Callback promisified
NOT IMPLEMENTED Method not implemented in the current release
DEPRECATED Deprecated

| |0.6.x / 0.9.x | | 2.x | | |----------------------------|----------------------------------------------------------------------------------|------------------|---------------|---------------------------------------| |Methods |Params |Status |Renamed to |Params | |init |( options , callback ) | DEPRECATED | | | |joinRoom |( room , options , callback ) | PROMISIFIED, PARAM| |( options , prefetchedStream ) | |leaveRoom |( stopMediaOptions=true , callback ) | PROMISIFIED, PARAM| |( roomName ) | |lockRoom() |() | PARAM | |( roomName ) | |unlockRoom |() | PARAM | |( roomName ) | |leaveAllRooms | | NEW | |() | |introducePeer |( sendingPeerId , receivingPeerId ) | NOT IMPLEMENTED | | | |getConnectionStatus |( targetPeerId , callback ) | PROMISIFIED, PARAM| |( roomName , peerId ) | |sendMessage |( message , targetPeerId ) | PARAM | |( roomName , message , targetPeerId )| |sendP2PMessage |( message , targetPeerId ) | PARAM | |( roomName , message , targetPeerId )| |getMessageHistory |() | NOT IMPLEMENTED | | | |getPeerCustomSettings |() | PARAM | |( roomName ) | |getPeerInfo |( peerId ) | PARAM | |( roomName , peerId ) | |getPeers |( showAll=false , callback ) | PROMISIFIED, PARAM| |( roomName , showAll = false ) | |getPeersInRoom |() | PARAM | |( roomName ) | |getPeersStream |() | PARAM, RENAME |getPeersStreams|( roomName , includeSelf = true ) | |getUserData |( peerId ) | PARAM | |( roomName, peerId ) | |getStreams | | NEW | |( roomName ) | |setUserData |( userData ) | PARAM | |( roomName, userData ) | |getUserMedia |( options , callback ) | PROMISIFIED, PARAM| |( options , options ) | |muteStream |( options ) | PARAM, RENAME |muteStreams |( roomName , options , streamId ) | |sendStream |( options , callback ) | PROMISIFIED, PARAM| |( roomName , options ) | |shareScreen |( enableAudio=false , mediaSource=screen , callback ) | PARAM | |( roomName ) | |stopScreen |() | PARAM | |( roomName ) | |stopStream |() | PARAM, RENAME |stopStreams |( roomName , streamId ) | |getPeersScreenshare | | NEW | |( roomName ) | |stopPrefetchedStream | | NEW | |( stream ) | |acceptDataTransfer |( peerId , transferId , accept=false ) | NOT IMPLEMENTED | | | |cancelDataTransfer |( peerId , transferId ) | NOT IMPLEMENTED | | | |getCurrentDataStreamsSession|() | NOT IMPLEMENTED | | | |getCurrentDataTransfers |() | NOT IMPLEMENTED | | | |getPeersDatachannels |() | PARAM | |( roomName ) | |refreshDatachannel |( peerId ) | PARAM | |( roomName , peerId ) | |sendBlobData |( data , timeout=60 , targetPeerId , sendChunksAsBinary=false , callback )| NOT IMPLEMENTED | | | |sendURLData |( data , timeout = 60 , targetPeerId , callback ) | NOT IMPLEMENTED | | | |startStreamingData |( isStringStream=false , targetPeerId ) | NOT IMPLEMENTED | | | |stopStreamingData |( streamId ) | NOT IMPLEMENTED | | | |streamData |( streamId , chunk ) | NOT IMPLEMENTED | | | |getRecordings |() | PARAM | |( roomName ) | |startRecording |( callback ) | PROMISIFIED, PARAM| |( roomName ) | |stopRecording |( callback , callbackSuccessWhenLink=false ) | PROMISIFIED, PARAM| |( roomName ) | |startRTMPSession |( callback ) | PROMISIFIED, PARAM| |( roomName , streamId , endpoint) | |stopRTMPSession |( callback ) | PROMISIFIED, PARAM| |( roomName , rtmpId ) | |generateUUID |() | UNCHANGED | |() | |getScreenSources |( callback ) | PROMISIFIED, PARAM| |() | |getStreamSources |( callback ) | PROMISIFIED, PARAM| |() | |off |( eventName , callback ) | DEPRECATED | | | |on |( eventName , callback ) | DEPRECATED | | | |once |( eventName , callback , condition , fireAlways=false ) | DEPRECATED | | | |setDebugMode |( options = false ) | NOT IMPLEMENTED | | | |setLogLevel |( logLevel ) | DEPRECATED | | |