@flashphoner/websdk 2.0.208 → 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.
@@ -12656,6 +12656,9 @@ var getSession = function getSession(id) {
12656
12656
  * @param {Object=} options.sipOptions Sip configuration
12657
12657
  * @param {Object=} options.mediaOptions Media connection configuration
12658
12658
  * @param {Integer=} options.timeout Connection timeout in milliseconds
12659
+ * @param {Integer=} options.pingInterval Server ping interval in milliseconds [0]
12660
+ * @param {Integer=} options.receiveProbes A maximum subsequental pings received missing count [0]
12661
+ * @param {Integer=} options.probesInterval Interval to check subsequental pings received [0]
12659
12662
  * @returns {Session} Created session
12660
12663
  * @throws {Error} Error if API is not initialized
12661
12664
  * @throws {TypeError} Error if options.urlServer is not specified
@@ -12682,6 +12685,8 @@ var createSession = function createSession(options) {
12682
12685
  var mediaOptions = options.mediaOptions;
12683
12686
  var keepAlive = options.keepAlive;
12684
12687
  var timeout = options.timeout;
12688
+ var wsPingSender = new WSPingSender(options.pingInterval || 0);
12689
+ var wsPingReceiver = new WSPingReceiver(options.receiveProbes || 0, options.probesInterval || 0);
12685
12690
  var connectionTimeout;
12686
12691
  var cConfig; //SIP config
12687
12692
 
@@ -12799,7 +12804,7 @@ var createSession = function createSession(options) {
12799
12804
  mediaProviders: Object.keys(MediaProvider),
12800
12805
  keepAlive: keepAlive,
12801
12806
  authToken: authToken,
12802
- clientVersion: "2.0.208",
12807
+ clientVersion: "2.0.209",
12803
12808
  clientOSVersion: window.navigator.appVersion,
12804
12809
  clientBrowserVersion: window.navigator.userAgent,
12805
12810
  msePacketizationVersion: 2,
@@ -12812,7 +12817,11 @@ var createSession = function createSession(options) {
12812
12817
 
12813
12818
 
12814
12819
  send("connection", cConfig);
12815
- logger.setConnection(wsConnection);
12820
+ logger.setConnection(wsConnection); // Send ping messages to server to check if connection is still alive #WCS-3410
12821
+
12822
+ wsPingSender.start(); // Check subsequintel pings received from server to check if connection is still alive #WCS-3410
12823
+
12824
+ wsPingReceiver.start();
12816
12825
  };
12817
12826
 
12818
12827
  wsConnection.onmessage = function (event) {
@@ -12828,6 +12837,7 @@ var createSession = function createSession(options) {
12828
12837
  switch (data.message) {
12829
12838
  case 'ping':
12830
12839
  send("pong", null);
12840
+ wsPingReceiver.success();
12831
12841
  break;
12832
12842
 
12833
12843
  case 'getUserData':
@@ -12987,7 +12997,11 @@ var createSession = function createSession(options) {
12987
12997
  sessionStatus = newStatus;
12988
12998
 
12989
12999
  if (sessionStatus == SESSION_STATUS.DISCONNECTED || sessionStatus == SESSION_STATUS.FAILED) {
12990
- //remove streams
13000
+ // Stop pinging server #WCS-3410
13001
+ wsPingSender.stop(); // Stop checking pings received #WCS-3410
13002
+
13003
+ wsPingReceiver.stop(); //remove streams
13004
+
12991
13005
  for (var prop in streamRefreshHandlers) {
12992
13006
  if (streamRefreshHandlers.hasOwnProperty(prop) && typeof streamRefreshHandlers[prop] === 'function') {
12993
13007
  streamRefreshHandlers[prop]({
@@ -13003,6 +13017,73 @@ var createSession = function createSession(options) {
13003
13017
  if (callbacks[sessionStatus]) {
13004
13018
  callbacks[sessionStatus](session, obj);
13005
13019
  }
13020
+ } // Websocket periodic ping sender
13021
+
13022
+
13023
+ function WSPingSender(interval) {
13024
+ this.interval = interval || 0;
13025
+ this.intervalId = null;
13026
+
13027
+ this.start = function () {
13028
+ if (this.interval > 0) {
13029
+ this.intervalId = setInterval(function () {
13030
+ send("ping", null);
13031
+ }, this.interval);
13032
+ }
13033
+ };
13034
+
13035
+ this.stop = function () {
13036
+ if (this.intervalId) {
13037
+ clearInterval(this.intervalId);
13038
+ }
13039
+ };
13040
+
13041
+ return this;
13042
+ } // Websocket ping receive prober
13043
+
13044
+
13045
+ function WSPingReceiver(receiveProbes, probesInterval) {
13046
+ this.maxPings = receiveProbes || 0;
13047
+ this.interval = probesInterval || 0;
13048
+ this.intervalId = null;
13049
+ this.pingsMissing = 0;
13050
+
13051
+ this.start = function () {
13052
+ if (this.maxPings > 0 && this.interval > 0) {
13053
+ var receiver = this;
13054
+ this.intervalId = setInterval(function () {
13055
+ receiver.checkPingsReceived();
13056
+ }, this.interval);
13057
+ }
13058
+ };
13059
+
13060
+ this.stop = function () {
13061
+ if (this.intervalId) {
13062
+ clearInterval(this.intervalId);
13063
+ }
13064
+
13065
+ this.pingsMissing = 0;
13066
+ };
13067
+
13068
+ this.checkPingsReceived = function () {
13069
+ this.pingsMissing++;
13070
+
13071
+ if (this.pingsMissing >= this.maxPings) {
13072
+ this.failure();
13073
+ }
13074
+ };
13075
+
13076
+ this.success = function () {
13077
+ this.pingsMissing = 0;
13078
+ };
13079
+
13080
+ this.failure = function () {
13081
+ logger.info(LOG_PREFIX, "Missing " + this.pingsMissing + " pings from server, connection seems to be down");
13082
+ onSessionStatusChange(SESSION_STATUS.FAILED);
13083
+ wsConnection.close();
13084
+ };
13085
+
13086
+ return this;
13006
13087
  }
13007
13088
  /**
13008
13089
  * @callback sdpHook
@@ -19411,6 +19411,9 @@ var getSession = function getSession(id) {
19411
19411
  * @param {Object=} options.sipOptions Sip configuration
19412
19412
  * @param {Object=} options.mediaOptions Media connection configuration
19413
19413
  * @param {Integer=} options.timeout Connection timeout in milliseconds
19414
+ * @param {Integer=} options.pingInterval Server ping interval in milliseconds [0]
19415
+ * @param {Integer=} options.receiveProbes A maximum subsequental pings received missing count [0]
19416
+ * @param {Integer=} options.probesInterval Interval to check subsequental pings received [0]
19414
19417
  * @returns {Session} Created session
19415
19418
  * @throws {Error} Error if API is not initialized
19416
19419
  * @throws {TypeError} Error if options.urlServer is not specified
@@ -19437,6 +19440,8 @@ var createSession = function createSession(options) {
19437
19440
  var mediaOptions = options.mediaOptions;
19438
19441
  var keepAlive = options.keepAlive;
19439
19442
  var timeout = options.timeout;
19443
+ var wsPingSender = new WSPingSender(options.pingInterval || 0);
19444
+ var wsPingReceiver = new WSPingReceiver(options.receiveProbes || 0, options.probesInterval || 0);
19440
19445
  var connectionTimeout;
19441
19446
  var cConfig; //SIP config
19442
19447
 
@@ -19554,7 +19559,7 @@ var createSession = function createSession(options) {
19554
19559
  mediaProviders: Object.keys(MediaProvider),
19555
19560
  keepAlive: keepAlive,
19556
19561
  authToken: authToken,
19557
- clientVersion: "2.0.208",
19562
+ clientVersion: "2.0.209",
19558
19563
  clientOSVersion: window.navigator.appVersion,
19559
19564
  clientBrowserVersion: window.navigator.userAgent,
19560
19565
  msePacketizationVersion: 2,
@@ -19567,7 +19572,11 @@ var createSession = function createSession(options) {
19567
19572
 
19568
19573
 
19569
19574
  send("connection", cConfig);
19570
- logger.setConnection(wsConnection);
19575
+ logger.setConnection(wsConnection); // Send ping messages to server to check if connection is still alive #WCS-3410
19576
+
19577
+ wsPingSender.start(); // Check subsequintel pings received from server to check if connection is still alive #WCS-3410
19578
+
19579
+ wsPingReceiver.start();
19571
19580
  };
19572
19581
 
19573
19582
  wsConnection.onmessage = function (event) {
@@ -19583,6 +19592,7 @@ var createSession = function createSession(options) {
19583
19592
  switch (data.message) {
19584
19593
  case 'ping':
19585
19594
  send("pong", null);
19595
+ wsPingReceiver.success();
19586
19596
  break;
19587
19597
 
19588
19598
  case 'getUserData':
@@ -19742,7 +19752,11 @@ var createSession = function createSession(options) {
19742
19752
  sessionStatus = newStatus;
19743
19753
 
19744
19754
  if (sessionStatus == SESSION_STATUS.DISCONNECTED || sessionStatus == SESSION_STATUS.FAILED) {
19745
- //remove streams
19755
+ // Stop pinging server #WCS-3410
19756
+ wsPingSender.stop(); // Stop checking pings received #WCS-3410
19757
+
19758
+ wsPingReceiver.stop(); //remove streams
19759
+
19746
19760
  for (var prop in streamRefreshHandlers) {
19747
19761
  if (streamRefreshHandlers.hasOwnProperty(prop) && typeof streamRefreshHandlers[prop] === 'function') {
19748
19762
  streamRefreshHandlers[prop]({
@@ -19758,6 +19772,73 @@ var createSession = function createSession(options) {
19758
19772
  if (callbacks[sessionStatus]) {
19759
19773
  callbacks[sessionStatus](session, obj);
19760
19774
  }
19775
+ } // Websocket periodic ping sender
19776
+
19777
+
19778
+ function WSPingSender(interval) {
19779
+ this.interval = interval || 0;
19780
+ this.intervalId = null;
19781
+
19782
+ this.start = function () {
19783
+ if (this.interval > 0) {
19784
+ this.intervalId = setInterval(function () {
19785
+ send("ping", null);
19786
+ }, this.interval);
19787
+ }
19788
+ };
19789
+
19790
+ this.stop = function () {
19791
+ if (this.intervalId) {
19792
+ clearInterval(this.intervalId);
19793
+ }
19794
+ };
19795
+
19796
+ return this;
19797
+ } // Websocket ping receive prober
19798
+
19799
+
19800
+ function WSPingReceiver(receiveProbes, probesInterval) {
19801
+ this.maxPings = receiveProbes || 0;
19802
+ this.interval = probesInterval || 0;
19803
+ this.intervalId = null;
19804
+ this.pingsMissing = 0;
19805
+
19806
+ this.start = function () {
19807
+ if (this.maxPings > 0 && this.interval > 0) {
19808
+ var receiver = this;
19809
+ this.intervalId = setInterval(function () {
19810
+ receiver.checkPingsReceived();
19811
+ }, this.interval);
19812
+ }
19813
+ };
19814
+
19815
+ this.stop = function () {
19816
+ if (this.intervalId) {
19817
+ clearInterval(this.intervalId);
19818
+ }
19819
+
19820
+ this.pingsMissing = 0;
19821
+ };
19822
+
19823
+ this.checkPingsReceived = function () {
19824
+ this.pingsMissing++;
19825
+
19826
+ if (this.pingsMissing >= this.maxPings) {
19827
+ this.failure();
19828
+ }
19829
+ };
19830
+
19831
+ this.success = function () {
19832
+ this.pingsMissing = 0;
19833
+ };
19834
+
19835
+ this.failure = function () {
19836
+ logger.info(LOG_PREFIX, "Missing " + this.pingsMissing + " pings from server, connection seems to be down");
19837
+ onSessionStatusChange(SESSION_STATUS.FAILED);
19838
+ wsConnection.close();
19839
+ };
19840
+
19841
+ return this;
19761
19842
  }
19762
19843
  /**
19763
19844
  * @callback sdpHook