From fb862379554a5543b76e69b7fb6289ba362e066e Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Mon, 16 Sep 2013 11:16:47 -0700 Subject: [PATCH] Try to kill hanging sessions --- clientapp/app.js | 4 ++++ clientapp/libraries/stanza.io.js | 3 +++ clientapp/views/main.js | 8 ++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/clientapp/app.js b/clientapp/app.js index 6226e77..ab25535 100644 --- a/clientapp/app.js +++ b/clientapp/app.js @@ -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); diff --git a/clientapp/libraries/stanza.io.js b/clientapp/libraries/stanza.io.js index 3403442..0d7abf8 100644 --- a/clientapp/libraries/stanza.io.js +++ b/clientapp/libraries/stanza.io.js @@ -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(); } }; diff --git a/clientapp/views/main.js b/clientapp/views/main.js index 296f318..810b0dd 100644 --- a/clientapp/views/main.js +++ b/clientapp/views/main.js @@ -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];