1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-08-13 17:03:51 -04:00

Try to kill hanging sessions

This commit is contained in:
Lance Stout 2013-09-16 11:16:47 -07:00
parent e435c178c8
commit fb86237955
3 changed files with 13 additions and 2 deletions

View File

@ -31,6 +31,10 @@ module.exports = {
$(window).focus(function () {
me.hasFocus = true;
});
window.onbeforeunload = function () {
client.disconnect();
return "End active session?";
};
config = JSON.parse(config);

View File

@ -256,6 +256,7 @@ function Client(opts) {
self.negotiatedFeatures.sasl = false;
self.negotiatedFeatures.streamManagement = false;
self.negotiatedFeatures.bind = false;
self.negotiatedFeatures.session = false;
self.releaseGroup('connection');
});
@ -4991,6 +4992,7 @@ WSConnection.prototype.connect = function (opts) {
};
self.conn.onopen = function () {
self.sm.started = false;
self.emit('connected', self);
};
@ -5010,6 +5012,7 @@ WSConnection.prototype.disconnect = function () {
this.conn.close();
this.stream = undefined;
this.conn = undefined;
this.sm.failed();
}
};

View File

@ -1,4 +1,4 @@
/*global $, app, me*/
/*global $, app, me, client*/
"use strict";
var HumanView = require('human-view');
@ -9,7 +9,8 @@ var ContactListItem = require('../views/contactListItem');
module.exports = HumanView.extend({
template: templates.body,
events: {
'click a[href]': 'handleLinkClick'
'click a[href]': 'handleLinkClick',
'click .reconnect': 'handleReconnect'
},
classBindings: {
connected: '#connectionOverlay'
@ -21,6 +22,9 @@ module.exports = HumanView.extend({
this.renderCollection(me.contacts, ContactListItem, this.$('#roster nav'));
return this;
},
handleReconnect: function (e) {
client.connect();
},
handleLinkClick: function (e) {
var t = $(e.target);
var aEl = t.is('a') ? t[0] : t.closest('a')[0];