1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-12 04:25:05 -05:00

Handle session resumption

This commit is contained in:
Lance Stout 2013-09-11 22:02:54 -07:00
parent 378f6e0a8b
commit 49d5f8e692
2 changed files with 11 additions and 2 deletions

View File

@ -86,6 +86,10 @@ module.exports = function (client, app) {
window.location = '/login';
});
client.on('stream:management:resumed', function () {
me.connected = true;
});
client.on('session:started', function (jid) {
me.jid = jid;

View File

@ -76,6 +76,8 @@ function Client(opts) {
this._idPrefix = uuid.v4();
this._idCount = 0;
this.timeoutMonitor = null;
this.negotiatedFeatures = {};
this.featureOrder = [
'sasl',
@ -407,8 +409,10 @@ Client.prototype.connect = function (opts) {
_.extend(self.config, opts || {});
// Default iq timeout of 15 seconds
self.timeoutMonitor = new paddle.Paddle(self.config.timeout || 15);
self.timeoutMonitor.start();
if (!self.timeoutMonitor) {
self.timeoutMonitor = new paddle.Paddle(self.config.timeout || 15);
self.timeoutMonitor.start();
}
if (self.config.wsURL) {
return self.conn.connect(self.config);
@ -426,6 +430,7 @@ Client.prototype.connect = function (opts) {
Client.prototype.disconnect = function () {
this.timeoutMonitor.stop();
this.timeoutMonitor = null;
if (this.sessionStarted) {
this.emit('session:end');
this.releaseGroup('session');