]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/handler/message-types/anouncement/class_NodeMessageAnnouncementHandler.php
Added announcement answer XML, template engine and acceptance of announcements
[hub.git] / application / hub / main / handler / message-types / anouncement / class_NodeMessageAnnouncementHandler.php
index 8b4195a954d7aef29a65b98da8930964ba32718e..adbd315549372b068e24015def4b71a4839c207c 100644 (file)
@@ -32,7 +32,7 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl
                parent::__construct(__CLASS__);
 
                // Set handler name
-               $this->setHandlerName('message_type_announcement');
+               $this->setHandlerName('message_announcement');
 
                // Init message data array
                $this->messageDataElements = array(
@@ -63,8 +63,21 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl
         * @param       $messageData            An array with message data to handle
         * @param       $packageInstance        An instance of a Receivable class
         * @return      void
+        * @throws      AnnouncementNotAcceptedException        If this node does not accept announcements
         */
        public function handleMessageData (array $messageData, Receivable $packageInstance) {
+               // Get node instance
+               $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+               // Is this node accepting announcements?
+               if (!$nodeInstance->isAcceptingAnnouncements()) {
+                       /*
+                        * This node is not accepting announcements, then someone wants to
+                        * announce his node to a non-bootstrap and non-master node.
+                        */
+                       throw new AnnouncementNotAcceptedException(array($this, $nodeInstance, $messageData), self::EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED);
+               } // END - if
+
                // Register the announcing node with this node
                $this->registerNodeByMessageData($messageData);