@flashphoner/websdk 2.0.205 → 2.0.209

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10035,6 +10035,9 @@ var getSession = function (id) {
10035
10035
  * @param {Object=} options.sipOptions Sip configuration
10036
10036
  * @param {Object=} options.mediaOptions Media connection configuration
10037
10037
  * @param {Integer=} options.timeout Connection timeout in milliseconds
10038
+ * @param {Integer=} options.pingInterval Server ping interval in milliseconds [0]
10039
+ * @param {Integer=} options.receiveProbes A maximum subsequental pings received missing count [0]
10040
+ * @param {Integer=} options.probesInterval Interval to check subsequental pings received [0]
10038
10041
  * @returns {Session} Created session
10039
10042
  * @throws {Error} Error if API is not initialized
10040
10043
  * @throws {TypeError} Error if options.urlServer is not specified
@@ -10059,6 +10062,8 @@ var createSession = function (options) {
10059
10062
  var mediaOptions = options.mediaOptions;
10060
10063
  var keepAlive = options.keepAlive;
10061
10064
  var timeout = options.timeout;
10065
+ var wsPingSender = new WSPingSender(options.pingInterval || 0);
10066
+ var wsPingReceiver = new WSPingReceiver(options.receiveProbes || 0, options.probesInterval || 0);
10062
10067
  var connectionTimeout;
10063
10068
 
10064
10069
  var cConfig;
@@ -10166,7 +10171,7 @@ var createSession = function (options) {
10166
10171
  mediaProviders: Object.keys(MediaProvider),
10167
10172
  keepAlive: keepAlive,
10168
10173
  authToken:authToken,
10169
- clientVersion: "2.0.205",
10174
+ clientVersion: "2.0.209",
10170
10175
  clientOSVersion: window.navigator.appVersion,
10171
10176
  clientBrowserVersion: window.navigator.userAgent,
10172
10177
  msePacketizationVersion: 2,
@@ -10178,6 +10183,10 @@ var createSession = function (options) {
10178
10183
  //connect to REST App
10179
10184
  send("connection", cConfig);
10180
10185
  logger.setConnection(wsConnection);
10186
+ // Send ping messages to server to check if connection is still alive #WCS-3410
10187
+ wsPingSender.start();
10188
+ // Check subsequintel pings received from server to check if connection is still alive #WCS-3410
10189
+ wsPingReceiver.start();
10181
10190
  };
10182
10191
  wsConnection.onmessage = function (event) {
10183
10192
  var data = {};
@@ -10190,6 +10199,7 @@ var createSession = function (options) {
10190
10199
  switch (data.message) {
10191
10200
  case 'ping':
10192
10201
  send("pong", null);
10202
+ wsPingReceiver.success();
10193
10203
  break;
10194
10204
  case 'getUserData':
10195
10205
  authToken = obj.authToken;
@@ -10316,6 +10326,10 @@ var createSession = function (options) {
10316
10326
  function onSessionStatusChange(newStatus, obj) {
10317
10327
  sessionStatus = newStatus;
10318
10328
  if (sessionStatus == SESSION_STATUS.DISCONNECTED || sessionStatus == SESSION_STATUS.FAILED) {
10329
+ // Stop pinging server #WCS-3410
10330
+ wsPingSender.stop();
10331
+ // Stop checking pings received #WCS-3410
10332
+ wsPingReceiver.stop();
10319
10333
  //remove streams
10320
10334
  for (var prop in streamRefreshHandlers) {
10321
10335
  if (streamRefreshHandlers.hasOwnProperty(prop) && typeof streamRefreshHandlers[prop] === 'function') {
@@ -10330,6 +10344,65 @@ var createSession = function (options) {
10330
10344
  }
10331
10345
  }
10332
10346
 
10347
+ // Websocket periodic ping sender
10348
+ function WSPingSender(interval) {
10349
+ this.interval = interval || 0;
10350
+ this.intervalId = null;
10351
+ this.start = function() {
10352
+ if (this.interval > 0) {
10353
+ this.intervalId = setInterval(function() {
10354
+ send("ping", null);
10355
+ }, this.interval);
10356
+ }
10357
+ };
10358
+ this.stop = function() {
10359
+ if (this.intervalId) {
10360
+ clearInterval(this.intervalId);
10361
+ }
10362
+ };
10363
+
10364
+ return(this);
10365
+ }
10366
+
10367
+ // Websocket ping receive prober
10368
+ function WSPingReceiver(receiveProbes, probesInterval) {
10369
+ this.maxPings = receiveProbes || 0;
10370
+ this.interval = probesInterval || 0;
10371
+ this.intervalId = null;
10372
+ this.pingsMissing = 0;
10373
+ this.start = function() {
10374
+ if (this.maxPings > 0 && this.interval > 0) {
10375
+ let receiver = this;
10376
+ this.intervalId = setInterval(function() {
10377
+ receiver.checkPingsReceived();
10378
+ }, this.interval);
10379
+ }
10380
+ };
10381
+ this.stop = function() {
10382
+ if (this.intervalId) {
10383
+ clearInterval(this.intervalId);
10384
+ }
10385
+ this.pingsMissing = 0;
10386
+ };
10387
+ this.checkPingsReceived = function() {
10388
+ this.pingsMissing++;
10389
+ if (this.pingsMissing >= this.maxPings) {
10390
+ this.failure();
10391
+ }
10392
+ };
10393
+ this.success = function() {
10394
+ this.pingsMissing = 0;
10395
+ };
10396
+ this.failure = function() {
10397
+ logger.info(LOG_PREFIX, "Missing " + this.pingsMissing + " pings from server, connection seems to be down");
10398
+ onSessionStatusChange(SESSION_STATUS.FAILED);
10399
+ wsConnection.close();
10400
+ };
10401
+
10402
+ return(this);
10403
+ }
10404
+
10405
+
10333
10406
  /**
10334
10407
  * @callback sdpHook
10335
10408
  * @param {Object} sdp Callback options
@@ -14262,14 +14335,14 @@ var createConnection = function (options) {
14262
14335
  if (!report.isRemote) {
14263
14336
  if (report.type == 'outbound-rtp') {
14264
14337
  fillStatObject(result.outboundStream, report);
14265
- if (report.mediaType == 'video') {
14338
+ if (report.mediaType == 'video' && localVideo != undefined && localVideo != null) {
14266
14339
  var vSettings = localVideo.srcObject.getVideoTracks()[0].getSettings();
14267
14340
  result.outboundStream[report.mediaType].height = vSettings.height;
14268
14341
  result.outboundStream[report.mediaType].width = vSettings.width;
14269
14342
  }
14270
14343
  } else if (report.type == 'inbound-rtp') {
14271
14344
  fillStatObject(result.inboundStream, report);
14272
- if (report.mediaType == 'video' && remoteVideo != undefined) {
14345
+ if (report.mediaType == 'video' && remoteVideo != undefined && remoteVideo != null) {
14273
14346
  result.inboundStream[report.mediaType].height = remoteVideo.videoHeight;
14274
14347
  result.inboundStream[report.mediaType].width = remoteVideo.videoWidth;
14275
14348
  }
@@ -14430,7 +14503,7 @@ var createConnection = function (options) {
14430
14503
  if (browserDetails.browser === 'firefox') {
14431
14504
  clonedConstraints.video.mediaSource = source;
14432
14505
  }
14433
- if (window.chrome && woExtension) {
14506
+ if (woExtension) {
14434
14507
  getScreenDeviceIdWoExtension(clonedConstraints).then(function (screenSharingConstraints) {
14435
14508
  navigator.mediaDevices.getDisplayMedia(screenSharingConstraints).then(
14436
14509
  (stream) => {