application/hub/interfaces/handler/chunks/.htaccess -text svneol=unset#text/plain
application/hub/interfaces/handler/chunks/class_HandleableChunks.php svneol=native#text/plain
application/hub/interfaces/handler/class_Handleable.php svneol=native#text/plain
+application/hub/interfaces/handler/message-types/.htaccess -text svneol=unset#text/plain
+application/hub/interfaces/handler/message-types/class_HandleableMessage.php svneol=native#text/plain
application/hub/interfaces/handler/network/.htaccess -text svneol=unset#text/plain
application/hub/interfaces/handler/network/class_Networkable.php svneol=native#text/plain
application/hub/interfaces/handler/task/.htaccess -text svneol=unset#text/plain
application/hub/main/factories/discovery/class_PackageDiscoveryFactory.php svneol=native#text/plain
application/hub/main/factories/discovery/class_SocketDiscoveryFactory.php svneol=native#text/plain
application/hub/main/factories/fragmenter/.htaccess -text
+application/hub/main/factories/handler/.htaccess -text svneol=unset#text/plain
+application/hub/main/factories/handler/class_MessageTypeHandlerFactory.php svneol=native#text/plain
application/hub/main/factories/lists/.htaccess -text svneol=unset#text/plain
application/hub/main/factories/lists/class_RecipientListFactory.php svneol=native#text/plain
application/hub/main/factories/package/.htaccess -text svneol=unset#text/plain
application/hub/main/handler/chunks/class_ChunkHandler.php svneol=native#text/plain
application/hub/main/handler/class_ svneol=native#text/plain
application/hub/main/handler/class_BaseHandler.php svneol=native#text/plain
+application/hub/main/handler/message-types/.htaccess -text svneol=unset#text/plain
+application/hub/main/handler/message-types/class_NodeMessageAnnouncementHandler.php svneol=native#text/plain
application/hub/main/handler/network/.htaccess -text svneol=unset#text/plain
application/hub/main/handler/network/class_ svneol=native#text/plain
application/hub/main/handler/network/class_BaseRawDataHandler.php svneol=native#text/plain
// CFG: PACKAGE-TAG-SELF-CONNECT-FILTER
$cfg->setConfigEntry('package_tag_self_connect_filter', 'PackageSelfConnectTagFilter');
+// CFG: MESSAGE-TYPE-ANNOUNCEMENT-HANDLER-CLASS
+$cfg->setConfigEntry('message_type_announcement_handler_class', 'NodeMessageAnnouncementHandler');
+
// CFG: NEWS-READER-CLASS
$cfg->setConfigEntry('news_reader_class', 'ConsoleNewsReader');
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * Handleable chunks interface
+ *
+ * @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 HandleableMessage extends Handleable {
+ /**
+ * Handles data array of the message
+ *
+ * @param $messageData An array with message data to handle
+ * @param $packageInstance An instance of a Receivable class
+ * @return void
+ */
+ function handleMessageData (array $messageData, Receivable $packageInstance);
+}
+
+// [EOF]
+?>
*/
function handleNewlyArrivedMessage ();
+ /**
+ * Checks whether a processed message is pending for "interpretation"
+ *
+ * @return $isPending Whether a processed message is pending
+ */
+ function isProcessedMessagePending ();
+
+ /**
+ * Handle processed messages by "interpreting" the 'message_type' element
+ *
+ * @return void
+ */
+ function handleProcessedMessage ();
+
/**
* Adds raw decoded data from the given handler instance to this receiver
*
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A factory class for message type handlers
+ *
+ * @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/>.
+ */
+class MessageTypeHandlerFactory extends ObjectFactory {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Returns a singleton message type handler instance. If an instance is
+ * found in registry, it will be returned, else a new instance is created
+ * and stored in the same registry entry.
+ *
+ * @param $messageType Message type to create an object from
+ * @return $handlerInstance A message type handler instance
+ */
+ public static final function createMessageTypeHandlerInstance ($messageType) {
+ // Do we have an instance in the registry?
+ if (Registry::getRegistry()->instanceExists('message_type_' . $messageType . '_handler')) {
+ // Then use this instance
+ $handlerInstance = Registry::getRegistry()->getInstance('message_type_' . $messageType . '_handler');
+ } else {
+ // Now prepare the tags instance
+ $handlerInstance = self::createObjectByConfiguredName('message_type_' . $messageType . '_handler_class');
+
+ // Set the instance in registry for further use
+ Registry::getRegistry()->addInstance('message_type_' . $messageType . '_handler', $handlerInstance);
+ }
+
+ // Return the instance
+ return $handlerInstance;
+ }
+}
+
+// [EOF]
+?>
/**
* Creates an instance of this class
*
- * @return $handlerInstance An instance of a !!! class
+ * @return $handlerInstance An instance of a !!! class
*/
public final static function create???Handler () {
// Get new instance
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A NodeMessageAnnouncement handler
+ *
+ * @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/>.
+ */
+class NodeMessageAnnouncementHandler extends BaseHandler implements HandleableMessage, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set handler name
+ $this->setHandlerName('message_type_announcement');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $handlerInstance An instance of a HandleableMessage class
+ */
+ public final static function createNodeMessageAnnouncementHandler () {
+ // Get new instance
+ $handlerInstance = new NodeMessageAnnouncementHandler();
+
+ // Return the prepared instance
+ return $handlerInstance;
+ }
+
+ /**
+ * Handles data array of the message
+ *
+ * @param $messageData An array with message data to handle
+ * @param $packageInstance An instance of a Receivable class
+ * @return void
+ */
+ public function handleMessageData (array $messageData, Receivable $packageInstance) {
+ }
+}
+
+// [EOF]
+?>
*/
$chainInstance->processMessage($decodedContent[self::PACKAGE_CONTENT_MESSAGE], $this);
}
+
+ /**
+ * Checks whether a processed message is pending for "interpretation"
+ *
+ * @return $isPending Whether a processed message is pending
+ */
+ public function isProcessedMessagePending () {
+ // Check it
+ $isPending = (!$this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_PROCESSED_MESSAGE));
+
+ // Return it
+ return $isPending;
+ }
+
+ /**
+ * Handle processed messages by "interpreting" the 'message_type' element
+ *
+ * @return void
+ */
+ public function handleProcessedMessage () {
+ // Get it from the stacker, it is the full array with the processed message
+ $messageArray = $this->getStackerInstance()->popNamed(self::STACKER_NAME_PROCESSED_MESSAGE);
+
+ // Create a handler instance from given message type
+ $handlerInstance = MessageTypeHandlerFactory::createMessageTypeHandlerInstance($messageArray[self::MESSAGE_ARRAY_TYPE]);
+
+ // Handle message data
+ $handlerInstance->handleMessageData($messageArray[self::MESSAGE_ARRAY_DATA], $this);
+
+ die('messageArray='.print_r($messageArray,true));
+ }
}
// [EOF]
*/
public function executeTask () {
// Do we have something to handle?
- if ($this->getPackageInstance()->isNewMessageArrived()) {
+ if ($this->getPackageInstance()->isProcessedMessagePending()) {
+ /*
+ * A previously proccessed message is waiting for being
+ * "interpreted". This is done by trying to find a configuration
+ * entry based on 'message_type' element.
+ */
+ $this->getPackageInstance()->handleProcessedMessage();
+ } elseif ($this->getPackageInstance()->isNewMessageArrived()) {
/*
* A fully "decoded" message has been received and added for being
* processed. Processing a message should not take long, so mostly