Skip to content

Commit

Permalink
Merged in pre-prod-2-0 (pull request #443)
Browse files Browse the repository at this point in the history
Release 2.4.0
  • Loading branch information
dinawee committed Oct 18, 2021
2 parents 6d46389 + 873c8ea commit 3262987
Show file tree
Hide file tree
Showing 274 changed files with 11,699 additions and 10,270 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SKYLINK WEB SDK 2.3.2
# SKYLINK WEB SDK 2.4.0
> 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](https://console.temasys.io).
Expand Down Expand Up @@ -34,7 +34,7 @@ You'll need a Temasys Account, and an App key to use this. [Register here to get
- 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.3.2](https://github.com/Temasys/SkylinkJS/releases/tag/2.3.2)
[Latest version: 2.4.0](https://github.com/Temasys/SkylinkJS/releases/tag/2.4.0)


## How to build your own Temasys SkylinkJS Web SDK
Expand Down
4 changes: 2 additions & 2 deletions docs/SkylinkConstants.html
Original file line number Diff line number Diff line change
Expand Up @@ -4599,7 +4599,7 @@ <h5 class="subsection-title">Properties:</h5>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="constants.js.html">constants.js</a>, <a href="constants.js.html#line1883">line 1883</a>
<a href="constants.js.html">constants.js</a>, <a href="constants.js.html#line1884">line 1884</a>
</li>
</ul>
</dd>
Expand Down Expand Up @@ -5073,7 +5073,7 @@ <h5 class="subsection-title">Properties:</h5>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="constants.js.html">constants.js</a>, <a href="constants.js.html#line1830">line 1830</a>
<a href="constants.js.html">constants.js</a>, <a href="constants.js.html#line1831">line 1831</a>
</li>
</ul>
</dd>
Expand Down
23 changes: 23 additions & 0 deletions docs/constants.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,7 @@ <h1 class="page-title">
ASYNC_MESSAGING: 'ASYNC MESSAGING',
ENCRYPTED_MESSAGING: 'ENCRYPTED MESSAGING',
STATS: 'STATS',
NEGOTIATION: 'NEGOTIATION',
};

/**
Expand Down Expand Up @@ -2166,6 +2167,28 @@ <h1 class="page-title">
SOCKET: 'SOCKET',
};

/**
* The negotiation states for the negotiation state machine
* @type {{WELCOMING: string, LOCAL_OFFER_SENT: string, REMOTE_OFFER_SET: string, REMOTE_ANSWER_RECEIVED: string, LOCAL_OFFER_SET: string, REMOTE_OFFER_RECEIVED: string, LOCAL_ANSWER_SET: string, ENTERING: string, NEGOTIATED: string, REMOTE_ANSWER_SET: string}}
* @private
* @constant
* @readonly
* @memberOf SkylinkConstants
* @since 2.3.3
*/
export const NEGOTIATION_STATES = {
ENTERING: 'entering',
WELCOMING: 'welcoming',
LOCAL_OFFER_SENT: 'localOfferSent',
LOCAL_OFFER_SET: ' localOfferSet',
REMOTE_OFFER_RECEIVED: 'remoteOfferReceived',
REMOTE_ANSWER_RECEIVED: 'remoteAnswerReceived',
REMOTE_OFFER_SET: 'remoteOfferSet',
LOCAL_ANSWER_SET: 'localAnswerSet',
REMOTE_ANSWER_SET: 'remoteAnswerSet',
NEGOTIATED: 'negotiated',
};

export const EVENTS = SkylinkEventsConstants;
</code></pre>
</article>
Expand Down
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h3>Classes</h3><ul><li id="Skylink-nav"><a href="Skylink.html">Skylink</a><ul c

<section class="readme">
<article>
<h1>SKYLINK WEB SDK 2.3.2</h1>
<h1>SKYLINK WEB SDK 2.4.0</h1>
<blockquote>
<p>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.</p>
</blockquote>
Expand Down Expand Up @@ -178,7 +178,7 @@ <h4>Current versions and stability</h4>
<li>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.</li>
<li>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.</li>
</ul>
<p><a href="https://github.com/Temasys/SkylinkJS/releases/tag/2.3.2">Latest version: 2.3.2</a></p>
<p><a href="https://github.com/Temasys/SkylinkJS/releases/tag/2.4.0">Latest version: 2.4.0</a></p>
<h2>How to build your own Temasys SkylinkJS Web SDK</h2>
<p>Using <a href="https://git-scm.com/download">Git</a> command line tools, execute the following:</p>
<pre class="prettyprint source"><code># 1. Clone or download this repository via git terminal.
Expand Down
369 changes: 34 additions & 335 deletions docs/models_skylink-state.js.html

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/peer-connection_helpers_createOffer.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ <h1 class="page-title">
logger.log.DEBUG([targetMid, null, null, 'Creating offer with config:'], offerConstraints);

peerConnection.endOfCandidates = false;
peerConnection.negotiating = true;
peerConnection.sdpConstraints = offerConstraints;

Skylink.setSkylinkState(state, currentRoom.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ <h1 class="page-title">
// attributes (added on by Temasys)
rtcPeerConnection.setOffer = '';
rtcPeerConnection.setAnswer = '';
rtcPeerConnection.negotiating = false;
rtcPeerConnection.hasMainChannel = false;
rtcPeerConnection.processingLocalSDP = false;
rtcPeerConnection.processingRemoteSDP = false;
rtcPeerConnection.gathered = false;
rtcPeerConnection.gathering = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ <h1 class="page-title">
* Function that refreshes Peer connections to update with the current streaming.
* @param {SkylinkState} roomState
* @param {String} targetPeerId
* @param {boolean} iceRestart
* @param {Object} options
* @param {boolean} [iceRestart]
* @param {Object} [options]
* @param {Object} options.bandwidth
* @return {Promise}
* @memberOf PeerConnection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ <h1 class="page-title">
<section>
<article>
<pre class="prettyprint source linenums"><code>import Skylink from '../../../index';
import sendRestartOfferMsg from './sendRestartOfferMsg';
import { PEER_TYPE } from '../../../constants';
import { sendRestartOffer } from '../../../server-communication/signaling-server/message-handler/handlers/commons/offerAndAnswer';

/**
* @param {SkylinkState} roomState
Expand All @@ -118,7 +118,7 @@ <h1 class="page-title">
updatedRoomState.peerEndOfCandidatesCounter.MCU.len = 0;

Skylink.setSkylinkState(updatedRoomState);
resolve(sendRestartOfferMsg(updatedRoomState, PEER_TYPE.MCU, doIceRestart));
resolve(sendRestartOffer(updatedRoomState, PEER_TYPE.MCU, doIceRestart));
}
} catch (error) {
resolve([PEER_TYPE.MCU, error]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ <h1 class="page-title">
import { PEER_CONNECTION_STATE, TAGS } from '../../../constants';
import SkylinkSignalingServer from '../../../server-communication/signaling-server';
import MESSAGES from '../../../messages';
import sendRestartOfferMsg from './sendRestartOfferMsg';
import { sendRestartOffer } from '../../../server-communication/signaling-server/message-handler/handlers/commons/offerAndAnswer';

/**
* Function that sends restart message to the signaling server.
Expand Down Expand Up @@ -146,7 +146,7 @@ <h1 class="page-title">
updateState.peerEndOfCandidatesCounter[peerId].len = 0;
Skylink.setSkylinkState(updateState, updateState.room.id);

return resolve(sendRestartOfferMsg(updateState, peerId, doIceRestart));
return resolve(sendRestartOffer(updateState, peerId, doIceRestart));
}

// Checks if the local description is defined first
Expand Down
4 changes: 2 additions & 2 deletions docs/peer-connection_index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ <h1 class="page-title">
return helpers.refreshPeerConnection(listOfPeers, roomState, doIceRestart, bwOptions);
}

static buildPeerInformations(...args) {
return helpers.buildPeerInformations(...args);
static buildAndSetPeerInformations(...args) {
return helpers.buildAndSetPeerInformations(...args);
}

static closePeerConnection(roomState, peerId) {
Expand Down
31 changes: 9 additions & 22 deletions docs/server-communication_signaling-server_index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ <h1 class="page-title">
import { dispatchEvent } from '../../utils/skylinkEventManager';
import Skylink from '../../index';
import MESSAGES from '../../messages';
import { TAGS, SOCKET_ERROR, HANDSHAKE_PROGRESS } from '../../constants';
import { SOCKET_ERROR, HANDSHAKE_PROGRESS } from '../../constants';
import Room from '../../room';
import HandleSessionStats from '../../skylink-stats/handleSessionStats';

Expand Down Expand Up @@ -256,15 +256,12 @@ <h1 class="page-title">

/**
*
* @param args
* @param state
* @param answer
*/
answer(...args) {
return this.messageBuilder.getAnswerMessage(...args).then((answer) => {
const state = args[0];
this.sendMessage(answer);
this.dispatchHandshakeProgress(state, 'ANSWER');
return answer;
});
answer(state, answer) {
this.sendMessage(answer);
this.dispatchHandshakeProgress(state, 'ANSWER');
}

answerAck(...args) {
Expand All @@ -291,19 +288,9 @@ <h1 class="page-title">
this.logClientSessionStats(args[0].room.id, join);
}

offer(...args) {
const room = args[0];
const peerId = args[1];
const state = Skylink.getSkylinkState(room.id);
if (state.peerConnections[peerId].negotiating) {
logger.log.DEBUG([peerId, TAGS.SIG_SERVER, null, `${MESSAGES.SIGNALING.ABORTING_OFFER}`]);
return;
}

this.messageBuilder.getOfferMessage(...args).then((offer) => {
this.sendMessage(offer);
this.dispatchHandshakeProgress(state, 'OFFER');
});
offer(state, offer) {
this.sendMessage(offer);
this.dispatchHandshakeProgress(state, 'OFFER');
}

welcome(...args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,115 +94,45 @@ <h1 class="page-title">
<section>
<article>
<pre class="prettyprint source linenums"><code>import Skylink from '../../../../../index';
import { PEER_CONNECTION_STATE, TAGS } from '../../../../../constants';
import processPeer from './processPeer';
import SkylinkSignalingServer from '../../../index';
import { TAGS } from '../../../../../constants';
import handleNegotiationStats from '../../../../../skylink-stats/handleNegotiationStats';
import logger from '../../../../../logger';
import messages from '../../../../../messages';
import parsers from '../../../parsers';

export const CALLERS = {
ENTER: 'enterHandler',
WELCOME: 'welcomeHander',
};

const getNextNegotiationStep = (params) => {
let method = 'welcome';

if (params.caller === CALLERS.WELCOME) {
const state = Skylink.getSkylinkState(params.currentRoom.id);
const { peerMessagesStamps, peerPriorityWeight, hasMCU } = state;
if (hasMCU || peerPriorityWeight > params.message.weight) {
if (peerMessagesStamps[params.targetMid].hasWelcome) {
method = 'noop';
logger.log.WARN([params.targetMid, TAGS.PEER_CONNECTION, null, 'Discarding extra "welcome" received.']);
} else {
method = 'offer';
state.peerMessagesStamps[params.targetMid].hasWelcome = true;
Skylink.setSkylinkState(state, params.currentRoom.id);
}
}
}
return method;
};

// eslint-disable-next-line consistent-return
const checkStampBeforeSendingWelcome = (params) => {
const { currentRoom, targetMid, message } = params;
const state = Skylink.getSkylinkState(currentRoom.id);
const { peerConnections, hasMCU } = state;
const { STATS_MODULE, NEGOTIATION_PROGRESS, PEER_CONNECTION } = messages;
const signaling = new SkylinkSignalingServer();
const method = getNextNegotiationStep(params);

if (method === 'offer') {
// Added checks to ensure that connection object is defined first
if (!peerConnections[targetMid]) {
logger.log.WARN([targetMid, 'RTCSessionDescription', 'offer', PEER_CONNECTION.NO_PEER_CONNECTION]);
handleNegotiationStats.send(currentRoom.id, STATS_MODULE.HANDLE_NEGOTIATION_STATS.OFFER.dropped, targetMid, message, false, PEER_CONNECTION.NO_PEER_CONNECTION);
return null;
}

const { signalingState } = peerConnections[targetMid];

// Added checks to ensure that state is "stable" if setting local "offer"
if (signalingState !== PEER_CONNECTION_STATE.STABLE) {
logger.log.WARN([targetMid, 'RTCSessionDescription', 'offer', NEGOTIATION_PROGRESS.ERRORS.NOT_STABLE], signalingState);
handleNegotiationStats.send(currentRoom.id, STATS_MODULE.HANDLE_NEGOTIATION_STATS.OFFER.dropped, targetMid, message, false, NEGOTIATION_PROGRESS.ERRORS.NOT_STABLE);
return null;
}

signaling[method](params.currentRoom, params.targetMid);
} else if (!hasMCU) {
signaling[method](params.currentRoom, params.targetMid);
}
};

const logStats = (caller, targetMid, state, message) => {
const { room } = state;

let callerState = 'enter';
if (caller === CALLERS.WELCOME) {
callerState = 'welcome';
}

logger.log.INFO([targetMid, TAGS.PEER_CONNECTION, null, `Peer ${callerState} received ->`], message);
handleNegotiationStats.send(room.id, callerState, targetMid, message, true);
};
import NegotiationState from '../../../negotiationState/negotiationState';

/**
* Function that parses the enterAndWelcome and welcome message and sends the offer or welcome message.
* Function that parses the enter and welcome message and sends the welcome or offer message.
* @param {JSON} message
* @param {String} caller
* @memberOf SignalingMessageHandler
*/
export const parseAndSendWelcome = (message, caller) => {
// eslint-disable-next-line consistent-return
const enterAndWelcomeHandler = (message) => {
const parsedMsg = parsers.enterAndWelcome(message);
const {
rid, mid, userInfo, publisherId,
rid, mid, publisherId,
} = parsedMsg;
const state = Skylink.getSkylinkState(rid);
const { hasMCU, user } = state;
const targetMid = hasMCU &amp;&amp; publisherId ? publisherId : mid;

if (!user.sid) {
logger.log.DEBUG([targetMid, TAGS.PEER_CONNECTION, null, [messages.SIGNALING.DROPPING_ENTER]]);
return logger.log.DEBUG([targetMid, TAGS.PEER_CONNECTION, null, [messages.SIGNALING.DROPPING_ENTER]]);
}

logStats(caller, targetMid, state, parsedMsg);
logger.log.INFO([targetMid, TAGS.PEER_CONNECTION, null, `Peer ${parsedMsg.type} received ->`], message);
handleNegotiationStats.send(rid, parsedMsg.type, targetMid, message, true);

const peerParams = {
currentRoom: state.room,
targetMid,
userInfo,
message: parsedMsg,
caller,
};
if (parsedMsg.type === 'enter') {
return NegotiationState.onEnterReceived(message);
}

processPeer(peerParams);
checkStampBeforeSendingWelcome(peerParams);
if (parsedMsg.type === 'welcome') {
return NegotiationState.onWelcomeReceived(message);
}
};

export default enterAndWelcomeHandler;
</code></pre>
</article>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ <h1 class="page-title">
import PeerStream from '../../../../peer-stream';
import { ON_INCOMING_STREAM } from '../../../../skylink-events/constants';
import logger from '../../../../logger';
import { TAGS } from '../../../../constants';
import MESSAGES from '../../../../messages';
import HandleUserMediaStats from '../../../../skylink-stats/handleUserMediaStats';
import HandleSessionStats from '../../../../skylink-stats/handleSessionStats';
import { TAGS } from '../../../../constants';

const dispatchIncomingStream = (room, sid) => {
const state = Skylink.getSkylinkState(room.id);
Expand Down

0 comments on commit 3262987

Please sign in to comment.