Commit 7458497759b9b68ceda8a03baa511f01b0692947

Authored by Adhidarma Hadiwinoto
1 parent 6222f4f937
Exists in master

pingMySelf

Showing 1 changed file with 17 additions and 1 deletions Side-by-side Diff

... ... @@ -34,6 +34,13 @@ var logger = new (winston.Logger)({
34 34 ]
35 35 });
36 36  
  37 +function pingMySelf() {
  38 + if (warming_up) {
  39 + return;
  40 + }
  41 +
  42 + sendMessage(config.globals.jid, "PING " + strftime('%F %T', new Date()));
  43 +}
37 44  
38 45 function xmppConnect() {
39 46 logger.info('Connecting to XMPP server');
... ... @@ -73,7 +80,10 @@ function createHttpListener() {
73 80 }
74 81  
75 82 function sendMessage(destination, message) {
76   - logger.info('Sending xmpp message', {from: config.globals.jid, to: destination, message: message});
  83 + if (destination != config.globals.jid) {
  84 + logger.info('Sending xmpp message', {from: config.globals.jid, to: destination, message: message});
  85 + }
  86 +
77 87 xmpp.send(destination, message);
78 88 }
79 89  
... ... @@ -114,6 +124,10 @@ xmpp.on('online', function(data) {
114 124 });
115 125  
116 126 xmpp.on('chat', function(from, message) {
  127 + if (from == config.globals.jid) {
  128 + return;
  129 + }
  130 +
117 131 logger.info('Incoming message via XMPP ', {to: config.globals.jid, from: from, message: message});
118 132  
119 133 if (warming_up) {
... ... @@ -141,3 +155,5 @@ xmpp.on('subscribe', function(from) {
141 155  
142 156 createHttpListener();
143 157 xmppConnect();
  158 +
  159 +setInterval(pingMySelf, 60000);