mirror of
https://github.com/moparisthebest/kaiwa
synced 2024-11-22 17:22:22 -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';
|
window.location = '/login';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
client.on('stream:management:resumed', function () {
|
||||||
|
me.connected = true;
|
||||||
|
});
|
||||||
|
|
||||||
client.on('session:started', function (jid) {
|
client.on('session:started', function (jid) {
|
||||||
me.jid = jid;
|
me.jid = jid;
|
||||||
|
|
||||||
|
@ -76,6 +76,8 @@ function Client(opts) {
|
|||||||
this._idPrefix = uuid.v4();
|
this._idPrefix = uuid.v4();
|
||||||
this._idCount = 0;
|
this._idCount = 0;
|
||||||
|
|
||||||
|
this.timeoutMonitor = null;
|
||||||
|
|
||||||
this.negotiatedFeatures = {};
|
this.negotiatedFeatures = {};
|
||||||
this.featureOrder = [
|
this.featureOrder = [
|
||||||
'sasl',
|
'sasl',
|
||||||
@ -407,8 +409,10 @@ Client.prototype.connect = function (opts) {
|
|||||||
_.extend(self.config, opts || {});
|
_.extend(self.config, opts || {});
|
||||||
|
|
||||||
// Default iq timeout of 15 seconds
|
// Default iq timeout of 15 seconds
|
||||||
self.timeoutMonitor = new paddle.Paddle(self.config.timeout || 15);
|
if (!self.timeoutMonitor) {
|
||||||
self.timeoutMonitor.start();
|
self.timeoutMonitor = new paddle.Paddle(self.config.timeout || 15);
|
||||||
|
self.timeoutMonitor.start();
|
||||||
|
}
|
||||||
|
|
||||||
if (self.config.wsURL) {
|
if (self.config.wsURL) {
|
||||||
return self.conn.connect(self.config);
|
return self.conn.connect(self.config);
|
||||||
@ -426,6 +430,7 @@ Client.prototype.connect = function (opts) {
|
|||||||
|
|
||||||
Client.prototype.disconnect = function () {
|
Client.prototype.disconnect = function () {
|
||||||
this.timeoutMonitor.stop();
|
this.timeoutMonitor.stop();
|
||||||
|
this.timeoutMonitor = null;
|
||||||
if (this.sessionStarted) {
|
if (this.sessionStarted) {
|
||||||
this.emit('session:end');
|
this.emit('session:end');
|
||||||
this.releaseGroup('session');
|
this.releaseGroup('session');
|
||||||
|
Loading…
Reference in New Issue
Block a user