]> git.mxchange.org Git - hub.git/commitdiff
Listeners are now intialized in a simple loop
authorRoland Häder <roland@mxchange.org>
Tue, 7 Jul 2009 19:38:41 +0000 (19:38 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 7 Jul 2009 19:38:41 +0000 (19:38 +0000)
application/hub/main/nodes/class_BaseHubNode.php

index 909343ea3a23864d0b996aacd864bea3eea6256f..0823e5bc47daa6e6f91bf46e5b526bb5a33321ae 100644 (file)
@@ -333,31 +333,21 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                // Get a new pool instance
                $this->listenerPoolInstance = ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this));
 
-               // Initialize the TCP listener
-               $listenerInstance = ObjectFactory::createObjectByConfiguredName('tcp_listener_class', array($this));
+               // Initialize both listeners
+               foreach (array('tcp', 'udp') as $protocol) {
+                       // Get an instance
+                       $listenerInstance = ObjectFactory::createObjectByConfiguredName($protocol . '_listener_class', array($this));
 
-               // Setup address and port
-               $listenerInstance->setListenAddressByConfiguration('node_listen_addr');
-               $listenerInstance->setListenPortByConfiguration('node_tcp_listen_port');
+                       // Setup address and port
+                       $listenerInstance->setListenAddressByConfiguration('node_listen_addr');
+                       $listenerInstance->setListenPortByConfiguration('node_' . $protocol . '_listen_port');
 
-               // Initialize the listener
-               $listenerInstance->initListener();
+                       // Initialize the listener
+                       $listenerInstance->initListener();
 
-               // Add this listener to the pool
-               $this->listenerPoolInstance->addListener($listenerInstance);
-
-               // Initialize the UDP listener
-               $listenerInstance = ObjectFactory::createObjectByConfiguredName('udp_listener_class', array($this));
-
-               // Setup address and port
-               $listenerInstance->setListenAddressByConfiguration('node_listen_addr');
-               $listenerInstance->setListenPortByConfiguration('node_udp_listen_port');
-
-               // Initialize the listener
-               $listenerInstance->initListener();
-
-               // Add this listener to the pool
-               $this->listenerPoolInstance->addListener($listenerInstance);
+                       // Add this listener to the pool
+                       $this->listenerPoolInstance->addListener($listenerInstance);
+               } // END - foreach
        }
 }