]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/nodes/class_BaseHubNode.php
Filters and chains added:
[hub.git] / application / hub / main / nodes / class_BaseHubNode.php
index 6325a94fbb3c6a7298f2064203c03036a285c8f8..7e5b121e5d643aded57b8c68c0aabfea316b98e0 100644 (file)
@@ -357,13 +357,24 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                return $this->hubIsActive;
        }
 
+       /**
+        * Setter for $hubIsActive attribute
+        *
+        * @param       $hubIsActive    Wether the hub is activer
+        */
+       public final function enableHubIsActive ($hubIsActive = true) {
+               $this->hubIsActive = $hubIsActive;
+       }
+
        /**
         * Activates the hub by doing some final preparation and setting
         * $hubIsActive to true
         *
+        * @param       $requestInstance        A Requestable class
+        * @param       $responseInstance       A Responseable class
         * @return      void
         */
-       public function activateHub () {
+       public function activateHub (Requestable $requestInstance, Responseable $responseInstance) {
                // Checks wether a listener is still active and shuts it down if one
                // is still listening
                if (($this->determineIfListenerIsActive()) && ($this->isHubActive())) {
@@ -371,15 +382,15 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                        $this->shutdownListenerPool();
                } // END - if
 
-               // Initialize the TCP/UDP listener pool
-               $this->initializeListenerPool();
+               // Get the controller here
+               $controllerInstance = Registry::getRegistry()->getInstance('controller');
 
-               // @TODO Do some final preparation
-               $this->partialStub('Do some final preparation before the hub gots activated.');
+               // Run all filters for the hub activation
+               $controllerInstance->executeHubActivationFilters($requestInstance, $responseInstance);
 
                // ----------------------- Last step from here ------------------------
                // Activate the hub. This is ALWAYS the last step in this method
-               $this->hubIsActive = true;
+               $this->enableHubIsActive();
                // ---------------------- Last step until here ------------------------
        }
 
@@ -388,7 +399,10 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
         *
         * @return      void
         */
-       private function initializeListenerPool () {
+       public function initializeListenerPool () {
+               // Debug output
+               $this->debugOutput('HUB: Initializing listeners...');
+
                // Get a new pool instance
                $this->listenerPoolInstance = ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this));
 
@@ -435,6 +449,9 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
 
                // Add this listener to the pool
                $this->listenerPoolInstance->addListener($decoratorInstance);
+
+               // Debug output
+               $this->debugOutput('HUB: All listeners are initialized.');
        }
 }