summaryrefslogtreecommitdiff
path: root/scripts/xmppdaemon.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-07-11 07:30:26 -0700
committerEvan Prodromou <evan@controlyourself.ca>2009-07-11 07:30:26 -0700
commit55415652382d1f3ae77123d197e01d95da83041e (patch)
tree449ee7e9aebe184583f099e49a7194eb5bbf8543 /scripts/xmppdaemon.php
parentbfae5489cb629331f2936b2bf1066adb3976bce1 (diff)
parent7621e0e38467349a89f71e814941932fbacecfa1 (diff)
Merge branch 'testing'
Diffstat (limited to 'scripts/xmppdaemon.php')
-rwxr-xr-xscripts/xmppdaemon.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php
index bd1918ca9..488b4b514 100755
--- a/scripts/xmppdaemon.php
+++ b/scripts/xmppdaemon.php
@@ -60,7 +60,9 @@ class XMPPDaemon extends Daemon
$this->resource = common_config('xmpp', 'resource') . 'daemon';
}
- $this->log(LOG_INFO, "INITIALIZE XMPPDaemon {$this->user}@{$this->server}/{$this->resource}");
+ $this->jid = $this->user.'@'.$this->server.'/'.$this->resource;
+
+ $this->log(LOG_INFO, "INITIALIZE XMPPDaemon {$this->jid}");
}
function connect()
@@ -106,10 +108,25 @@ class XMPPDaemon extends Daemon
$this->log(LOG_DEBUG, "Beginning processing loop.");
- $this->conn->process();
+ while ($this->conn->processTime(60)) {
+ $this->sendPing();
+ }
}
}
+ function sendPing()
+ {
+ if (!isset($this->pingid)) {
+ $this->pingid = 0;
+ } else {
+ $this->pingid++;
+ }
+
+ $this->log(LOG_DEBUG, "Sending ping #{$this->pingid}");
+
+ $this->conn->send("<iq from='{$this->jid}' to='{$this->server}' id='ping_{$this->pingid}' type='get'><ping xmlns='urn:xmpp:ping'/></iq>");
+ }
+
function handle_reconnect(&$pl)
{
$this->log(LOG_DEBUG, "Got reconnection callback.");