1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-12-25 00:48:51 -05: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 () { $(window).focus(function () {
me.hasFocus = true; me.hasFocus = true;
}); });
window.onbeforeunload = function () {
client.disconnect();
return "End active session?";
};
config = JSON.parse(config); config = JSON.parse(config);

View File

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

View File

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