summaryrefslogtreecommitdiff
path: root/js/codeq/comms.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/codeq/comms.js')
-rw-r--r--js/codeq/comms.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/js/codeq/comms.js b/js/codeq/comms.js
index fcce6df..d3f9252 100644
--- a/js/codeq/comms.js
+++ b/js/codeq/comms.js
@@ -114,6 +114,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
// * the user logged in elsewhere
s = 'The server forced us to disconnect';
if (typeof m.message === 'string') s += ': ' + m.message;
+ sid = null;
codeq.reset(s);
return;
@@ -345,7 +346,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
// reject any outstanding promises
for (tid in waiters) {
if (waiters.hasOwnProperty(tid)) {
- waiters[id].promise.reject(new Error(reason || 'Forced disconnect'));
+ waiters[tid].promise.reject(new Error(reason || 'Forced disconnect'));
delete waiters[tid];
}
}
@@ -387,9 +388,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
},
'logout': function () {
- var promise = this.send({'action': 'logout'});
- sid = null;
- return promise;
+ var performLogout = function() {
+ var promise = codeq.comms.send({'action': 'logout'});
+ sid = null;
+ return promise;
+ };
+
+ if (socket) return performLogout();
+ return this.connect().then(performLogout);
},
'signup': function (username, name, email, password) {