From d77a2ee6adce4175e20992342623d72842d7593b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 9 Jul 2009 09:31:10 -0400 Subject: [PATCH] send a ping from the xmppdaemon --- scripts/xmppdaemon.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php index bd1918ca98..488b4b514c 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(""); + } + function handle_reconnect(&$pl) { $this->log(LOG_DEBUG, "Got reconnection callback."); -- 2.39.5