]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/handler/message-types/anouncement/class_NodeMessageAnnouncementHandler.php
Added internal IP handling (unfinished), added package tags
[hub.git] / application / hub / main / handler / message-types / anouncement / class_NodeMessageAnnouncementHandler.php
index adbd315549372b068e24015def4b71a4839c207c..368a156524a9b679ee04486face545d0a47aed79 100644 (file)
@@ -37,11 +37,19 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl
                // Init message data array
                $this->messageDataElements = array(
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP,
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP,
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT,
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_UDP_PORT
                );
+
+               // Init message-data->configuration translation array
+               $this->messageToConfig = array(
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP => 'other_external_ip',
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP => 'other_internal_ip',
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID  => 'other_session_id'
+               );
        }
 
        /**
@@ -102,6 +110,44 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl
                        $dataSetInstance->addCriteria('node_' . $key, $messageData[$key]);
                } // END - foreach
        }
+
+       /**
+        * Initializes configuration data from given message data array
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       protected function initMessageConfigurationData (array $messageData) {
+               // "Walk" throught the translation array
+               foreach ($this->messageToConfig as $messageKey => $configKey) {
+                       // Set the element in configuration
+                       $this->getConfigInstance()->setConfigEntry($configKey, $messageData[$messageKey]);
+               } // END - foreach
+
+               // Translate last exception into a status code
+               $statusCode = $this->getTranslatedStatusFromLastException();
+
+               // Set it in configuration (temporarily)
+               $this->getConfigInstance()->setConfigEntry('answer_status', $statusCode);
+       }
+
+       /**
+        * Removes configuration data with given message data array from global
+        * configuration
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       protected function removeMessageConfigurationData (array $messageData) {
+               // "Walk" throught the translation array again
+               foreach ($this->messageToConfig as $dummy => $configKey) {
+                       // Now unset this configuration entry (to save some memory)
+                       $this->getConfigInstance()->unsetConfigEntry($configKey);
+               } // END - foreach
+
+               // Remove 'answer_status' as well
+               $this->getConfigInstance()->unsetConfigEntry('answer_status');
+       }
 }
 
 // [EOF]