From 7f7e5ad573215142fe99eff69051e141737291ca Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 8 Aug 2009 21:25:15 +0000 Subject: [PATCH] Network package handling added (unfinished) - Interfaces for handling of network packages (Networkable) added - Base classes and first TCP network package handler added - Prefix gos- removed from ZIP file name (package.sh) --- .gitattributes | 14 ++++++ application/hub/config.php | 3 ++ application/hub/interfaces/handler/.htaccess | 1 + .../interfaces/handler/class_Handleable.php | 28 +++++++++++ .../hub/interfaces/handler/network/.htaccess | 1 + .../handler/network/class_Networkable.php | 28 +++++++++++ application/hub/main/class_ | 17 ++++++- application/hub/main/class_Base | 2 +- application/hub/main/handler/.htaccess | 1 + application/hub/main/handler/class_ | 50 +++++++++++++++++++ .../hub/main/handler/class_BaseHandler.php | 38 ++++++++++++++ .../hub/main/handler/network/.htaccess | 1 + application/hub/main/handler/network/class_ | 50 +++++++++++++++++++ .../class_BaseNetworkPackageHandler.php | 38 ++++++++++++++ .../hub/main/handler/network/tcp/.htaccess | 1 + .../tcp/class_TcpNetworkPackageHandler.php | 50 +++++++++++++++++++ .../hub/main/handler/network/udp/.htaccess | 1 + .../udp/class_UdpNetworkPackageHandler.php | 50 +++++++++++++++++++ application/hub/main/iterator/class_ | 2 +- .../hub/main/listener/class_BaseListener.php | 24 +++++++++ .../main/listener/tcp/class_TcpListener.php | 9 +++- package.sh | 8 +-- 22 files changed, 407 insertions(+), 10 deletions(-) create mode 100644 application/hub/interfaces/handler/.htaccess create mode 100644 application/hub/interfaces/handler/class_Handleable.php create mode 100644 application/hub/interfaces/handler/network/.htaccess create mode 100644 application/hub/interfaces/handler/network/class_Networkable.php create mode 100644 application/hub/main/handler/.htaccess create mode 100644 application/hub/main/handler/class_ create mode 100644 application/hub/main/handler/class_BaseHandler.php create mode 100644 application/hub/main/handler/network/.htaccess create mode 100644 application/hub/main/handler/network/class_ create mode 100644 application/hub/main/handler/network/class_BaseNetworkPackageHandler.php create mode 100644 application/hub/main/handler/network/tcp/.htaccess create mode 100644 application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php create mode 100644 application/hub/main/handler/network/udp/.htaccess create mode 100644 application/hub/main/handler/network/udp/class_UdpNetworkPackageHandler.php diff --git a/.gitattributes b/.gitattributes index eda6bd360..338447b5d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -16,6 +16,10 @@ application/hub/init.php -text application/hub/interfaces/.htaccess -text application/hub/interfaces/connectors/.htaccess -text application/hub/interfaces/connectors/class_Connectable.php -text +application/hub/interfaces/handler/.htaccess -text +application/hub/interfaces/handler/class_Handleable.php -text +application/hub/interfaces/handler/network/.htaccess -text +application/hub/interfaces/handler/network/class_Networkable.php -text application/hub/interfaces/listener/.htaccess -text application/hub/interfaces/listener/class_Listenable.php -text application/hub/interfaces/lists/.htaccess -text @@ -97,6 +101,16 @@ application/hub/main/filter/shutdown/class_HubShutdownDeinitQueuesFilter.php -te application/hub/main/filter/shutdown/class_HubShutdownFlushNodeListFilter.php -text application/hub/main/filter/shutdown/class_HubShutdownListenerPoolFilter.php -text application/hub/main/filter/shutdown/class_HubShutdownNodeFilter.php -text +application/hub/main/handler/.htaccess -text +application/hub/main/handler/class_ -text +application/hub/main/handler/class_BaseHandler.php -text +application/hub/main/handler/network/.htaccess -text +application/hub/main/handler/network/class_ -text +application/hub/main/handler/network/class_BaseNetworkPackageHandler.php -text +application/hub/main/handler/network/tcp/.htaccess -text +application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php -text +application/hub/main/handler/network/udp/.htaccess -text +application/hub/main/handler/network/udp/class_UdpNetworkPackageHandler.php -text application/hub/main/iterator/.htaccess -text application/hub/main/iterator/class_ -text application/hub/main/iterator/class_BaseIterator.php -text diff --git a/application/hub/config.php b/application/hub/config.php index 2f9a39e84..ddf8b6fd4 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -102,6 +102,9 @@ $cfg->setConfigEntry('handler_pool_iterator_class', 'HandlerPoolIterator'); // CFG: NETWORK-LISTEN-ITERATOR-CLASS $cfg->setConfigEntry('network_listen_iterator_class', 'NetworkListenIterator'); +// CFG: NETWORK-PACKAGE-HANDLER-CLASS +$cfg->setConfigEntry('tcp_network_package_handler_class', 'TcpNetworkPackageHandler'); + // CFG: LIST-GROUP-CLASS $cfg->setConfigEntry('list_group_class', 'ListGroupList'); diff --git a/application/hub/interfaces/handler/.htaccess b/application/hub/interfaces/handler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/handler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/handler/class_Handleable.php b/application/hub/interfaces/handler/class_Handleable.php new file mode 100644 index 000000000..a143bced3 --- /dev/null +++ b/application/hub/interfaces/handler/class_Handleable.php @@ -0,0 +1,28 @@ + + * @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 . + */ +interface Handleable extends FrameworkInterface { +} + +// +?> diff --git a/application/hub/interfaces/handler/network/.htaccess b/application/hub/interfaces/handler/network/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/handler/network/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/handler/network/class_Networkable.php b/application/hub/interfaces/handler/network/class_Networkable.php new file mode 100644 index 000000000..bb4ce5028 --- /dev/null +++ b/application/hub/interfaces/handler/network/class_Networkable.php @@ -0,0 +1,28 @@ + + * @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 . + */ +interface Networkable extends Handleable { +} + +// +?> diff --git a/application/hub/main/class_ b/application/hub/main/class_ index 2afb25d1d..9f2dcb696 100644 --- a/application/hub/main/class_ +++ b/application/hub/main/class_ @@ -1,6 +1,6 @@ * @version 0.0.0 @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class ??? extends BaseHubSystem { +class ??? extends BaseFrameworkSystem { /** * Protected constructor * @@ -31,6 +31,19 @@ class ??? extends BaseHubSystem { // Call parent constructor parent::__construct(__CLASS__); } + + /** + * Creates an instance of this class + * + * @return $!!!Instance An instance of a === class + */ + public final static function create??? () { + // Get new instance + $!!!Instance = new ???(); + + // Return the prepared instance + return $!!!Instance; + } } // [EOF] diff --git a/application/hub/main/class_Base b/application/hub/main/class_Base index 6e9a679eb..d0122d615 100644 --- a/application/hub/main/class_Base +++ b/application/hub/main/class_Base @@ -1,6 +1,6 @@ * @version 0.0.0 diff --git a/application/hub/main/handler/.htaccess b/application/hub/main/handler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/handler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/handler/class_ b/application/hub/main/handler/class_ new file mode 100644 index 000000000..e8c9d36d5 --- /dev/null +++ b/application/hub/main/handler/class_ @@ -0,0 +1,50 @@ + + * @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 . + */ +class ???Handler extends BaseHandler { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a !!! class + */ + public final static function create???Handler () { + // Get new instance + $handlerInstance = new ???Handler(); + + // Return the prepared instance + return $handlerInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/handler/class_BaseHandler.php b/application/hub/main/handler/class_BaseHandler.php new file mode 100644 index 000000000..ca4023419 --- /dev/null +++ b/application/hub/main/handler/class_BaseHandler.php @@ -0,0 +1,38 @@ + + * @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 . + */ +class BaseHandler extends BaseHubSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/main/handler/network/.htaccess b/application/hub/main/handler/network/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/handler/network/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/handler/network/class_ b/application/hub/main/handler/network/class_ new file mode 100644 index 000000000..57d7a75a0 --- /dev/null +++ b/application/hub/main/handler/network/class_ @@ -0,0 +1,50 @@ + + * @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 . + */ +class ???NetworkPackageHandler extends BaseNetworkPackageHandler implements !!! { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a !!! class + */ + public final static function create???NetworkPackageHandler () { + // Get new instance + $handlerInstance = new ???NetworkPackageHandler(); + + // Return the prepared instance + return $handlerInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/handler/network/class_BaseNetworkPackageHandler.php b/application/hub/main/handler/network/class_BaseNetworkPackageHandler.php new file mode 100644 index 000000000..b9762e384 --- /dev/null +++ b/application/hub/main/handler/network/class_BaseNetworkPackageHandler.php @@ -0,0 +1,38 @@ + + * @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 . + */ +class BaseNetworkPackageHandler extends BaseHandler { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/main/handler/network/tcp/.htaccess b/application/hub/main/handler/network/tcp/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/handler/network/tcp/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php b/application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php new file mode 100644 index 000000000..805c7627b --- /dev/null +++ b/application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php @@ -0,0 +1,50 @@ + + * @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 . + */ +class TcpNetworkPackageHandler extends BaseNetworkPackageHandler implements Networkable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a !!! class + */ + public final static function createTcpNetworkPackageHandler () { + // Get new instance + $handlerInstance = new TcpNetworkPackageHandler(); + + // Return the prepared instance + return $handlerInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/handler/network/udp/.htaccess b/application/hub/main/handler/network/udp/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/handler/network/udp/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/handler/network/udp/class_UdpNetworkPackageHandler.php b/application/hub/main/handler/network/udp/class_UdpNetworkPackageHandler.php new file mode 100644 index 000000000..ce6489d7e --- /dev/null +++ b/application/hub/main/handler/network/udp/class_UdpNetworkPackageHandler.php @@ -0,0 +1,50 @@ + + * @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 . + */ +class UdpNetworkPackageHandler extends BaseNetworkPackageHandler implements Networkable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a !!! class + */ + public final static function createUdpNetworkPackageHandler () { + // Get new instance + $handlerInstance = new UdpNetworkPackageHandler(); + + // Return the prepared instance + return $handlerInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/iterator/class_ b/application/hub/main/iterator/class_ index a259cea5c..0a44b5d6e 100644 --- a/application/hub/main/iterator/class_ +++ b/application/hub/main/iterator/class_ @@ -35,7 +35,7 @@ class ???Iterator extends BaseIterator implements Iterator { /** * Creates an instance of this class * - * @return $iteratorInstance An instance a Iterator class + * @return $iteratorInstance An instance of a Iterator class */ public final static function create???Iterator () { // Get new instance diff --git a/application/hub/main/listener/class_BaseListener.php b/application/hub/main/listener/class_BaseListener.php index c53d81e91..8b28acd0c 100644 --- a/application/hub/main/listener/class_BaseListener.php +++ b/application/hub/main/listener/class_BaseListener.php @@ -55,6 +55,11 @@ class BaseListener extends BaseHubSystem implements Visitable { */ private $poolInstance = null; + /** + * A network package handler instance + */ + private $packageInstance = null; + /** * Protected constructor * @@ -200,6 +205,25 @@ class BaseListener extends BaseHubSystem implements Visitable { return $this->poolInstance; } + /** + * Setter for network package handler instance + * + * @param $packageInstance The network package handler instance we shall set + * @return void + */ + protected final function setPackageInstance (Networkable $packageInstance) { + $this->packageInstance = $packageInstance; + } + + /** + * Getter for network package handler instance + * + * @return $packageInstance The network package handler instance we shall set + */ + protected final function getPackageInstance () { + return $this->packageInstance; + } + /** * Accepts the visitor to rpocess the visit "request" * diff --git a/application/hub/main/listener/tcp/class_TcpListener.php b/application/hub/main/listener/tcp/class_TcpListener.php index d7d3de766..df8b0111d 100644 --- a/application/hub/main/listener/tcp/class_TcpListener.php +++ b/application/hub/main/listener/tcp/class_TcpListener.php @@ -143,6 +143,12 @@ class TcpListener extends BaseListener implements Listenable { $iteratorInstance->rewind(); $this->setIteratorInstance($iteratorInstance); + // Initialize the network package handler + $packageInstance = ObjectFactory::createObjectByConfiguredName('tcp_network_package_handler_class'); + + // Set it in this class + $this->setPackageInstance($packageInstance); + // Output message $this->debugOutput('LISTENER: TCP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.'); } @@ -185,11 +191,10 @@ class TcpListener extends BaseListener implements Listenable { $current = $this->getIteratorInstance()->current(); // Handle it here - $this->partialStub('current['.gettype($current).']='.$current); + $this->getPackageInstance()->processPackage($current); // Advance to next entry. This should be the last line $this->getIteratorInstance()->next(); - die("OK!\n"); } } diff --git a/package.sh b/package.sh index c7d12c053..efb233317 100755 --- a/package.sh +++ b/package.sh @@ -3,14 +3,14 @@ sh ./clear-cache.sh echo -n "$0: Packaging... " -zip -9 gos-hub_dev.zip docs/* Doxyfile *.php *.sh > /dev/null 2>&1 +zip -9 hub_dev.zip docs/* Doxyfile *.php *.sh > /dev/null 2>&1 echo -n "." -zip -9r gos-hub_dev.zip application/ db/ devel/ Doxyfile inc/ templates/ tests/ > /dev/null 2>&1 +zip -9r hub_dev.zip application/ db/ devel/ Doxyfile inc/ templates/ tests/ > /dev/null 2>&1 echo -n "." -zip -d gos-hub_dev.zip docs/warn.log db/*/*.serialized > /dev/null 2>&1 +zip -d hub_dev.zip docs/warn.log db/*/*.serialized > /dev/null 2>&1 echo ". done" echo "$0: Renaming..." -mv gos-hub_dev.zip gos-hub_dev_`date +%Y%m%d_%H%M%S`.zip +mv hub_dev.zip hub_dev_`date +%Y%m%d_%H%M%S`.zip echo "$0: All done." -- 2.39.5