]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/nodes/class_BaseHubNode.php
Decorators for hub/client listeners added
[hub.git] / application / hub / main / nodes / class_BaseHubNode.php
index 1f39c2decb9a0147a07d26283011b1c129b33032..c76e89776964fe7213137609aa79383a7c7d5ae9 100644 (file)
@@ -342,21 +342,49 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                // Get a new pool instance
                $this->listenerPoolInstance = ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this));
 
-               // Initialize both listeners
-               foreach (array('tcp', 'udp') as $protocol) {
-                       // Get an instance
-                       $listenerInstance = ObjectFactory::createObjectByConfiguredName($protocol . '_listener_class', array($this));
+               // Get an instance of the low-level listener
+               $listenerInstance = ObjectFactory::createObjectByConfiguredName('tcp_listener_class', array($this));
 
-                       // Setup address and port
-                       $listenerInstance->setListenAddressByConfiguration('node_listen_addr');
-                       $listenerInstance->setListenPortByConfiguration('node_' . $protocol . '_listen_port');
+               // Setup address and port
+               $listenerInstance->setListenAddressByConfiguration('node_listen_addr');
+               $listenerInstance->setListenPortByConfiguration('node_tcp_listen_port');
 
-                       // Initialize the listener
-                       $listenerInstance->initListener();
+               // Initialize the listener
+               $listenerInstance->initListener();
 
-                       // Add this listener to the pool
-                       $this->listenerPoolInstance->addListener($listenerInstance);
-               } // END - foreach
+               // Get a decorator class
+               $decoratorInstance = ObjectFactory::createObjectByConfiguredName('hub_tcp_listener_class', array($listenerInstance));
+
+               // Add this listener to the pool
+               $this->listenerPoolInstance->addListener($decoratorInstance);
+
+               // Get a decorator class
+               $decoratorInstance = ObjectFactory::createObjectByConfiguredName('client_tcp_listener_class', array($listenerInstance));
+
+               // Add this listener to the pool
+               $this->listenerPoolInstance->addListener($decoratorInstance);
+
+               // Get an instance of the low-level 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();
+
+               // Get a decorator class
+               $decoratorInstance = ObjectFactory::createObjectByConfiguredName('hub_udp_listener_class', array($listenerInstance));
+
+               // Add this listener to the pool
+               $this->listenerPoolInstance->addListener($decoratorInstance);
+
+               // Get a decorator class
+               $decoratorInstance = ObjectFactory::createObjectByConfiguredName('client_udp_listener_class', array($listenerInstance));
+
+               // Add this listener to the pool
+               $this->listenerPoolInstance->addListener($decoratorInstance);
        }
 }