]> git.mxchange.org Git - hub.git/commitdiff
Introduced (currently not used as type-hints) new interfaces:
authorRoland Häder <roland@mxchange.org>
Wed, 30 May 2012 21:02:55 +0000 (21:02 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 30 May 2012 21:02:55 +0000 (21:02 +0000)
- Interface 'NodeInformationWrapper' introduced, this may help other developers to implement their own classes
- Interface 'NodeListWrapper' introduced with same intension
- TODOs.txt update

.gitattributes
application/hub/interfaces/wrapper/.htaccess [new file with mode: 0644]
application/hub/interfaces/wrapper/class_NodeInformationWrapper.php [new file with mode: 0644]
application/hub/interfaces/wrapper/class_NodeListWrapper.php [new file with mode: 0644]
application/hub/main/database/wrapper/node/class_NodeInformationDatabaseWrapper.php
application/hub/main/database/wrapper/node/class_NodeListDatabaseWrapper.php
application/hub/main/handler/message-types/class_BaseMessageHandler.php
docs/TODOs.txt

index bfa2f9443d726ea0892bc7aa8dc8113f76f1d80e..e50089001f37dc2c2b61b36f7144e2d0784288d5 100644 (file)
@@ -145,6 +145,9 @@ application/hub/interfaces/visitor/tasks/.htaccess -text svneol=unset#text/plain
 application/hub/interfaces/visitor/tasks/class_TaskVisitor.php svneol=native#text/plain
 application/hub/interfaces/work_units/.htaccess svneol=native#text/plain
 application/hub/interfaces/work_units/class_UnitHelper.php svneol=native#text/plain
+application/hub/interfaces/wrapper/.htaccess -text svneol=unset#text/plain
+application/hub/interfaces/wrapper/class_NodeInformationWrapper.php svneol=native#text/plain
+application/hub/interfaces/wrapper/class_NodeListWrapper.php svneol=native#text/plain
 application/hub/loader.php svneol=native#text/plain
 application/hub/main/.htaccess -text svneol=unset#text/plain
 application/hub/main/chat/.htaccess svneol=native#text/plain
diff --git a/application/hub/interfaces/wrapper/.htaccess b/application/hub/interfaces/wrapper/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/interfaces/wrapper/class_NodeInformationWrapper.php b/application/hub/interfaces/wrapper/class_NodeInformationWrapper.php
new file mode 100644 (file)
index 0000000..df6fa70
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/**
+ * An interface for node-information (database) wrapper
+ *
+ * @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/>.
+ */
+interface NodeInformationWrapper extends FrameworkInterface {
+       /**
+        * 'Registers' a new node id along with data provided in the node instance.
+        * This may sound confusing but avoids double code very nicely...
+        *
+        * @param       $nodeInstance           A node instance
+        * @param       $requestInstance        An instance of a Requestable class
+        * @return      void
+        */
+       function registerNodeId (BaseHubNode $nodeInstance, Requestable $requestInstance);
+
+       /**
+        * 'Registers' a new session id along with data provided in the node instance.
+        * This may sound confusing but avoids double code very nicely...
+        *
+        * @param       $nodeInstance           A node instance
+        * @param       $requestInstance        An instance of a Requestable class
+        * @return      void
+        */
+       function registerSessionId (BaseHubNode $nodeInstance, Requestable $requestInstance);
+}
+
+// [EOF]
+?>
diff --git a/application/hub/interfaces/wrapper/class_NodeListWrapper.php b/application/hub/interfaces/wrapper/class_NodeListWrapper.php
new file mode 100644 (file)
index 0000000..702ff0d
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/**
+ * An interface for node-list (database) wrapper
+ *
+ * @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/>.
+ */
+interface NodeListWrapper extends FrameworkInterface {
+       /**
+        * Resolves a session id into an ip:port combination
+        *
+        * @param       $sessionId      A valid session id
+        * @param       $protocol       Name of the protocol (TCP/UDP)
+        * @return      $recipient      Recipient as ip:port combination
+        */
+       function resolveIpPortBySessionId ($sessionId, $protocol);
+
+       /**
+        * Resolves a ip:port combination into a session id
+        *
+        * @param       $ipPort         Ip:port combination
+        * @param       $protocol       Name of the used protocol (TCP/UDP)
+        * @return      $sessionId      A valid session id
+        */
+       function resolveSessionIdByIpPort ($ipPort, $protocol);
+
+       /**
+        * Registeres a node by given message data.
+        *
+        * @param       $messageData            An array of all message data
+        * @param       $handlerInstance        An instance of a HandleableMessage class
+        * @return      void
+        */
+       function registerNodeByMessageData (array $messageData, HandleableMessage $handlerInstance);
+
+       /**
+        * Updates an existing entry in node list
+        *
+        * @param       $messageData            An array of all message data
+        * @param       $handlerInstance        An instance of a HandleableMessage class
+        * @return      void
+        */
+       function updateNodeByMessageData (array $messageData, HandleableMessage $handlerInstance);
+}
+
+// [EOF]
+?>
index 5f803f95b917a3bb4b760a22c56c295a68986ab3..86d14cece303d179f566f5c928a518fb9ec6241c 100644 (file)
@@ -21,7 +21,7 @@
  * 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 NodeInformationDatabaseWrapper extends BaseDatabaseWrapper {
+class NodeInformationDatabaseWrapper extends BaseDatabaseWrapper implements NodeInformationWrapper {
        // Constants for database table names
        const DB_TABLE_NODE_INFORMATION = 'node_data';
 
index 4ec539e9c34a41521e9f5e125993dc07a90288a9..6d47114467f1e47fbd64e428efd9665795c2b3e6 100644 (file)
@@ -21,7 +21,7 @@
  * 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 NodeListDatabaseWrapper extends BaseDatabaseWrapper implements Registerable {
+class NodeListDatabaseWrapper extends BaseDatabaseWrapper implements NodeListWrapper Registerable {
        // Table names
        const DB_TABLE_NODE_LIST = 'node_list';
 
@@ -183,6 +183,27 @@ class NodeListDatabaseWrapper extends BaseDatabaseWrapper implements Registerabl
                // Run the "INSERT" query
                $this->queryInsertDataSet($dataSetInstance);
        }
+
+       /**
+        * Updates an existing entry in node list
+        *
+        * @param       $messageData            An array of all message data
+        * @param       $handlerInstance        An instance of a HandleableMessage class
+        * @return      void
+        */
+       public function updateNodeByMessageData (array $messageData, HandleableMessage $handlerInstance) {
+               // Get a data set instance
+               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_LIST));
+
+               // Set primary key (session id)
+               $dataSetInstance->setUniqueKey('node_' . XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID);
+
+               // Add all array elements
+               $handlerInstance->addArrayToDataSet($dataSetInstance, $messageData);
+
+               // Run the "UPDATE" query
+               $this->queryUpdateDataSet($dataSetInstance);
+       }
 }
 
 // [EOF]
index 5b2ff9ba231e089e471b81d2f85ccab3690fafb9..4c8f30fc5fe9cbd70a76bcb85a9a9fdd206f29e4 100644 (file)
@@ -105,6 +105,7 @@ abstract class BaseMessageHandler extends BaseHandler {
         *
         * @param       $messageArray   An array with all minimum message data
         * @return      void
+        * @todo        Add something more, e.g. spreading information over DHT
         */
        protected function registerNodeByMessageData (array $messageData) {
                // Get a wrapper instance
@@ -127,8 +128,8 @@ abstract class BaseMessageHandler extends BaseHandler {
 
                // Is there already an entry?
                if ($resultInstance->next()) {
-                       // Entry found
-                       $resultInstance->debugBackTrace('Entry found!');
+                       // Entry found, so update it
+                       $wrapperInstance->updateNodeByMessageData($messageData, $this);
                } else {
                        // Nothing found, so register it
                        $wrapperInstance->registerNodeByMessageData($messageData, $this);
index e5b432e1d46da5d53a501d389695c8d43eeceaaf..33c9dc9d316953e86c5ce6a07d142355f6e04869 100644 (file)
@@ -50,6 +50,7 @@
 ./application/hub/main/filter/task/chat/class_ChatTaskHandlerInitializerFilter.php:55:  * @todo        5% done
 ./application/hub/main/filter/task/cruncher/class_CruncherTaskHandlerInitializerFilter.php:55:  * @todo        5% done
 ./application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php:55:  * @todo        Maybe some more tasks needs to be added?
+./application/hub/main/handler/message-types/class_BaseMessageHandler.php:108:  * @todo        Add something more, e.g. spreading information over DHT
 ./application/hub/main/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php:71:                  // @TODO Throw an exception here instead of dying
 ./application/hub/main/handler/network/class_BaseRawDataHandler.php:148:        * @todo        This method will be moved to a better place
 ./application/hub/main/handler/network/udp/class_UdpRawDataHandler.php:58:      * @todo        0%
 ./application/hub/main/tasks/network/class_NetworkPackageWriterTask.php:59:     * @todo        Also visit some sub-objects?
 ./application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php:10: * @todo               This template engine does not make use of setTemplateType()
 ./application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php:10: * @todo          This template engine does not make use of setTemplateType()
-./application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php:247:  * @todo        Find something useful with this!
+./application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php:257:  * @todo        Find something useful with this!
 ./application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php:10: * @todo             This template engine does not make use of setTemplateType()
 ./application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php:249:     * @todo        Find something useful with this!
 ./application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php:10: * @todo          This template engine does not make use of setTemplateType()
 ./inc/classes/main/user/class_BaseUser.php:308:         * @todo        Try to make this method more generic so we can move it in BaseFrameworkSystem
 ./inc/classes/main/user/class_BaseUser.php:80:  * @todo        Find a way of casting here. "(int)" might destroy the user id > 32766
 ./inc/classes/main/user/member/class_Member.php:84:     * @todo        Add more ways over creating user classes
-./inc/classes/middleware/debug/class_DebugMiddleware.php:112:                  // @TODO Initialization phase
+./inc/classes/middleware/debug/class_DebugMiddleware.php:113:                  // @TODO Initialization phase
 ./inc/classes.php:10: * @todo          We should minimize these includes
-./inc/config/class_FrameworkConfiguration.php:194:      * @todo        We have to add some more entries from $_SERVER here
+./inc/config/class_FrameworkConfiguration.php:212:      * @todo        We have to add some more entries from $_SERVER here
 ./inc/database.php:11: * @todo         We should minimize these includes
 ./inc/database.php:51:// @TODO Rewrite this
 ./inc/hooks.php:11: * @todo            We should minimize these includes