From: Roland Häder Date: Tue, 7 Jul 2009 19:29:41 +0000 (+0000) Subject: Method addListener() added X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=fd2ceb64f224067ebc5e0b0afe8883e0a2378019;p=hub.git Method addListener() added --- diff --git a/application/hub/interfaces/pool/class_Poolable.php b/application/hub/interfaces/pool/class_Poolable.php index 8a9511748..1f58cb080 100644 --- a/application/hub/interfaces/pool/class_Poolable.php +++ b/application/hub/interfaces/pool/class_Poolable.php @@ -22,6 +22,13 @@ * along with this program. If not, see . */ interface Poolable extends FrameworkInterface { + /** + * Adds a listener instance to this pool + * + * @param $listenerInstance An instance of a Listenable class + * @return void + */ + function addListener (Listenable $listenerInstance); } // diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index db16c7742..909343ea3 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -343,6 +343,9 @@ class BaseHubNode extends BaseHubSystem implements Updateable { // 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)); @@ -352,6 +355,9 @@ class BaseHubNode extends BaseHubSystem implements Updateable { // Initialize the listener $listenerInstance->initListener(); + + // Add this listener to the pool + $this->listenerPoolInstance->addListener($listenerInstance); } } diff --git a/application/hub/main/pools/class_ b/application/hub/main/pools/class_ index 65b82bb45..83265f335 100644 --- a/application/hub/main/pools/class_ +++ b/application/hub/main/pools/class_ @@ -48,7 +48,18 @@ class ???Pool extends BasePool implements Poolable { // Return the prepared instance return $listenerInstance; } + + /** + * Adds a listener instance to this pool + * + * @param $listenerInstance An instance of a Listenable class + * @return void + * @todo 0% done + */ + public function addListener (Listenable $listenerInstance) { + $this->partialStub('Need to implement this method. listenerInstance=' . $listenerInstance->__toString()); + } } -// [EOF] +// ?> diff --git a/application/hub/main/pools/class_BasePool.php b/application/hub/main/pools/class_BasePool.php index 908d1942c..6fb5bd1fd 100644 --- a/application/hub/main/pools/class_BasePool.php +++ b/application/hub/main/pools/class_BasePool.php @@ -22,6 +22,11 @@ * along with this program. If not, see . */ class BasePool extends BaseHubSystem { + /** + * A list of instances for this pool + */ + private $instancePool = array(); + /** * Protected constructor * @@ -32,6 +37,17 @@ class BasePool extends BaseHubSystem { // Call parent constructor parent::__construct($className); } + + /** + * Adds an instance to a pool segment + * + * @param $poolSegment Name of the pool segment + * @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; + } } // [EOF] diff --git a/application/hub/main/pools/listener/class_DefaultListenerPool.php b/application/hub/main/pools/listener/class_DefaultListenerPool.php index a01ef687e..ce7fe90c5 100644 --- a/application/hub/main/pools/listener/class_DefaultListenerPool.php +++ b/application/hub/main/pools/listener/class_DefaultListenerPool.php @@ -51,6 +51,17 @@ class DefaultListenerPool extends BasePool implements Poolable { // Return the prepared instance return $listenerInstance; } + + /** + * Adds a listener instance to this pool + * + * @param $listenerInstance An instance of a Listenable class + * @return void + */ + public function addListener (Listenable $listenerInstance) { + // Add this listener instance to the instance list + parent::addInstance('listener', $listenerInstance); + } } // [EOF]