@voicenter-team/opensips-js 1.0.145 → 1.0.147

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.
@@ -19628,6 +19628,7 @@ class HT {
19628
19628
  Wi.debug("no Contact header pointing to us, response ignored");
19629
19629
  break;
19630
19630
  }
19631
+ this._ua.clearKeepAliveInterval(), this._ua.setLastRegisterTimestamp();
19631
19632
  let d = r.getParam("expires");
19632
19633
  !d && o.hasHeader("expires") && (d = o.getHeader("expires")), d || (d = this._expires), d = Number(d), d < ha && (d = ha);
19633
19634
  const h = d > 64 ? d * 1e3 / 2 + Math.floor((d / 2 - 32) * 1e3 * Math.random()) : d * 1e3 - 5e3;
@@ -19734,7 +19735,10 @@ class jT extends FT {
19734
19735
  nict: {},
19735
19736
  ist: {},
19736
19737
  ict: {}
19737
- }, this._janus_sessions = [], this.newStreamPlugins = [], this.processStreamPlugins = [], this._registrator = new HT(this);
19738
+ }, this._janus_sessions = [], this.newStreamPlugins = [], this.processStreamPlugins = [], this.optionsInterval = null, this.lastOptionsTimestamp = null, this.lastRegisterTimestamp = null, this._registrator = new HT(this);
19739
+ }
19740
+ setLastRegisterTimestamp() {
19741
+ this.lastRegisterTimestamp = Date.now();
19738
19742
  }
19739
19743
  call(t, n) {
19740
19744
  return super.call(t, n);
@@ -19867,6 +19871,9 @@ class jT extends FT {
19867
19871
  destroyJanusSession(t) {
19868
19872
  delete this._janus_sessions[t.id];
19869
19873
  }
19874
+ clearKeepAliveInterval() {
19875
+ clearInterval(this.optionsInterval), this.optionsInterval = null;
19876
+ }
19870
19877
  receiveRequest(t) {
19871
19878
  var s, r, d, h;
19872
19879
  const n = t.method;
@@ -19881,7 +19888,10 @@ class jT extends FT {
19881
19888
  if (Gt.checkTransaction(this, t))
19882
19889
  return;
19883
19890
  if (n === De.INVITE ? new Gt.InviteServerTransaction(this, this._transport, t) : n !== De.ACK && n !== De.CANCEL && new Gt.NonInviteServerTransaction(this, this._transport, t), n === De.OPTIONS) {
19884
- if (this.listeners("newOptions").length === 0) {
19891
+ if (this.lastOptionsTimestamp = Date.now(), this.optionsInterval || (this.emit("initKeepAliveInterval"), this.optionsInterval = setInterval(() => {
19892
+ const g = Date.now();
19893
+ this.lastOptionsTimestamp > g - 35e3 && this.lastRegisterTimestamp + this._configuration.register_expires * 1e3 > g && this.emit("keepAliveInterval");
19894
+ }, 35e3)), this.listeners("newOptions").length === 0) {
19885
19895
  t.reply(200);
19886
19896
  return;
19887
19897
  }