Skip to content

Commit

Permalink
Guarding around accidental recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeFoodPixels committed Feb 27, 2016
1 parent 0493218 commit b69ad17
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit b69ad17

Please sign in to comment.