Skip to content

Commit

Permalink
Change disconnect call order to something more sensible (#754)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brett Berenz authored Mar 16, 2021
1 parent b2aac71 commit d16df4a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions js/qz-tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,21 @@ var qz = (function() {
//called when an open connection is closed
_qz.websocket.connection.onclose = function(evt) {
_qz.log.trace(evt);
_qz.log.info("Closed connection with QZ Tray");

//if this is set, then an explicit close call was made
if (this.promise != undefined) {
this.promise.resolve();
}

_qz.websocket.callClose(evt);
_qz.websocket.connection = null;
_qz.websocket.callClose(evt);
_qz.log.info("Closed connection with QZ Tray");

for(var uid in _qz.websocket.pendingCalls) {
if (_qz.websocket.pendingCalls.hasOwnProperty(uid)) {
_qz.websocket.pendingCalls[uid].reject(new Error("Connection closed before response received"));
}
}

//if this is set, then an explicit close call was made
if (this.promise != undefined) {
this.promise.resolve();
}
};

//called for any errors with an open connection
Expand Down

0 comments on commit d16df4a

Please sign in to comment.