]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php
Updated 'core'.
[hub.git] / application / hub / main / handler / message-types / requests / class_NodeMessageRequestNodeListHandler.php
index fe39ae8491a05d2adeff80d2f06caf70520282c2..92cc25eacdeac5a15a13c280a43a30e77bbd8e80 100644 (file)
@@ -2,11 +2,11 @@
 /**
  * A NodeMessageRequestNodeList handler
  *
- * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @link               http://www.shipsimu.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
@@ -72,7 +72,7 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha
         */
        public function handleMessageData (array $messageData, Receivable $packageInstance) {
                // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Is this node accepting announcements?
                if (!$nodeInstance->isAcceptingNodeListRequests()) {
@@ -119,20 +119,17 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha
         */
        protected function initMessageConfigurationData (array $messageData) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __LINE__ . ']: messageData=' . print_r($messageData, true));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE));
 
                // "Walk" throught the config-copy array
                foreach ($this->configCopy as $targetKey => $sourceKey) {
                        // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __LINE__ . ']: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
 
                        // Copy from source to targetKey
                        $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey));
                } // END - foreach
 
-               // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __LINE__ . ']: Got a node list of ' . count($nodeList) . ' entry/-ies back.');
-
                // Query local DHT for nodes except given session id
                $nodeList = $this->getDhtInstance()->queryLocalNodeListExceptByMessageData(
                        $messageData,
@@ -142,14 +139,17 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha
                        BaseHubNode::OBJECT_LIST_SEPARATOR
                );
 
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Got a node list of ' . count($nodeList) . ' entry/-ies back.');
+
                // Set it serialized in configuration (temporarily)
-               $this->getConfigInstance()->setConfigEntry('node_list', base64_encode(serialize($nodeList)));
+               $this->getConfigInstance()->setConfigEntry('node_list', base64_encode(json_encode($nodeList)));
 
                // Translate last exception into a status code
                $statusCode = $this->getTranslatedStatusFromLastException();
 
                // Set it in configuration (temporarily)
-               $this->getConfigInstance()->setConfigEntry('answer_status', $statusCode);
+               $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode);
        }
 
        /**
@@ -167,7 +167,7 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha
                } // END - foreach
 
                // Remove answer status/node list as well
-               $this->getConfigInstance()->unsetConfigEntry('answer_status');
+               $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS);
                $this->getConfigInstance()->unsetConfigEntry('node_list');
        }
 }