X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=scripts%2Fxmppdaemon.php;h=69512f243895e6d6d2a9c023a5408638f141e1a1;hb=ec83890bc242650b169a524c373f488bb652265c;hp=ca62181203a6952167e33e4c690318e59c582d42;hpb=87e3c52fa80ca15e00ae0d1892999fc5be6282a1;p=quix0rs-gnu-social.git diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php index ca62181203..69512f2438 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,8 +108,23 @@ 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) @@ -116,6 +133,11 @@ class XMPPDaemon extends Daemon $this->conn->processUntil('session_start'); $this->log(LOG_DEBUG, "Sending reconnection presence."); $this->conn->presence('Send me a message to post a notice', 'available', null, 'available', 100); + unset($pl['xml']); + $pl['xml'] = null; + + $pl = null; + unset($pl); } function get_user($from) @@ -153,6 +175,10 @@ class XMPPDaemon extends Daemon $user = $this->get_user($from); + // For common_current_user to work + global $_cur; + $_cur = $user; + if (!$user) { $this->from_site($from, 'Unknown user; go to ' . common_local_url('imsettings') . @@ -189,6 +215,13 @@ class XMPPDaemon extends Daemon $user->free(); unset($user); + unset($_cur); + + unset($pl['xml']); + $pl['xml'] = null; + + $pl = null; + unset($pl); } function is_self($from) @@ -334,6 +367,11 @@ class XMPPDaemon extends Daemon } break; } + unset($pl['xml']); + $pl['xml'] = null; + + $pl = null; + unset($pl); } function log($level, $msg)