3 * A general hub node class
5 * @author Roland Haeder <webmaster@ship-simu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.ship-simu.org
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 class BaseHubNode extends BaseHubSystem implements Updateable {
28 const NODE_TYPE_BOOT = 'boot';
29 const NODE_TYPE_MASTER = 'master';
30 const NODE_TYPE_LIST = 'list';
31 const NODE_TYPE_REGULAR = 'regular';
33 // Exception constants
34 const EXCEPTION_HUB_ALREADY_ANNOUNCED = 0xe00;
37 const OBJECT_LIST_SEPARATOR = ',';
40 * IP/port number of bootstrapping node
42 private $bootIpPort = '';
45 * Query connector instance
47 private $queryConnectorInstance = NULL;
50 * Queue connector instance
52 private $queueConnectorInstance = NULL;
55 * Whether this node is anncounced (KEEP ON false!)
58 private $hubIsAnnounced = false;
61 * Whether this hub is active (default: false)
63 private $isActive = false;
66 * Whether this node accepts announcements (default: false)
68 private $acceptAnnouncements = false;
71 * Protected constructor
73 * @param $className Name of the class
76 protected function __construct ($className) {
77 // Call parent constructor
78 parent::__construct($className);
80 // Get a crypto instance
81 $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
84 $this->setCryptoInstance($cryptoInstance);
86 // Init state which sets the state to 'init'
91 * Initializes the node's state which sets it to 'init'
95 private function initState() {
97 * Get the state factory and create the initial state, we don't need
98 * the state instance here
100 NodeStateFactory::createNodeStateInstanceByName('init', $this);
104 * Generates a random string from various data inluding UUID if PECL
105 * extension uuid is installed.
107 * @param $length Length of the random part
108 * @return $randomString Random string
109 * @todo Make this code more generic and move it to CryptoHelper or
111 protected function generateRamdomString ($length) {
112 // Get an RNG instance
113 $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
115 // Generate a pseudo-random string
116 $randomString = $rngInstance->randomString($length) . ':' . $this->getBootIpPort() . ':' . $this->getRequestInstance()->getRequestElement('mode');
118 // Add UUID for even more entropy for the hasher
119 $randomString .= $this->getCryptoInstance()->createUuid();
122 return $randomString;
126 * Generates a private key and hashes it (for speeding up things)
128 * @param $searchInstance An instance of a LocalSearchCriteria class
131 private function generatePrivateKeyAndHash (LocalSearchCriteria $searchInstance) {
132 // Generate a pseudo-random string
133 $randomString = $this->generateRandomString(255);
135 // Hash and encrypt the string so we become a node id (also documented as "hub id")
136 $this->setPrivateKey($this->getCryptoInstance()->encryptString($randomString));
137 $this->setPrivateKeyHash($this->getCryptoInstance()->hashString($this->getPrivateKey()));
139 // Get a wrapper instance
140 $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class');
142 // Register the node id with our wrapper
143 $wrapperInstance->registerPrivateKey($this, $this->getRequestInstance(), $searchInstance);
146 self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Created new private key with hash: ' . $this->getPrivateKeyHash() . '');
150 * Setter for query instance
152 * @param $connectorInstance Our new query instance
155 private final function setQueryConnectorInstance (Connectable $connectorInstance) {
156 $this->queryConnectorInstance = $connectorInstance;
160 * Getter for query instance
162 * @return $connectorInstance Our new query instance
164 public final function getQueryConnectorInstance () {
165 return $this->queryConnectorInstance;
169 * Setter for queue instance
171 * @param $connectorInstance Our new queue instance
174 private final function setQueueConnectorInstance (Connectable $connectorInstance) {
175 $this->queueConnectorInstance = $connectorInstance;
179 * Getter for queue instance
181 * @return $connectorInstance Our new queue instance
183 public final function getQueueConnectorInstance () {
184 return $this->queueConnectorInstance;
188 * Getter for boot IP/port combination
190 * @return $bootIpPort The IP/port combination of the boot node
192 protected final function getBootIpPort () {
193 return $this->bootIpPort;
197 * Checks whether the given IP address matches one of the bootstrapping nodes
199 * @param $remoteAddr IP address to checkout against our bootstrapping list
200 * @return $isFound Whether the IP is found
202 protected function ifAddressMatchesBootstrappingNodes ($remoteAddr) {
203 // By default nothing is found
206 // Run through all configured IPs
207 foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $ipPort) {
208 // Split it up in IP/port
209 $ipPortArray = explode(':', $ipPort);
212 if ($ipPortArray[0] == $remoteAddr) {
216 // Remember the port number
217 $this->bootIpPort = $ipPort;
220 self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __LINE__ . ']: IP matches remote address ' . $ipPort . '.');
222 // Stop further searching
224 } elseif ($ipPortArray[0] == $this->getConfigInstance()->getConfigEntry('node_listen_addr')) {
226 * IP matches listen address. At this point we really don't care
227 * if we can really listen on that address
231 // Remember the port number
232 $this->bootIpPort = $ipPort;
235 self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __LINE__ . ']: IP matches listen address ' . $ipPort . '.');
237 // Stop further searching
247 * Outputs the console teaser. This should only be executed on startup or
248 * full restarts. This method generates some space around the teaser.
252 public function outputConsoleTeaser () {
253 // Get the app instance (for shortening our code)
254 $app = $this->getApplicationInstance();
257 self::createDebugInstance(__CLASS__)->debugOutput(' ');
258 self::createDebugInstance(__CLASS__)->debugOutput($app->getAppName() . ' v' . $app->getAppVersion() . ' - ' . $this->getRequestInstance()->getRequestElement('mode') . ' mode active');
259 self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2012 Hub Developer Team');
260 self::createDebugInstance(__CLASS__)->debugOutput(' ');
261 self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.');
262 self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain');
263 self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.');
264 self::createDebugInstance(__CLASS__)->debugOutput(' ');
268 * Generic method to acquire a hub-id. On first run this generates a new one
269 * based on many pseudo-random data. On any later run, unless the id
270 * got not removed from database, it will be restored from the database.
272 * @param $requestInstance A Requestable class
273 * @param $responseInstance A Responseable class
276 public function bootstrapAcquireNodeId (Requestable $requestInstance, Responseable $responseInstance) {
277 // Get a wrapper instance
278 $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class');
280 // Now get a search criteria instance
281 $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
283 // Search for the node number one which is hard-coded the default
284 $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR, 1);
285 $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_TYPE, $this->getRequestInstance()->getRequestElement('mode'));
286 $searchInstance->setLimit(1);
289 $resultInstance = $wrapperInstance->doSelectByCriteria($searchInstance);
292 if ($resultInstance->next()) {
293 // Save the result instance in this class
294 $this->setResultInstance($resultInstance);
296 // Get the node id from result and set it
297 $this->setNodeId($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID));
300 self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Re-using found node-id: ' . $this->getNodeId() . '');
302 // Generate a pseudo-random string
303 $randomString = $this->generateRandomString(255);
305 // Hash and encrypt the string so we become a node id (also documented as "hub id")
306 $this->setNodeId($this->getCryptoInstance()->hashString($this->getCryptoInstance()->encryptString($randomString)));
308 // Register the node id with our wrapper
309 $wrapperInstance->registerNodeId($this, $this->getRequestInstance());
312 self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Created new node-id: ' . $this->getNodeId() . '');
317 * Generates a session id which will be sent to the other hubs and peers
321 public function bootstrapGenerateSessionId () {
322 // Now get a search criteria instance
323 $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
325 // Search for the node number one which is hard-coded the default
326 $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR, 1);
327 $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_TYPE, $this->getRequestInstance()->getRequestElement('mode'));
328 $searchInstance->setLimit(1);
330 // Get a random string
331 $randomString = $this->generateRamdomString(255);
333 // Hash and encrypt the string so we become a "node id" aka Hub-Id
334 $this->setSessionId($this->getCryptoInstance()->hashString($this->getCryptoInstance()->encryptString($randomString)));
336 // Get a wrapper instance
337 $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class');
339 // Register the node id with our wrapper
340 $wrapperInstance->registerSessionId($this, $this->getRequestInstance(), $searchInstance);
343 self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Created new session-id: ' . $this->getSessionId() . '');
345 // Change the state because the node has auired a hub id
346 $this->getStateInstance()->nodeGeneratedSessionId();
350 * Generate a private key for en-/decryption
354 public function bootstrapGeneratePrivateKey () {
355 // Get a wrapper instance
356 $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class');
358 // Now get a search criteria instance
359 $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
361 // Search for the node number one which is hard-coded the default
362 $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR, 1);
363 $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_TYPE, $this->getRequestInstance()->getRequestElement('mode'));
364 $searchInstance->setLimit(1);
367 $resultInstance = $wrapperInstance->doSelectByCriteria($searchInstance);
370 if ($resultInstance->next()) {
371 // Save the result instance in this class
372 $this->setResultInstance($resultInstance);
374 // Is the element set?
375 if (is_null($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY))) {
377 * Auto-generate the private key for e.g. out-dated database
378 * "tables". This allows a smooth update for the underlaying
381 $this->generatePrivateKeyAndHash($searchInstance);
383 // Get the node id from result and set it
384 $this->setPrivateKey(base64_decode($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY)));
385 $this->setPrivateKeyHash($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH));
388 self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Re-using found private key hash: ' . $this->getPrivateKeyHash() . '');
392 * Generate it in a private method (no confusion with 'private
393 * method access' and 'private key' here! ;-)).
395 $this->generatePrivateKeyAndHash($searchInstance);
400 * Adds hub data elements to a given dataset instance
402 * @param $criteriaInstance An instance of a storeable criteria
403 * @param $requestInstance An instance of a Requestable class
406 public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance) {
407 // Add node number and type
408 $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR, 1);
409 $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_TYPE, $requestInstance->getRequestElement('mode'));
412 $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID, $this->getNodeId());
414 // Add the session id if acquired
415 if ($this->getSessionId() != '') {
416 $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID, $this->getSessionId());
419 // Add the private key if acquired
420 if ($this->getPrivateKey() != '') {
421 $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY, base64_encode($this->getPrivateKey()));
422 $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH, $this->getPrivateKeyHash());
427 * Updates a given field with new value
429 * @param $fieldName Field to update
430 * @param $fieldValue New value to store
432 * @throws DatabaseUpdateSupportException If this class does not support database updates
433 * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem
435 public function updateDatabaseField ($fieldName, $fieldValue) {
437 $this->partialStub('Unfinished!');
440 // Get a critieria instance
441 $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
443 // Add search criteria
444 $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
445 $searchInstance->setLimit(1);
447 // Now get another criteria
448 $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class');
450 // Add criteria entry which we shall update
451 $updateInstance->addCriteria($fieldName, $fieldValue);
453 // Add the search criteria for searching for the right entry
454 $updateInstance->setSearchInstance($searchInstance);
456 // Set wrapper class name
457 $updateInstance->setWrapperConfigEntry('user_db_wrapper_class');
459 // Remember the update in database result
460 $this->getResultInstance()->add2UpdateQueue($updateInstance);
464 * Announces this hub to the upper (bootstrap or list) hubs. After this is
465 * successfully done the given task is unregistered from the handler. This
466 * might look a bit overloaded here but the announcement phase isn't a
467 * simple "Hello there" message, it may later on also contain more
468 * informations like the object list.
470 * @param $taskInstance The task instance running this announcement
472 * @throws NodeAlreadyAnnouncedException If this hub is already announced
473 * @todo Change the first if() block to check for a specific state
475 public function announceToUpperNodes (Taskable $taskInstance) {
476 // Is this hub node announced?
477 if ($this->hubIsAnnounced === true) {
478 // Already announced!
479 throw new NodeAlreadyAnnouncedException($this, self::EXCEPTION_HUB_ALREADY_ANNOUNCED);
483 self::createDebugInstance(__CLASS__)->debugOutput('HUB-Announcement: START (taskInstance=' . $taskInstance->__toString(). ')');
485 // Get a helper instance
486 $helperInstance = ObjectFactory::createObjectByConfiguredName('node_announcement_helper_class');
488 // Load the announcement descriptor
489 $helperInstance->loadDescriptorXml($this);
491 // Compile all variables
492 $helperInstance->getTemplateInstance()->compileConfigInVariables();
494 // "Publish" the descriptor by sending it to the bootstrap/list nodes
495 $helperInstance->sendPackage($this);
497 // Change the state, this should be the last line except debug output
498 $this->getStateInstance()->nodeAnnouncedToUpperHubs();
501 self::createDebugInstance(__CLASS__)->debugOutput('HUB-Announcement: FINISHED');
505 * Does a self-connect attempt on the public IP address. This should make
506 * it sure, we are reachable from outside world. For this kind of package we
507 * don't need that overload we have in the announcement phase.
509 * @param $taskInstance The task instance running this announcement
512 public function doSelfConnection (Taskable $taskInstance) {
514 self::createDebugInstance(__CLASS__)->debugOutput('HUB: Self Connection: START (taskInstance=' . $taskInstance->__toString(). ')');
516 // Get a helper instance
517 $helperInstance = ObjectFactory::createObjectByConfiguredName('node_self_connect_helper_class', array($this));
519 // Load the descriptor (XML) file
520 $helperInstance->loadDescriptorXml($this);
522 // Compile all variables
523 $helperInstance->getTemplateInstance()->compileConfigInVariables();
525 // And send the package away
526 $helperInstance->sendPackage($this);
529 self::createDebugInstance(__CLASS__)->debugOutput('HUB: Self Connection: FINISHED');
533 * Activates the hub by doing some final preparation and setting
534 * $hubIsActive to true
536 * @param $requestInstance A Requestable class
537 * @param $responseInstance A Responseable class
540 public function activateNode (Requestable $requestInstance, Responseable $responseInstance) {
541 // Checks whether a listener is still active and shuts it down if one
542 // is still listening.
543 if (($this->determineIfListenerIsActive()) && ($this->isNodeActive())) {
544 // Shutdown them down before they can hurt anything
545 $this->shutdownListenerPool();
548 // Get the controller here
549 $controllerInstance = Registry::getRegistry()->getInstance('controller');
551 // Run all filters for the hub activation
552 $controllerInstance->executeActivationFilters($requestInstance, $responseInstance);
554 // ----------------------- Last step from here ------------------------
555 // Activate the hub. This is ALWAYS the last step in this method
556 $this->getStateInstance()->nodeIsActivated();
557 // ---------------------- Last step until here ------------------------
561 * Initializes the listener pool (class)
565 public function initializeListenerPool () {
567 self::createDebugInstance(__CLASS__)->debugOutput('HUB: Initialize listener: START');
569 // Get a new pool instance
570 $this->setListenerPoolInstance(ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this)));
572 // Get an instance of the low-level listener
573 $listenerInstance = ObjectFactory::createObjectByConfiguredName('tcp_listener_class', array($this));
575 // Setup address and port
576 $listenerInstance->setListenAddressByConfiguration('node_listen_addr');
579 * All nodes can now use the same configuration entry because it can be
580 * customized in config-local.php.
582 $listenerInstance->setListenPortByConfiguration('node_tcp_listen_port');
584 // Initialize the listener
585 $listenerInstance->initListener();
587 // Get a decorator class
588 $decoratorInstance = ObjectFactory::createObjectByConfiguredName('node_tcp_listener_class', array($listenerInstance));
590 // Add this listener to the pool
591 $this->getListenerPoolInstance()->addListener($decoratorInstance);
593 // Get a decorator class
594 $decoratorInstance = ObjectFactory::createObjectByConfiguredName('client_tcp_listener_class', array($listenerInstance));
596 // Add this listener to the pool
597 $this->getListenerPoolInstance()->addListener($decoratorInstance);
599 // Get an instance of the low-level listener
600 $listenerInstance = ObjectFactory::createObjectByConfiguredName('udp_listener_class', array($this));
602 // Setup address and port
603 $listenerInstance->setListenAddressByConfiguration('node_listen_addr');
606 * All nodes can now use the same configuration entry because it can be
607 * customized in config-local.php.
609 $listenerInstance->setListenPortByConfiguration('node_udp_listen_port');
611 // Initialize the listener
612 $listenerInstance->initListener();
614 // Get a decorator class
615 $decoratorInstance = ObjectFactory::createObjectByConfiguredName('node_udp_listener_class', array($listenerInstance));
617 // Add this listener to the pool
618 $this->getListenerPoolInstance()->addListener($decoratorInstance);
620 // Get a decorator class
621 $decoratorInstance = ObjectFactory::createObjectByConfiguredName('client_udp_listener_class', array($listenerInstance));
623 // Add this listener to the pool
624 $this->getListenerPoolInstance()->addListener($decoratorInstance);
627 self::createDebugInstance(__CLASS__)->debugOutput('HUB: Initialize listener: FINISHED.');
631 * Getter for isActive attribute
633 * @return $isActive Whether the hub is active
635 public final function isNodeActive () {
636 return $this->isActive;
640 * Enables (default) or disables isActive flag
642 * @param $isActive Whether the hub is active
645 public final function enableIsActive ($isActive = true) {
646 $this->isActive = (bool) $isActive;
650 * Checks whether this node accepts announcements
652 * @return $acceptAnnouncements Whether this node accepts announcements
654 public final function isAcceptingAnnouncements () {
655 // Check it (this node must be active and not shutdown!)
656 $acceptAnnouncements = (($this->acceptAnnouncements === true) && ($this->isNodeActive()));
659 return $acceptAnnouncements;
663 * Checks whether this node has attempted to announce itself
665 * @return $hasAnnounced Whether this node has attempted to announce itself
666 * @todo Add checking if this node has been announced to the sender node
668 public function ifNodeHasAnnounced () {
670 /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE: ifNodeHasAnnounced(): state=' . $this->getStateInstance()->getStateName());
672 // Simply check the state of this node
673 $hasAnnounced = ($this->getStateInstance() instanceof NodeAnnouncedState);
676 /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE: ifNodeHasAnnounced(): hasAnnounced=' . intval($hasAnnounced));
679 return $hasAnnounced;
683 * Checks whether this node has attempted to announce itself and completed it
685 * @return $hasAnnouncementCompleted Whether this node has attempted to announce itself and completed it
686 * @todo Add checking if this node has been announced to the sender node
688 public function ifNodeHasAnnouncementCompleted () {
690 /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE: ifNodeHasAnnouncementCompleted(): state=' . $this->getStateInstance()->getStateName());
692 // Simply check the state of this node
693 $hasAnnouncementCompleted = ($this->getStateInstance() instanceof NodeAnnouncementCompletedState);
696 /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE: ifNodeHasAnnouncementCompleted(): hasAnnouncementCompleted=' . intval($hasAnnouncementCompleted));
699 return $hasAnnouncementCompleted;
703 * Enables whether this node accepts announcements
705 * @param $acceptAnnouncements Whether this node accepts announcements (default: true)
708 protected final function enableAcceptingAnnouncements ($acceptAnnouncements = true) {
709 $this->acceptAnnouncements = $acceptAnnouncements;
713 * Checks wether this node is accepting node-list requests
715 * @return $acceptsRequest Wether this node accepts node-list requests
717 public function isAcceptingNodeListRequests () {
719 * Only 'regular' nodes does not accept such requests, checking
720 * HubRegularNode is faster, but if e.g. HubRegularI2PNode will be
721 * added then the next check will be true.
723 $acceptsRequest = ((!$this instanceof HubRegularNode) && ($this->getRequestInstance()->getRequestElement('mode') != self::NODE_TYPE_REGULAR));
726 return $acceptsRequest;
730 * "Getter" for address:port combination
732 * @param $handlerInstance An instance of a Networkable class
733 * @return $addressPort A address:port combination for this node
735 public final function getAddressPort (Networkable $handlerInstance) {
736 // Construct config entry
737 $configEntry = 'node_' . $handlerInstance->getHandlerName() . '_listen_port';
740 $addressPort = $this->getConfigInstance()->detectServerAddress() . ':' . $this->getConfigInstance()->getConfigEntry($configEntry);
747 * Updates/refreshes node data (e.g. status).
750 * @todo Find more to do here
752 public function updateNodeData () {
753 // Set some dummy configuration entries, e.g. node_status
754 $this->getConfigInstance()->setConfigEntry('node_status', $this->getStateInstance()->getStateName());
758 * Handles message answer by given data array
760 * @param $messageData A valid answer message data array
761 * @param $packageInstance An instance of a Receivable class
763 * @todo Handle thrown exception
765 public function handleAnswerStatusByMessageData (array $messageData, Receivable $packageInstance) {
767 assert(!empty($messageData[BaseXmlAnswerTemplateEngine::ANSWER_STATUS]));
769 // Construct configuration entry for handling class' name
770 $classConfigEntry = strtolower($messageData[NetworkPackage::MESSAGE_ARRAY_TYPE] . '_status_' . $messageData[BaseXmlAnswerTemplateEngine::ANSWER_STATUS]) . '_handler_class';
772 // Try to get a class
773 $handlerInstance = ObjectFactory::createObjectByConfiguredName($classConfigEntry);
776 $handlerInstance->handleAnswerMessageData($messageData, $packageInstance);
780 * "Getter" for an array of all accepted object types
782 * @return $objectList Array of all accepted object types
784 public function getListFromAcceptedObjectTypes () {
785 // Get registry instance
786 $objectRegistryInstance = ObjectTypeRegistryFactory::createObjectTypeRegistryInstance();
789 $objectList = $objectRegistryInstance->getEntries(XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_NAME);