application/hub/interfaces/.htaccess -text
application/hub/interfaces/connectors/.htaccess -text
application/hub/interfaces/connectors/class_Connectable.php -text
+application/hub/interfaces/listener/.htaccess -text
+application/hub/interfaces/listener/class_Listenable.php -text
application/hub/interfaces/nodes/.htaccess -text
application/hub/interfaces/nodes/class_NodeHelper.php -text
application/hub/interfaces/pool/.htaccess -text
application/hub/main/listener/class_ -text
application/hub/main/listener/class_BaseListener.php -text
application/hub/main/listener/tcp/.htaccess -text
+application/hub/main/listener/tcp/class_TcpListener.php -text
application/hub/main/listener/udp/.htaccess -text
+application/hub/main/listener/udp/class_UdpListener.php -text
application/hub/main/nodes/.htaccess -text
application/hub/main/nodes/boot/.htaccess -text
application/hub/main/nodes/boot/class_HubBootNode.php -text
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for listeners
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core 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 Listenable extends FrameworkInterface {
+}
+
+//
+?>
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class BaseListener extends BaseHubSystem {
+ /**
+ * Address (IP mostly) we shall listen on
+ */
+ private $listenAddress = '0.0.0.0'; // This is the default and listens on all interfaces
+
+ /**
+ * Port we shall listen on (or wait for incoming data)
+ */
+ private $listenPort = 0; // This port MUST be changed by your application
+
+ /**
+ * Wether we are in blocking or non-blocking mode (default: non-blocking
+ */
+ private $blockingMode = false;
+
/**
* Protected constructor
*
// Call parent constructor
parent::__construct($className);
}
+
+ /**
+ * Setter for listen address
+ *
+ * @param $listenAddress The address this listener should listen on
+ * @return void
+ */
+ protected final function setListenAddress ($listenAddress) {
+ $this->listenAddress = (string) $listenAddress;
+ }
+
+ /**
+ * Getter for listen address
+ *
+ * @return $listenAddress The address this listener should listen on
+ */
+ public final function getListenAddress () {
+ return $this->listenAddress;
+ }
+
+ /**
+ * Setter for listen port
+ *
+ * @param $listenPort The port this listener should listen on
+ * @return void
+ */
+ protected final function setListenPort ($listenPort) {
+ $this->listenPort = (int) $listenPort;
+ }
+
+ /**
+ * Getter for listen port
+ *
+ * @return $listenPort The port this listener should listen on
+ */
+ public final function getListenPort () {
+ return $this->listenPort;
+ }
+
+ /**
+ * "Setter" to set listen address from configuration entry
+ *
+ * @param $configEntry The configuration entry holding our listen address
+ * @return void
+ */
+ public final function setListenAddressByConfiguration ($configEntry) {
+ $this->setListenAddress($this->getConfigInstance()->readConfig($configEntry));
+ }
+
+ /**
+ * "Setter" to set listen port from configuration entry
+ *
+ * @param $configEntry The configuration entry holding our listen port
+ * @return void
+ */
+ public final function setListenPortByConfiguration ($configEntry) {
+ $this->setListenPort($this->getConfigInstance()->readConfig($configEntry));
+ }
}
// [EOF]
--- /dev/null
+<?php
+/**
+ * A TCP connection listener
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core 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 TcpListener extends BaseListener implements Listenable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $nodeInstance A NodeHelper instance
+ * @return $listenerInstance An instance a prepared listener class
+ */
+ public final static function createTcpListener (NodeHelper $nodeInstance) {
+ // Get new instance
+ $listenerInstance = new TcpListener();
+
+ // Set the application instance
+ $listenerInstance->setNodeInstance($nodeInstance);
+
+ // Return the prepared instance
+ return $listenerInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A UDP connection listener
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core 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 UdpListener extends BaseListener implements Listenable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $nodeInstance A NodeHelper instance
+ * @return $listenerInstance An instance a prepared listener class
+ */
+ public final static function createUdpListener (NodeHelper $nodeInstance) {
+ // Get new instance
+ $listenerInstance = new UdpListener();
+
+ // Set the application instance
+ $listenerInstance->setNodeInstance($nodeInstance);
+
+ // Return the prepared instance
+ return $listenerInstance;
+ }
+}
+
+// [EOF]
+?>