Skip to content

Commit

Permalink
Merge branch 'master' of github.com:versatica/JsSIP
Browse files Browse the repository at this point in the history
# Conflicts:
#	dist/jssip.min.js
  • Loading branch information
ibc committed Nov 19, 2016
2 parents 766cb2e + 90ac049 commit de722a2
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 32 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@ Version 3.0.0 (released in 2016-11-19)
* `RTCSession:`: Emit WebRTC related events when internal calls to `getUserMedia()`, `createOffer()`, etc. fail.
* Use debug NPM fixed "2.0.0" version (until a pending bug in such a library is fixed).
* `UA`: Remove `ws_servers` option.
* `UA`: Allow immediate restart


Version 2.0.6 (released in 2016-09-30)
Expand Down
1 change: 1 addition & 0 deletions THANKS.md
Expand Up @@ -11,6 +11,7 @@ Here the list of contributors with code and patches to JsSIP project. Thanks a l
* [Gavin Llewellyn](https://github.com/gavllew)
* [Julian Scheid](https://github.com/jscheid)
* [James Mortensen](https://github.com/jamesmortensen)
* [Steve Davies](https://github.com/davies147)


JsSIP Debian and Ubuntu packaging
Expand Down
36 changes: 22 additions & 14 deletions dist/jssip.js
Expand Up @@ -19195,6 +19195,8 @@ function UA(configuration) {
// Custom UA empty object for high level use
this.data = {};

this.closeTimer = null;

Object.defineProperties(this, {
transactionsCount: {
get: function() {
Expand Down Expand Up @@ -19271,22 +19273,21 @@ util.inherits(UA, events.EventEmitter);
UA.prototype.start = function() {
debug('start()');

var self = this;

function connect() {
debug('restarting UA');
self.status = C.STATUS_READY;
self.transport.connect();
}

if (this.status === C.STATUS_INIT) {
this.transport.connect();
} else if(this.status === C.STATUS_USER_CLOSED) {
if (!this.isConnected()) {
connect();
} else {
this.once('disconnected', connect);
debug('restarting UA');

// disconnect
if (this.closeTimer !== null) {
clearTimeout(this.closeTimer);
this.closeTimer = null;
this.transport.disconnect();
}

// reconnect
this.status = C.STATUS_INIT;
this.transport.connect();
} else if (this.status === C.STATUS_READY) {
debug('UA is in READY status, not restarted');
} else {
Expand Down Expand Up @@ -19442,7 +19443,8 @@ UA.prototype.stop = function() {
ua.transport.disconnect();
}
else {
setTimeout(function() {
this.closeTimer = setTimeout(function() {
ua.closeTimer = null;
ua.transport.disconnect();
}, 2000);
}
Expand Down Expand Up @@ -21056,7 +21058,7 @@ WebSocketInterface.prototype.connect = function () {
}

if (this.ws) {
this.ws.close();
this.disconnect();
}

debug('connecting to WebSocket ' + this.url);
Expand All @@ -21079,6 +21081,12 @@ WebSocketInterface.prototype.disconnect = function() {
debug('disconnect()');

if (this.ws) {
// unbind websocket event callbacks
this.ws.onopen = function() {};
this.ws.onclose = function() {};
this.ws.onmessage = function() {};
this.ws.onerror = function() {};

this.ws.close();
this.ws = null;
}
Expand Down
8 changes: 4 additions & 4 deletions dist/jssip.min.js

Large diffs are not rendered by default.

28 changes: 15 additions & 13 deletions lib/UA.js
Expand Up @@ -80,6 +80,8 @@ function UA(configuration) {
// Custom UA empty object for high level use
this.data = {};

this.closeTimer = null;

Object.defineProperties(this, {
transactionsCount: {
get: function() {
Expand Down Expand Up @@ -156,22 +158,21 @@ util.inherits(UA, events.EventEmitter);
UA.prototype.start = function() {
debug('start()');

var self = this;

function connect() {
debug('restarting UA');
self.status = C.STATUS_READY;
self.transport.connect();
}

if (this.status === C.STATUS_INIT) {
this.transport.connect();
} else if(this.status === C.STATUS_USER_CLOSED) {
if (!this.isConnected()) {
connect();
} else {
this.once('disconnected', connect);
debug('restarting UA');

// disconnect
if (this.closeTimer !== null) {
clearTimeout(this.closeTimer);
this.closeTimer = null;
this.transport.disconnect();
}

// reconnect
this.status = C.STATUS_INIT;
this.transport.connect();
} else if (this.status === C.STATUS_READY) {
debug('UA is in READY status, not restarted');
} else {
Expand Down Expand Up @@ -327,7 +328,8 @@ UA.prototype.stop = function() {
ua.transport.disconnect();
}
else {
setTimeout(function() {
this.closeTimer = setTimeout(function() {
ua.closeTimer = null;
ua.transport.disconnect();
}, 2000);
}
Expand Down
8 changes: 7 additions & 1 deletion lib/WebSocketInterface.js
Expand Up @@ -55,7 +55,7 @@ WebSocketInterface.prototype.connect = function () {
}

if (this.ws) {
this.ws.close();
this.disconnect();
}

debug('connecting to WebSocket ' + this.url);
Expand All @@ -78,6 +78,12 @@ WebSocketInterface.prototype.disconnect = function() {
debug('disconnect()');

if (this.ws) {
// unbind websocket event callbacks
this.ws.onopen = function() {};
this.ws.onclose = function() {};
this.ws.onmessage = function() {};
this.ws.onerror = function() {};

this.ws.close();
this.ws = null;
}
Expand Down

0 comments on commit de722a2

Please sign in to comment.