]> git.mxchange.org Git - hub.git/commitdiff
While self-connect is running, it might be already announced which is fine
authorRoland Häder <roland@mxchange.org>
Thu, 17 May 2012 13:42:21 +0000 (13:42 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 17 May 2012 13:42:21 +0000 (13:42 +0000)
application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php
application/hub/main/states/node/class_BaseNodeState.php

index 6e999537aa97982ea78bb0031758e828233fb161..1f210fba22f5d2ff26e7189ba5e34929d6f3bcb8 100644 (file)
@@ -84,7 +84,7 @@ class HubSelfConnectHelper extends BaseHubHelper implements HelpableHub {
         */
        public function sendPackage (NodeHelper $nodeInstance) {
                // Sanity check: Is the node in the approx. state? (active)
-               $nodeInstance->getStateInstance()->validateNodeStateIsActive();
+               $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrAnnounced();
 
                // Compile the template, this inserts the loaded node data into the gaps.
                $this->getTemplateInstance()->compileTemplate();
index 99ee452b7674f9d6656150596edf8d2f9f563ed7..d7a1bf962a9abd32bda03ac9361f9178b520878c 100644 (file)
@@ -47,6 +47,21 @@ class BaseNodeState extends BaseState {
                        throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE);
                } // END - if
        }
+
+       /**
+        * Validates whether the state is 'active' or 'announced' or throws an
+        * exception if it is every other state.
+        *
+        * @return      void
+        * @throws      InvalidStateException   If the state is not 'active'
+        */
+       public function validateNodeStateIsActiveOrAnnounced () {
+               // Just compare it...
+               if ((!$this instanceof NodeActiveState) && (!$this instanceof NodeAnnouncedState) {
+                       // Throw the exception
+                       throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE);
+               } // END - if
+       }
 }
 
 // [EOF]