]> git.mxchange.org Git - hub.git/commitdiff
Added NodeAnnouncementCompletedState which will be the next after 'announced' to...
authorRoland Häder <roland@mxchange.org>
Sat, 18 Aug 2012 16:44:16 +0000 (16:44 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 18 Aug 2012 16:44:16 +0000 (16:44 +0000)
.gitattributes
application/hub/config.php
application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php
application/hub/main/states/node/announced/class_NodeAnnouncedState.php
application/hub/main/states/node/announced/class_NodeAnnouncementCompletedState.php [new file with mode: 0644]

index ada260a725ba25652eb284524c9110fccfe26354..ad47d6d8dbfcca36f9ad7ef9eaaa530da69dfe83 100644 (file)
@@ -499,6 +499,7 @@ application/hub/main/states/node/active/.htaccess -text svneol=unset#text/plain
 application/hub/main/states/node/active/class_NodeActiveState.php svneol=native#text/plain
 application/hub/main/states/node/announced/.htaccess -text svneol=unset#text/plain
 application/hub/main/states/node/announced/class_NodeAnnouncedState.php svneol=native#text/plain
+application/hub/main/states/node/announced/class_NodeAnnouncementCompletedState.php svneol=native#text/plain
 application/hub/main/states/node/class_ svneol=native#text/plain
 application/hub/main/states/node/class_BaseNodeState.php svneol=native#text/plain
 application/hub/main/states/node/init/.htaccess -text svneol=unset#text/plain
index 5df512833e9e4b6e72b4463f9dd0f6f2534467d5..35215b2650fe0d7aa4855b34fbbff70c86b8dd39 100644 (file)
@@ -543,6 +543,9 @@ $cfg->setConfigEntry('node_announced_state_class', 'NodeAnnouncedState');
 // CFG: NODE-REACHABLE-STATE-CLASS
 $cfg->setConfigEntry('node_reachable_state_class', 'NodeReachableState');
 
+// CFG: NODE-ANNOUNCEMENT-COMPLETED-STATE-CLASS
+$cfg->setConfigEntry('node_announcement_completed_state_class', 'NodeAnnouncementCompletedState');
+
 // CFG: NETWORK-PACKAGE-CLASS
 $cfg->setConfigEntry('network_package_class', 'NetworkPackage');
 
index 5be1a0abc01fe861a774f5c86bc0dc673431fcbb..da3f656153673cb74e4f0ea402ed88f75c70f5cc 100644 (file)
@@ -54,6 +54,7 @@ class AnnouncementAnswerOkayHandler extends BaseAnserStatusHandler implements Ha
         * @param       $messageData    An array of message data
         * @return      void
         * @throws      NodeSessionIdVerficationException       If the provided session id is not matching
+        * @todo        Do some more here: Handle karma, et cetera?
         */
        public function handleAnswerMessageData (array $messageData) {
                // Get a database wrapper instance
@@ -81,6 +82,12 @@ class AnnouncementAnswerOkayHandler extends BaseAnserStatusHandler implements Ha
 
                // Update node data (include status code)
                $wrapperInstance->updateNodeByMessageData($messageData, $this, $searchInstance);
+
+               // Get the node instance
+               $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+               // Change state
+               $nodeInstance->getStateInstance()->nodeAnnouncementSuccessful();
        }
 }
 
index ab9b0e6d4c6aaee085d2494aef9e315217aaf728..1a3200101c83ce1c9af4a4ccf7e9961414ab17ac 100644 (file)
@@ -51,6 +51,17 @@ class NodeAnnouncedState extends BaseNodeState implements Stateable {
                // Return the prepared instance
                return $stateInstance;
        }
+
+       /**
+        * Changes the state if the announcement (to bootstrap node) was
+        * successful.
+        *
+        * @return      void
+        */
+       public function nodeAnnouncementSuccessful () {
+               // The node's announcement was successful
+               NodeStateFactory::createNodeStateInstanceByName('announcement_completed', $this->getNodeInstance());
+       }
 }
 
 // [EOF]
diff --git a/application/hub/main/states/node/announced/class_NodeAnnouncementCompletedState.php b/application/hub/main/states/node/announced/class_NodeAnnouncementCompletedState.php
new file mode 100644 (file)
index 0000000..91bdf48
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+/**
+ * A AnnouncementCompleted node state class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class NodeAnnouncementCompletedState extends BaseNodeState implements Stateable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set state name
+               $this->setStateName('announcement_completed');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $nodeInstance   An instance of a NodeHelper class
+        * @return      $stateInstance  An instance of a Stateable class
+        */
+       public static final function createNodeAnnouncementCompletedState (NodeHelper $nodeInstance) {
+               // Get new instance
+               $stateInstance = new NodeAnnouncementCompletedState();
+
+               // Set the node instance
+               $stateInstance->setNodeInstance($nodeInstance);
+
+               // Return the prepared instance
+               return $stateInstance;
+       }
+}
+
+// [EOF]
+?>