]> git.mxchange.org Git - hub.git/commitdiff
Added basicly finished (except TODO) handling of self-connect messages
authorRoland Häder <roland@mxchange.org>
Thu, 17 May 2012 19:16:44 +0000 (19:16 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 17 May 2012 19:16:44 +0000 (19:16 +0000)
application/hub/main/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php

index 9fdb29c3dd6e2260d4d0fe202d429baea90bbfa4..3b4c138926ffae8cc8b736eeefe459a58642cb97 100644 (file)
@@ -62,7 +62,21 @@ class NodeMessageSelfConnectHandler extends BaseMessageHandler implements Handle
         * @return      void
         */
        public function handleMessageData (array $messageData, Receivable $packageInstance) {
-               die(__METHOD__ . ':messageData=' . print_r($messageData, true));
+               // Are node id and session id the same?
+               if (($messageData[XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_NODE_ID] == $this->getNodeId()) && ($messageData[XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_SESSION_ID] == $this->getSessionId())) {
+                       // Both are equal
+                       $this->debugOutput('SELF-CONNECT: Have connected to myself, node and session id are equal!');
+
+                       // Get node instance ...
+                       $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+                       // ... and change state
+                       $nodeInstance->getStateInstance()->nodeHasSelfConnected();
+               } else {
+                       // Something really horrible happened
+                       // @TODO Throw an exception here instead of dying
+                       $this->debugInstance(__METHOD__ . ':IDs mismatch! messageData=' . print_r($messageData, true));
+               }
        }
 
        /**