Don't reconnect if close was called

Fixes a bug during re-registration where we continue to re-open
the socket using old credentials.

// FREEBIE
This commit is contained in:
lilia 2015-11-05 12:45:18 -08:00
parent f863616785
commit 675be2b569
2 changed files with 10 additions and 4 deletions

View file

@ -39312,7 +39312,7 @@ MessageReceiver.prototype = {
this.pending = Promise.resolve();
},
close: function() {
this.wsr.close();
this.socket.close(3000, 'called close');
delete this.listeners;
},
onopen: function() {
@ -39322,8 +39322,11 @@ MessageReceiver.prototype = {
console.log('websocket error');
},
onclose: function(ev) {
console.log('websocket closed', ev.code, ev.reason || '');
if (ev.code === 3000) {
return;
}
var eventTarget = this;
console.log('websocket closed', ev.code);
// possible 403 or network issue. Make an request to confirm
this.server.getDevices(this.number).
then(this.connect.bind(this)). // No HTTP error? Reconnect

View file

@ -32,7 +32,7 @@ MessageReceiver.prototype = {
this.pending = Promise.resolve();
},
close: function() {
this.wsr.close();
this.socket.close(3000, 'called close');
delete this.listeners;
},
onopen: function() {
@ -42,8 +42,11 @@ MessageReceiver.prototype = {
console.log('websocket error');
},
onclose: function(ev) {
console.log('websocket closed', ev.code, ev.reason || '');
if (ev.code === 3000) {
return;
}
var eventTarget = this;
console.log('websocket closed', ev.code);
// possible 403 or network issue. Make an request to confirm
this.server.getDevices(this.number).
then(this.connect.bind(this)). // No HTTP error? Reconnect