Skip to content

Commit

Permalink
3.5.7: improve registrator expires maths (credits to
Browse files Browse the repository at this point in the history
Roman Shpount)
  • Loading branch information
ibc committed Aug 14, 2020
1 parent cc42319 commit a6a66ce
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions dist/jssip.js
@@ -1,5 +1,5 @@
/*
* JsSIP v3.5.6
* JsSIP v3.5.7
* the Javascript SIP library
* Copyright: 2012-2020 José Luis Millán <jmillan@aliax.net> (https://github.com/jmillan)
* Homepage: https://jssip.net
Expand Down Expand Up @@ -20945,7 +20945,7 @@ module.exports = /*#__PURE__*/function () {

expires = Number(expires);
if (expires < MIN_REGISTER_EXPIRES) expires = MIN_REGISTER_EXPIRES;
var timeout = expires > 30 ? expires * 1000 - 10000 : expires * 1000 - 5000; // Re-Register or emit an event before the expiration interval has elapsed.
var timeout = expires > 64 ? expires * 1000 / 2 + Math.floor((expires / 2 - 32) * 1000 * Math.random()) : expires * 1000 - 5000; // Re-Register or emit an event before the expiration interval has elapsed.
// For that, decrease the expires value. ie: 3 seconds.

_this._registrationTimer = setTimeout(function () {
Expand Down Expand Up @@ -27822,7 +27822,7 @@ module.exports={
"name": "jssip",
"title": "JsSIP",
"description": "the Javascript SIP library",
"version": "3.5.6",
"version": "3.5.7",
"homepage": "https://jssip.net",
"author": "José Luis Millán <jmillan@aliax.net> (https://github.com/jmillan)",
"contributors": [
Expand Down
4 changes: 2 additions & 2 deletions dist/jssip.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions lib/Registrator.js
Expand Up @@ -193,8 +193,9 @@ ${this._contact};expires=${this._expires}${this._extraContactParams}`);
if (expires < MIN_REGISTER_EXPIRES)
expires = MIN_REGISTER_EXPIRES;

const timeout = expires > 30
? (expires * 1000) - 10000
const timeout = expires > 64
? (expires * 1000 / 2) +
Math.floor(((expires / 2) - 32) * 1000 * Math.random())
: (expires * 1000) - 5000;

// Re-Register or emit an event before the expiration interval has elapsed.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -2,7 +2,7 @@
"name": "jssip",
"title": "JsSIP",
"description": "the Javascript SIP library",
"version": "3.5.6",
"version": "3.5.7",
"homepage": "https://jssip.net",
"author": "José Luis Millán <jmillan@aliax.net> (https://github.com/jmillan)",
"contributors": [
Expand Down

0 comments on commit a6a66ce

Please sign in to comment.