3 namespace Org\Shipsimu\Hub\Handler\Node\Announcement\Answer;
5 // Import application-specific stuff
6 use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseFrontend;
7 use Org\Shipsimu\Hub\Factory\Dht\DhtObjectFactory;
8 use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
9 use Org\Shipsimu\Hub\Handler\Message\HandleableMessage;
10 use Org\Shipsimu\Hub\Network\Message\DeliverableMessage;
11 use Org\Shipsimu\Hub\Network\Receive\Receivable;
12 use Org\Shipsimu\Hub\Node\BaseHubNode;
13 use Org\Shipsimu\Hub\Template\Engine\Xml\Answer\Announcement\XmlAnnouncementAnswerTemplateEngine;
15 // Import framework stuff
16 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
17 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
18 use Org\Mxchange\CoreFramework\Registry\Registerable;
21 * A AnnouncementAnswerOkay handler
23 * @author Roland Haeder <webmaster@shipsimu.org>
25 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Hub Developer Team
26 * @license GNU GPL 3.0 or any newer version
27 * @link http://www.shipsimu.org
29 * This program is free software: you can redistribute it and/or modify
30 * it under the terms of the GNU General Public License as published by
31 * the Free Software Foundation, either version 3 of the License, or
32 * (at your option) any later version.
34 * This program is distributed in the hope that it will be useful,
35 * but WITHOUT ANY WARRANTY; without even the implied warranty of
36 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 * GNU General Public License for more details.
39 * You should have received a copy of the GNU General Public License
40 * along with this program. If not, see <http://www.gnu.org/licenses/>.
42 class NodeAnnouncementAnswerOkayHandler extends BaseAnswerStatusHandler implements HandleableAnswerStatus, Registerable {
44 * Protected constructor
48 private function __construct () {
49 // Call parent constructor
50 parent::__construct(__CLASS__);
53 $this->searchData = array(
54 XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
55 XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
59 $this->setHandlerName('announcement_answer_okay');
63 * Creates an instance of this class
65 * @return $handlerInstance An instance of a HandleableMessage class
67 public final static function createNodeAnnouncementAnswerOkayHandler () {
69 $handlerInstance = new NodeAnnouncementAnswerOkayHandler();
71 // Return the prepared instance
72 return $handlerInstance;
76 * Handles given message data array
78 * @param $messageInstance An instance of a DeliverableMessage class
79 * @param $handlerInstance An instance of a Receivable class
81 * @todo Do some more here: Handle karma, et cetera?
83 public function handleAnswerMessageData (DeliverableMessage $messageInstance, Receivable $handlerInstance) {
85 * Query DHT and force update (which will throw an exception if the
88 DhtObjectFactory::createDhtInstance('node')->registerNodeByMessageInstance($messageInstance, $this, TRUE);
90 // Get handler instance
91 $handlerInstance = GenericRegistry::getRegistry()->getInstance('task_handler');
93 // Generate DHT bootstrap task
94 $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_late_bootstrap_task_class');
96 // Register it as well
97 $handlerInstance->registerTask('dht_late_bootstrap', $taskInstance);
99 // Get the node instance
100 /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-MESSAGE-HANDLER: Creating node instance ...');
101 $nodeInstance = NodeObjectFactory::createNodeInstance();
104 $nodeInstance->getStateInstance()->nodeAnnouncementSuccessful();
106 // Prepare next message
107 $this->prepareNextMessage($messageInstance, $handlerInstance);