]> git.mxchange.org Git - hub.git/commitdiff
Missing configuration data is now temporary being copied
authorRoland Häder <roland@mxchange.org>
Sat, 26 May 2012 23:06:44 +0000 (23:06 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 26 May 2012 23:06:44 +0000 (23:06 +0000)
application/hub/main/handler/message-types/anouncement/class_NodeMessageAnnouncementHandler.php
application/hub/main/handler/message-types/class_BaseMessageHandler.php

index 7ca1e2dd97957aa9b497c7a05a5968a04001bb5b..a7fd43633758e399336b8ed806b3de68662c1966 100644 (file)
@@ -50,6 +50,16 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP => 'your_internal_ip',
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID  => 'your_session_id'
                );
+
+               // Init config-copy array
+               $this->configCopy = array(
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP => 'external_ip',
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP => 'internal_ip',
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => 'node_status',
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID  => 'session_id',
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT    => 'node_tcp_listen_port',
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_UDP_PORT    => 'node_udp_listen_port'
+               );
        }
 
        /**
@@ -118,12 +128,27 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl
         * @return      void
         */
        protected function initMessageConfigurationData (array $messageData) {
+               // Debug message
+               //* NOISY-DEBUG: */ $this->debugOutput('ANNOUNCEMENT-HANDLER: messageData=' . print_r($messageData, true));
+
                // "Walk" throught the translation array
                foreach ($this->messageToConfig as $messageKey => $configKey) {
+                       // Debug message
+                       /* NOISY-DEBUG: */ $this->debugOutput('ANNOUNCEMENT-HANDLER: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]);
+
                        // Set the element in configuration
                        $this->getConfigInstance()->setConfigEntry($configKey, $messageData[$messageKey]);
                } // END - foreach
 
+               // "Walk" throught the config-copy array
+               foreach ($this->configCopy as $targetKey => $sourceKey) {
+                       // Debug message
+                       /* NOISY-DEBUG: */ $this->debugOutput('ANNOUNCEMENT-HANDLER: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
+
+                       // Copy from source to targetKey
+                       $this->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey));
+               } // END - foreach
+
                // Translate last exception into a status code
                $statusCode = $this->getTranslatedStatusFromLastException();
 
@@ -145,6 +170,12 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl
                        $this->getConfigInstance()->unsetConfigEntry($configKey);
                } // END - foreach
 
+               // "Walk" throught the config-copy array again
+               foreach ($this->configCopy as $configKey => $dummy) {
+                       // Now unset this configuration entry (to save some memory again)
+                       $this->getConfigInstance()->unsetConfigEntry($configKey);
+               } // END - foreach
+
                // Remove 'answer_status' as well
                $this->getConfigInstance()->unsetConfigEntry('answer_status');
        }
index 4763b03cdf7e14f3a54df533047745cd62e0919e..a798e9951966f3d02162da9735382f544cd3579b 100644 (file)
@@ -39,6 +39,11 @@ abstract class BaseMessageHandler extends BaseHandler {
         */
        protected $messageToConfig = array();
 
+       /**
+        * Array for copying configuration entries
+        */
+       protected $configCopy = array();
+
        /**
         * Last exception instance from database layer or NULL (default)
         */
@@ -141,6 +146,9 @@ abstract class BaseMessageHandler extends BaseHandler {
         * @return      void
         */
        protected function prepareAnswerMessage (array $messageData, Deliverable $packageInstance) {
+               // Debug message
+               /* NOIST-DEBUG: */ $this->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Going to send an answer message ...');
+
                // Get a helper instance based on this handler's name
                $helperInstance = ObjectFactory::createObjectByConfiguredName('node_answer_' . $this->getHandlerName() . '_helper_class', array($messageData));
 
@@ -166,6 +174,9 @@ abstract class BaseMessageHandler extends BaseHandler {
                 * Remove temporary configuration
                 */
                $this->removeMessageConfigurationData($messageData);
+
+               // Debug message
+               /* NOIST-DEBUG: */ $this->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Answer message has been prepared.');
        }
 
        /**