]> git.mxchange.org Git - hub.git/commitdiff
Grouping by protocol of listeners in pool added
authorRoland Häder <roland@mxchange.org>
Tue, 7 Jul 2009 21:03:40 +0000 (21:03 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 7 Jul 2009 21:03:40 +0000 (21:03 +0000)
application/hub/main/listener/class_BaseListener.php
application/hub/main/listener/class_BaseListenerDecorator.php
application/hub/main/listener/tcp/class_TcpListener.php
application/hub/main/listener/udp/class_UdpListener.php
application/hub/main/pools/class_BasePool.php
application/hub/main/pools/listener/class_DefaultListenerPool.php

index 48f0cbc7788110f6fcbafedec2f6d71d1f314105..3b8da261e9e5098d06840fd3796cef164939fea1 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseListener extends BaseHubSystem {
+       /**
+        * Used protocol (Default: invalid, which is invalid...)
+        */
+       private $protcol = 'invalid';
+
        /**
         * Address (IP mostly) we shall listen on
         */
@@ -105,6 +110,25 @@ class BaseListener extends BaseHubSystem {
        public final function setListenPortByConfiguration ($configEntry) {
                $this->setListenPort($this->getConfigInstance()->readConfig($configEntry));
        }
+
+       /**
+        * Setter for protocol
+        *
+        * @param       $protocol       Used protocol
+        * @return      void
+        */
+       protected final function setProtocol ($protocol) {
+               $this->protocol = (string) $protocol;
+       }
+
+       /**
+        * Getter for protocol
+        *
+        * @return      $protocol       Used protocol
+        */
+       public final function getProtocol () {
+               return $this->protocol;
+       }
 }
 
 // [EOF]
index 07d4beaf05e337878c6809700d596b3364bbf8fd..c228078df79071573d8c4d3e30e009b3815a20bd 100644 (file)
@@ -78,6 +78,15 @@ class BaseListenerDecorator extends BaseFrameworkSystem {
        public final function getListenPort () {
                return $this->getListenerInstance()->getListenPort();
        }
+
+       /**
+        * Getter for protocol
+        *
+        * @return      $protocol       The used protocol
+        */
+       public final function getProtocol () {
+               return $this->getListenerInstance()->getProtocol();
+       }
 }
 
 // [EOF]
index ea227ce7faf07184327862d706fd83545e847c8b..a8a9d3d95da08c5da037b28ca1de91fb877c3e68 100644 (file)
@@ -45,6 +45,9 @@ class TcpListener extends BaseListener implements Listenable {
                // Set the application instance
                $listenerInstance->setNodeInstance($nodeInstance);
 
+               // Set the protocol to TCP
+               $listenerInstance->setProtocol('tcp');
+
                // Return the prepared instance
                return $listenerInstance;
        }
index b3b25b866e30e03259d4a4d81ed28c60fae17bae..d37980e3345bb730d748ab96895a3f08fda90f20 100644 (file)
@@ -45,6 +45,9 @@ class UdpListener extends BaseListener implements Listenable {
                // Set the application instance
                $listenerInstance->setNodeInstance($nodeInstance);
 
+               // Set the protocol to UDP
+               $listenerInstance->setProtocol('udp');
+
                // Return the prepared instance
                return $listenerInstance;
        }
index 6fb5bd1fd572c115c97f9b09050df3b67c745a82..a5b711738637e1b112725a10081964f13d869e30 100644 (file)
@@ -45,8 +45,8 @@ class BasePool extends BaseHubSystem {
         * @param       $instance               An instance of a class we should add to the pool
         * @return      void
         */
-       protected final function addInstance($poolName, FrameworkInterface $instance) {
-               $this->instancePool[$poolName][] = $instance;
+       protected final function addInstance($group, $poolName, FrameworkInterface $instance) {
+               $this->instancePool[$group][$poolName][] = $instance;
        }
 }
 
index 524e81c0a5ea674079beb6783f4ee486be860f3e..051f7e62225a8a90a416b425db498f4bd99a0adb 100644 (file)
@@ -60,7 +60,7 @@ class DefaultListenerPool extends BasePool implements Poolable {
         */
        public function addListener (Listenable $listenerInstance) {
                // Add this listener instance to the instance list
-               parent::addInstance('listener', $listenerInstance);
+               parent::addInstance($listenerInstance->getProtocol(), 'listener', $listenerInstance);
 
                // Debug message
                $this->getDebugInstance()->output(