]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/nodes/class_BaseHubNode.php
Field answer_status becomes more generic now
[hub.git] / application / hub / main / nodes / class_BaseHubNode.php
index 22d7273b958c566db0a025e45ee83e37390f7901..1dca6472acb233e396c83f8dd0aaddc78cacae61 100644 (file)
@@ -742,6 +742,26 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                return $hasAnnounced;
        }
 
+       /**
+        * Checks whether this node has attempted to announce itself and completed it
+        *
+        * @return      $hasAnnouncementCompleted       Whether this node has attempted to announce itself and completed it
+        * @todo        Add checking if this node has been announced to the sender node
+        */
+       public function ifNodeHasAnnouncementCompleted () {
+               // Debug message
+               /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE: ifNodeHasAnnouncementCompleted(): state=' . $this->getStateInstance()->getStateName());
+
+               // Simply check the state of this node
+               $hasAnnouncementCompleted = ($this->getStateInstance() instanceof NodeAnnouncementCompletedState);
+
+               // Debug message
+               /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE: ifNodeHasAnnouncementCompleted(): hasAnnouncementCompleted=' . intval($hasAnnouncementCompleted));
+
+               // Return it
+               return $hasAnnouncementCompleted;
+       }
+
        /**
         * Enables whether this node accepts announcements
         *
@@ -806,8 +826,11 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
         * @todo        Handle thrown exception
         */
        public function handleAnswerStatusByMessageData (array $messageData, Receivable $packageInstance) {
+               // Is it not empty?
+               assert(!empty($messageData[NetworkPackage::MESSAGE_DATA_ANSWER_STATUS]));
+
                // Construct configuration entry for handling class' name
-               $classConfigEntry = strtolower($messageData[NetworkPackage::MESSAGE_ARRAY_TYPE] . '_status_' . $messageData[XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_ANSWER_STATUS]) . '_handler_class';
+               $classConfigEntry = strtolower($messageData[NetworkPackage::MESSAGE_ARRAY_TYPE] . '_status_' . $messageData[NetworkPackage::MESSAGE_DATA_ANSWER_STATUS]) . '_handler_class';
 
                // Try to get a class
                $handlerInstance = ObjectFactory::createObjectByConfiguredName($classConfigEntry);