]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
add reconnect handlers to main XMPP-handling scripts
authorEvan Prodromou <evan@prodromou.name>
Tue, 2 Sep 2008 16:53:19 +0000 (12:53 -0400)
committerEvan Prodromou <evan@prodromou.name>
Tue, 2 Sep 2008 16:53:19 +0000 (12:53 -0400)
darcs-hash:20080902165319-84dde-b6cc255f014e6c5c059905c37c258a6c7a53b39a.gz

scripts/publicqueuehandler.php
scripts/xmppconfirmhandler.php
scripts/xmppdaemon.php
scripts/xmppqueuehandler.php

index 555298f6a9240674d9e4693b4d98fabfa388ff84..b482d029a78b5d3097b516cd2dce2c328cdf08d2 100755 (executable)
@@ -42,14 +42,16 @@ class PublicQueueHandler extends QueueHandler {
        function start() {
                $this->log(LOG_INFO, "INITIALIZE");
                # Low priority; we don't want to receive messages
-               $this->conn = jabber_connect($this->_id);
-               if ($this->conn) {
-                       $this->conn->addEventHandler('message', 'forward_message', $this);
-                       jabber_send_presence("Send me a message to post an notice", 'available', NULL, 'available', -1);
-               }
+               $this->conn = jabber_connect($this->_id, NULL, -1);
+               $this->conn->addEventHandler('message', 'forward_message', $this);
                return !is_null($this->conn);
        }
 
+       function handle_reconnect(&$pl) {
+               $this->conn->processUntil('session_start');
+               $this->conn->presence(NULL, 'available', NULL, 'available', -1);
+       }
+
        function handle_notice($notice) {
                return jabber_public_notice($notice);
        }
index 7971198b1e370cabacad98189d80f25d8494ed05..c63498f5519a468f52c7ecae5d22ad6c23eeab26 100755 (executable)
@@ -48,14 +48,16 @@ class XmppConfirmHandler {
        function start() {
                # Low priority; we don't want to receive messages
                $this->log(LOG_INFO, "INITIALIZE");
-               $this->conn = jabber_connect($this->_id);
-               if ($this->conn) {
-                       $this->conn->addEventHandler('message', 'forward_message', $this);
-                       jabber_send_presence("Send me a message to post an notice", 'available', NULL, 'available', -1);
-               }
+               $this->conn = jabber_connect($this->_id, NULL, -1);
+               $this->conn->addEventHandler('message', 'forward_message', $this);
                return !is_null($this->conn);
        }
        
+       function handle_reconnect(&$pl) {
+               $this->conn->processUntil('session_start');
+               $this->conn->presence(NULL, 'available', NULL, 'available', -1);
+       }
+       
        function handle_queue() {
                $this->log(LOG_INFO, 'checking for queued confirmations');
                do {
index 03cadee7cb50a58819a16f9f3950b6ee91d8b435..2372a17e6d9883c8e72926ca33c080136b4a066b 100755 (executable)
@@ -75,10 +75,16 @@ class XMPPDaemon {
        function handle() {
                $this->conn->addEventHandler('message', 'handle_message', $this);
                $this->conn->addEventHandler('presence', 'handle_presence', $this);
+               $this->conn->addEventHandler('reconnect', 'handle_reconnect', $this);
 
                $this->conn->process();
        }
 
+       function handle_reconnect(&$pl) {
+               $this->conn->processUntil('session_start');
+               $this->conn->presence('Send me a message to post a notice', 'available', NULL, 'available', 100);
+       }
+       
        function get_user($from) {
                $user = User::staticGet('jabber', jabber_normalize_jid($from));
                return $user;
index 7f1e6c28f4629e5a2a1741a28e51fcd7b11f1a72..49d3df0f50924a669154691169bf4ee32dacd8fc 100755 (executable)
@@ -44,14 +44,16 @@ class XmppQueueHandler extends QueueHandler {
        function start() {
                $this->log(LOG_INFO, "INITIALIZE");
                # Low priority; we don't want to receive messages
-               $this->conn = jabber_connect($this->_id);
-               if ($this->conn) {
-                       $this->conn->addEventHandler('message', 'forward_message', $this);
-                       jabber_send_presence("Send me a message to post an notice", 'available', NULL, 'available', -1);
-               }
+               $this->conn = jabber_connect($this->_id, NULL, -1);
+               $this->conn->addEventHandler('message', 'forward_message', $this);
                return !is_null($this->conn);
        }
 
+       function handle_reconnect(&$pl) {
+               $this->conn->processUntil('session_start');
+               $this->conn->presence(NULL, 'available', NULL, 'available', -1);
+       }
+       
        function handle_notice($notice) {
                return jabber_broadcast_notice($notice);
        }