From b69ad17139e398814453453009879881ffda6a68 Mon Sep 17 00:00:00 2001 From: Luke Bonaccorsi Date: Sat, 27 Feb 2016 01:25:47 +0000 Subject: [PATCH] Guarding around accidental recursion --- index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 0130e46..4d37310 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,7 @@ var xmppCore = require('node-xmpp-core'), this.name = 'hangouts'; this.displayname = 'Google Hangouts Chat'; this.description = 'Send messages to woodhouse via Google Hangouts'; + this.disconnected = false; this.defaultPrefs = [{ name: 'username', @@ -38,11 +39,15 @@ hangouts.prototype.connect = function() { this.connection.connection.socket.setKeepAlive(true, 10000) this.connection.on('disconnect', function() { - this.connection.end(); - this.connect(); + if (!this.disconnected) { + this.disconnected = true; + this.connection.end(); + this.connect(); + } }.bind(this)) this.connection.on('online', function() { + this.disconnected = false; connection.send(new xmppCore.Element('presence', {}) .c('show') .t('chat')