mirror of
https://github.com/moparisthebest/kaiwa
synced 2024-11-22 09:12:19 -05:00
Handle session resumption
This commit is contained in:
parent
378f6e0a8b
commit
49d5f8e692
@ -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;
|
||||
|
||||
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user