Skip to content

Commit

Permalink
reduced interval of connection live presence sending to 10 seconds fr…
Browse files Browse the repository at this point in the history
…om 60

enhanced buddy event with adding friendly status and indentified unvailable stanza
  • Loading branch information
arunoda committed Aug 13, 2011
1 parent 4554713 commit ffc38d7
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lib/simple-xmpp.js
Expand Up @@ -32,8 +32,8 @@ var STATUS = {
AWAY: "away",
DND: "dnd",
XA: "xa",
CHAT: "chat",
ONLINE: ""
ONLINE: "online",
OFFLINE: "offline"
};

module.exports = new SimpleXMPP();
Expand Down Expand Up @@ -81,12 +81,12 @@ function SimpleXMPP() {
//make the connection live
setInterval(function() {
conn.send(new xmpp.Element('presence'));
}, 1000 * 60)
}, 1000 * 10)
});

conn.on('stanza', function(stanza) {

// console.log(stanza);
console.log(stanza);
//looking for message stanza
if (stanza.is('message')) {

Expand All @@ -106,7 +106,8 @@ function SimpleXMPP() {
if(from) {
var id = from.split('/')[0];
var state = (stanza.getChild('show'))? stanza.getChild('show').getText(): STATUS.ONLINE;

state = (state == 'chat')? STATUS.ONLINE : state;
state = (stanza.attrs.type == STATUS.OFFLINE)? STATUS.OFFLINE : state;
//checking if this is based on probe
if(probeBuddies[id]) {
events.emit('probe_' + id, state);
Expand All @@ -123,10 +124,6 @@ function SimpleXMPP() {
events.emit('error', err);
});

conn.on('timeout', function(ww) {
console.log('2323232j3j23j2j3j23j %s', ww);
});

};
}

Expand Down

0 comments on commit ffc38d7

Please sign in to comment.