application/hub/main/listener/.htaccess -text
application/hub/main/listener/class_ -text
application/hub/main/listener/class_BaseListener.php -text
+application/hub/main/listener/class_BaseListenerDecorator.php -text
application/hub/main/listener/tcp/.htaccess -text
application/hub/main/listener/tcp/class_TcpListener.php -text
+application/hub/main/listener/tcp/decorators/.htaccess -text
+application/hub/main/listener/tcp/decorators/class_ClientTcpListenerDecorator.php -text
+application/hub/main/listener/tcp/decorators/class_HubTcpListenerDecorator.php -text
application/hub/main/listener/udp/.htaccess -text
application/hub/main/listener/udp/class_UdpListener.php -text
+application/hub/main/listener/udp/decorators/.htaccess -text
+application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php -text
+application/hub/main/listener/udp/decorators/class_HubUdpListenerDecorator.php -text
application/hub/main/nodes/.htaccess -text
application/hub/main/nodes/boot/.htaccess -text
application/hub/main/nodes/boot/class_HubBootNode.php -text
// CFG: UDP-LISTENER-CLASS
$cfg->setConfigEntry('udp_listener_class', "UdpListener");
+// CFG: HUB-TCP-LISTENER-CLASS
+$cfg->setConfigEntry('hub_tcp_listener_class', "HubTcpListenerDecorator");
+
+// CFG: HUB-UDP-LISTENER-CLASS
+$cfg->setConfigEntry('hub_udp_listener_class', "HubUdpListenerDecorator");
+
+// CFG: CLIENT-TCP-LISTENER-CLASS
+$cfg->setConfigEntry('client_tcp_listener_class', "ClientTcpListenerDecorator");
+
+// CFG: CLIENT-UDP-LISTENER-CLASS
+$cfg->setConfigEntry('client_udp_listener_class', "ClientUdpListenerDecorator");
+
// [EOF]
?>
--- /dev/null
+<?php
+/**
+ * A decorator for the TcpListener to communicate to hubs
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 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 BaseListenerDecorator extends BaseFrameworkSystem {
+ /**
+ * Decorated listener instance
+ */
+ private $listenerInstance = null;
+
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Setter for listener instance
+ *
+ * @param $listenerInstance A Listenable instance
+ * @return void
+ */
+ protected final function setListenerInstance (Listenable $listenerInstance) {
+ $this->listenerInstance = $listenerInstance;
+ }
+
+ /**
+ * Getter for listener instance
+ *
+ * @return $listenerInstance A Listenable instance
+ */
+ protected final function getListenerInstance () {
+ return $this->listenerInstance;
+ }
+
+ /**
+ * Getter for listen address
+ *
+ * @return $listenAddress The address this listener should listen on
+ */
+ public final function getListenAddress () {
+ return $this->getListenerInstance()->getListenAddress();
+ }
+
+ /**
+ * Getter for listen port
+ *
+ * @return $listenPort The port this listener should listen on
+ */
+ public final function getListenPort () {
+ return $this->getListenerInstance()->getListenPort();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A decorator for the TcpListener to communicate to clients
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Client 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 ClientTcpListenerDecorator extends BaseListenerDecorator implements Listenable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $listenerInstance A Listener instance
+ * @return $decoratorInstance An instance a prepared listener decorator class
+ */
+ public final static function createClientTcpListenerDecorator (Listenable $listenerInstance) {
+ // Get new instance
+ $decoratorInstance = new ClientTcpListenerDecorator();
+
+ // Set the application instance
+ $decoratorInstance->setListenerInstance($listenerInstance);
+
+ // Return the prepared instance
+ return $decoratorInstance;
+ }
+
+ /**
+ * Initializes the listener by setting up the required socket server
+ *
+ * @return void
+ * @todo 0% done
+ */
+ public function initListener() {
+ $this->partialStub('Need to implement this method.');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A decorator for the TcpListener to communicate to hubs
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 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 HubTcpListenerDecorator extends BaseListenerDecorator implements Listenable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $listenerInstance A Listener instance
+ * @return $decoratorInstance An instance a prepared listener decorator class
+ */
+ public final static function createHubTcpListenerDecorator (Listenable $listenerInstance) {
+ // Get new instance
+ $decoratorInstance = new HubTcpListenerDecorator();
+
+ // Set the application instance
+ $decoratorInstance->setListenerInstance($listenerInstance);
+
+ // Return the prepared instance
+ return $decoratorInstance;
+ }
+
+ /**
+ * Initializes the listener by setting up the required socket server
+ *
+ * @return void
+ * @todo 0% done
+ */
+ public function initListener() {
+ $this->partialStub('Need to implement this method.');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A decorator for the UdpListener to communicate to clients
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Client 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 ClientUdpListenerDecorator extends BaseListenerDecorator implements Listenable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $listenerInstance A Listener instance
+ * @return $decoratorInstance An instance a prepared listener decorator class
+ */
+ public final static function createClientUdpListenerDecorator (Listenable $listenerInstance) {
+ // Get new instance
+ $decoratorInstance = new ClientUdpListenerDecorator();
+
+ // Set the application instance
+ $decoratorInstance->setListenerInstance($listenerInstance);
+
+ // Return the prepared instance
+ return $decoratorInstance;
+ }
+
+ /**
+ * Initializes the listener by setting up the required socket server
+ *
+ * @return void
+ * @todo 0% done
+ */
+ public function initListener() {
+ $this->partialStub('Need to implement this method.');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A decorator for the UdpListener to communicate to hubs
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 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 HubUdpListenerDecorator extends BaseListenerDecorator implements Listenable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $listenerInstance A Listener instance
+ * @return $decoratorInstance An instance a prepared listener decorator class
+ */
+ public final static function createHubUdpListenerDecorator (Listenable $listenerInstance) {
+ // Get new instance
+ $decoratorInstance = new HubUdpListenerDecorator();
+
+ // Set the application instance
+ $decoratorInstance->setListenerInstance($listenerInstance);
+
+ // Return the prepared instance
+ return $decoratorInstance;
+ }
+
+ /**
+ * Initializes the listener by setting up the required socket server
+ *
+ * @return void
+ * @todo 0% done
+ */
+ public function initListener() {
+ $this->partialStub('Need to implement this method.');
+ }
+}
+
+// [EOF]
+?>
// Get a new pool instance
$this->listenerPoolInstance = ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this));
- // Initialize both listeners
- foreach (array('tcp', 'udp') as $protocol) {
- // Get an instance
- $listenerInstance = ObjectFactory::createObjectByConfiguredName($protocol . '_listener_class', array($this));
+ // Get an instance of the low-level listener
+ $listenerInstance = ObjectFactory::createObjectByConfiguredName('tcp_listener_class', array($this));
- // Setup address and port
- $listenerInstance->setListenAddressByConfiguration('node_listen_addr');
- $listenerInstance->setListenPortByConfiguration('node_' . $protocol . '_listen_port');
+ // Setup address and port
+ $listenerInstance->setListenAddressByConfiguration('node_listen_addr');
+ $listenerInstance->setListenPortByConfiguration('node_tcp_listen_port');
- // Initialize the listener
- $listenerInstance->initListener();
+ // Initialize the listener
+ $listenerInstance->initListener();
- // Add this listener to the pool
- $this->listenerPoolInstance->addListener($listenerInstance);
- } // END - foreach
+ // Get a decorator class
+ $decoratorInstance = ObjectFactory::createObjectByConfiguredName('hub_tcp_listener_class', array($listenerInstance));
+
+ // Add this listener to the pool
+ $this->listenerPoolInstance->addListener($decoratorInstance);
+
+ // Get a decorator class
+ $decoratorInstance = ObjectFactory::createObjectByConfiguredName('client_tcp_listener_class', array($listenerInstance));
+
+ // Add this listener to the pool
+ $this->listenerPoolInstance->addListener($decoratorInstance);
+
+ // Get an instance of the low-level listener
+ $listenerInstance = ObjectFactory::createObjectByConfiguredName('udp_listener_class', array($this));
+
+ // Setup address and port
+ $listenerInstance->setListenAddressByConfiguration('node_listen_addr');
+ $listenerInstance->setListenPortByConfiguration('node_udp_listen_port');
+
+ // Initialize the listener
+ $listenerInstance->initListener();
+
+ // Get a decorator class
+ $decoratorInstance = ObjectFactory::createObjectByConfiguredName('hub_udp_listener_class', array($listenerInstance));
+
+ // Add this listener to the pool
+ $this->listenerPoolInstance->addListener($decoratorInstance);
+
+ // Get a decorator class
+ $decoratorInstance = ObjectFactory::createObjectByConfiguredName('client_udp_listener_class', array($listenerInstance));
+
+ // Add this listener to the pool
+ $this->listenerPoolInstance->addListener($decoratorInstance);
}
}