]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
XMPP daemon that doesn't eat messages - note change to XMPPHP as well (Ticket #551)
authorCiaranG <ciaran@ciarang.com>
Tue, 26 Aug 2008 20:00:57 +0000 (16:00 -0400)
committerCiaranG <ciaran@ciarang.com>
Tue, 26 Aug 2008 20:00:57 +0000 (16:00 -0400)
darcs-hash:20080826200057-f6e2c-fb9a88251d034824218d20b3fefcde96ddaef827.gz

extlib/XMPPHP/XMLStream.php
scripts/xmppdaemon.php

index 4de23ef7fba951c9635b11e7138d8a90a1358281..2ed2f5e029ed152df0a6cfb376a851cbced27778 100644 (file)
@@ -242,7 +242,7 @@ class XMPPHP_XMLStream {
         * @param string  $obj
         */
        public function addEventHandler($name, $pointer, $obj) {
-               $this->eventhandlers[] = array($name, $pointer, $obj);
+               $this->eventhanders[] = array($name, $pointer, $obj);
        }
 
        /**
@@ -521,6 +521,7 @@ class XMPPHP_XMLStream {
                                if($handler[2] === null) {
                                        $handler[2] = $this;
                                }
+                               $this->log->log("Calling {$handler[1]}", XMPPHP_Log::LEVEL_DEBUG);
                                $handler[2]->$handler[1]($payload);
                        }
                }
index 07b8d24e5517f90dd174c6bb8f9bb5d862de2fd2..c15f28113121cb73d4cfd515fb35edc564eebb5c 100755 (executable)
@@ -96,39 +96,16 @@ class XMPPDaemon {
 
        function handle() {
 
-               static $parts = array('message', 'presence',
-                                                         'end_stream', 'session_start');
-
+               $this->conn->addEventHandler('message','handle_message',$this);
+               $this->conn->addEventHandler('presence','handle_presence',$this);
                while(!$this->conn->isDisconnected()) {
 
-                       $payloads = $this->conn->processUntil($parts, 10);
-
-                       if ($payloads) {
-                               foreach($payloads as $event) {
-                                       $pl = $event[1];
-                                       switch($event[0]) {
-                                        case 'message':
-                                               $this->handle_message($pl);
-                                               break;
-                                        case 'presence':
-                                               $this->handle_presence($pl);
-                                               break;
-                                        case 'session_start':
-                                               $this->handle_session($pl);
-                                               break;
-                                       }
-                               }
-                       }
-
+                       $this->conn->processTime(10);
                        $this->broadcast_queue();
                        $this->confirmation_queue();
                }
        }
 
-       function handle_session($pl) {
-               # XXX what to do here?
-               return true;
-       }
 
        function get_user($from) {
                $user = User::staticGet('jabber', jabber_normalize_jid($from));