]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/nodes/class_BaseHubNode.php
TCP/UDP listener config entries added, some more stub calls added
[hub.git] / application / hub / main / nodes / class_BaseHubNode.php
index d2755f21f7fa4e8d6554207c49e764bf0d78d2bb..590aaa8fed363865a74d7855d7287bd0808da376 100644 (file)
@@ -37,6 +37,16 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable {
         */
        private $queryInstance = null;
 
+       /**
+        * Listener pool instance
+        */
+       private $listenerPoolInstance = null;
+
+       /**
+        * Wether the hub is active (true/false)
+        */
+       private $hubIsActive = false;
+
        /**
         * Protected constructor
         *
@@ -156,15 +166,13 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable {
                $this->bootstrapAcquireHubId();
 
                // ------------------- More generic bootstrap steps -------------------
-               // Generate the session id which will only be stored in RAM
+               // Generate the session id which will only be stored in RAM and kept for
+               // the whole "session".
                $this->bootstrapGenerateSessionId();
 
-               // Restore a previously downloaded bootstrap-node list
+               // Restore a previously downloaded bootstrap-node list.
                $this->bootstrapRestoreNodeList();
 
-               // Download or update the bootstrap-node list
-               $this->bootstrapDownloadNodeList();
-
                // @TODO Add some generic bootstrap steps
                $this->partialStub('Add some generic bootstrap steps here.');
        }
@@ -284,6 +292,39 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable {
                // Remember the update in database result
                $this->getResultInstance()->add2UpdateQueue($updateInstance);
        }
+
+       /**
+        * Getter for $hubIsActive attribute
+        *
+        * @return      $hubIsActive    Wether the hub is activer
+        */
+       public final function isHubActive () {
+               return $this->hubIsActive;
+       }
+
+       /**
+        * Activates the hub by doing some final preparation and setting
+        * $hubIsActive to true
+        */
+       public function activateHub () {
+               // Checks wether a listener is still active and shuts it down if one
+               // is still listening
+               if (($this->checkIfListenerIsActive()) && ($this->isHubActive())) {
+                       // Shutdown them down before they can hurt anything
+                       $this->shutdownListenerPool();
+               } // END - if
+
+               // Initialize the TCP/UDP listener pool
+               $this->initializeListenerPool();
+
+               // @TODO Do some final preparation
+               $this->partialStub('Do some final preparation before the hub gots activated.');
+
+               // ----------------------- Last step from here ------------------------
+               // Activate the hub. This is ALWAYS the last step in this method
+               $this->hubIsActive = true;
+               // ---------------------- Last step until here ------------------------
+       }
 }
 
 // [EOF]