From 3bf7a368ab63fcdd3602d21f5be2467e2c23d501 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 12 Sep 2015 07:54:16 +0200 Subject: [PATCH] Moved files + added interface + generic socket file listener MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .gitattributes | 0 find-bad-php.sh => contrib/find-bad-php.sh | 0 todo-builder.sh => contrib/todo-builder.sh | 0 update_year.sh => contrib/update_year.sh | 0 inc/main/classes/listener/class_ | 62 ++++++++- inc/main/classes/listener/socket/.htaccess | 1 + .../socket/class_SocketFileListener.php | 126 ++++++++++++++++++ inc/main/interfaces/listener/.htaccess | 1 + .../interfaces/listener/class_Listenable.php | 85 ++++++++++++ 9 files changed, 270 insertions(+), 5 deletions(-) delete mode 100644 .gitattributes rename find-bad-php.sh => contrib/find-bad-php.sh (100%) rename todo-builder.sh => contrib/todo-builder.sh (100%) rename update_year.sh => contrib/update_year.sh (100%) create mode 100644 inc/main/classes/listener/socket/.htaccess create mode 100644 inc/main/classes/listener/socket/class_SocketFileListener.php create mode 100644 inc/main/interfaces/listener/.htaccess create mode 100644 inc/main/interfaces/listener/class_Listenable.php diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index e69de29b..00000000 diff --git a/find-bad-php.sh b/contrib/find-bad-php.sh similarity index 100% rename from find-bad-php.sh rename to contrib/find-bad-php.sh diff --git a/todo-builder.sh b/contrib/todo-builder.sh similarity index 100% rename from todo-builder.sh rename to contrib/todo-builder.sh diff --git a/update_year.sh b/contrib/update_year.sh similarity index 100% rename from update_year.sh rename to contrib/update_year.sh diff --git a/inc/main/classes/listener/class_ b/inc/main/classes/listener/class_ index 5d3309f5..d09db71d 100644 --- a/inc/main/classes/listener/class_ +++ b/inc/main/classes/listener/class_ @@ -35,16 +35,12 @@ class ???Listener extends BaseListener implements Listenable { /** * Creates an instance of this class * - * @param $nodeInstance A NodeHelper instance * @return $listenerInstance An instance a prepared listener class */ - public final static function create???Listener (NodeHelper $nodeInstance) { + public final static function create???Listener () { // Get new instance $listenerInstance = new ???Listener(); - // Set the application instance - $listenerInstance->setNodeInstance($nodeInstance); - // Return the prepared instance return $listenerInstance; } @@ -68,6 +64,62 @@ class ???Listener extends BaseListener implements Listenable { public function doListen() { $this->partialStub('Need to implement this method.'); } + + /** + * Checks whether the listener would accept the given package data array + * + * @param $packageData Raw package data + * @return $accepts Whether this listener does accept + */ + public function ifListenerAcceptsPackageData (array $packageData) { + $this->partialStub('Need to implement this method.') { + } + + /** + * Monitors incoming raw data from the handler and transfers it to the + * given receiver instance. + * + * @return void + */ + public function monitorIncomingRawData () { + $this->partialStub('Need to implement this method.') { + } + + /** + * Getter for listen address + * + * @return $listenAddress The address this listener should listen on + */ + public function getListenAddress () { + $this->partialStub('Need to implement this method.') { + } + + /** + * Getter for listen port + * + * @return $listenPort The port this listener should listen on + */ + public function getListenPort () { + $this->partialStub('Need to implement this method.') { + } + + /** + * Getter for connection type + * + * @return $connectionType Connection type for this listener + */ + public function getConnectionType () { + $this->partialStub('Need to implement this method.') { + } + + /** + * Getter for peer pool instance + * + * @return $poolInstance The peer pool instance we shall set + */ + public function getPoolInstance () { + $this->partialStub('Need to implement this method.') { + } } // [EOF] diff --git a/inc/main/classes/listener/socket/.htaccess b/inc/main/classes/listener/socket/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/listener/socket/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/listener/socket/class_SocketFileListener.php b/inc/main/classes/listener/socket/class_SocketFileListener.php new file mode 100644 index 00000000..2be9dff7 --- /dev/null +++ b/inc/main/classes/listener/socket/class_SocketFileListener.php @@ -0,0 +1,126 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 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 . + */ +class SocketFileListener extends BaseListener implements Listenable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $listenerInstance An instance a prepared listener class + */ + public final static function createSocketFileListener () { + // Get new instance + $listenerInstance = new SocketFileListener(); + + // Return the prepared instance + return $listenerInstance; + } + + /** + * 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.'); + } + + /** + * "Listens" for incoming network packages + * + * @return void + * @todo 0% done + */ + public function doListen() { + $this->partialStub('Need to implement this method.'); + } + + /** + * Checks whether the listener would accept the given package data array + * + * @param $packageData Raw package data + * @return $accepts Whether this listener does accept + */ + public function ifListenerAcceptsPackageData (array $packageData) { + $this->partialStub('Need to implement this method.') { + } + + /** + * Monitors incoming raw data from the handler and transfers it to the + * given receiver instance. + * + * @return void + */ + public function monitorIncomingRawData () { + $this->partialStub('Need to implement this method.') { + } + + /** + * Getter for listen address + * + * @return $listenAddress The address this listener should listen on + */ + public function getListenAddress () { + $this->partialStub('Need to implement this method.') { + } + + /** + * Getter for listen port + * + * @return $listenPort The port this listener should listen on + */ + public function getListenPort () { + $this->partialStub('Need to implement this method.') { + } + + /** + * Getter for connection type + * + * @return $connectionType Connection type for this listener + */ + public function getConnectionType () { + $this->partialStub('Need to implement this method.') { + } + + /** + * Getter for peer pool instance + * + * @return $poolInstance The peer pool instance we shall set + */ + public function getPoolInstance () { + $this->partialStub('Need to implement this method.') { + } +} + +// [EOF] +?> diff --git a/inc/main/interfaces/listener/.htaccess b/inc/main/interfaces/listener/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/listener/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/listener/class_Listenable.php b/inc/main/interfaces/listener/class_Listenable.php new file mode 100644 index 00000000..d453324e --- /dev/null +++ b/inc/main/interfaces/listener/class_Listenable.php @@ -0,0 +1,85 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 Listenable extends FrameworkInterface { + /** + * Initializes the listener by setting up the required socket server + * + * @return void + */ + function initListener(); + + /** + * "Listens" for incoming network packages + * + * @return void + */ + function doListen(); + + /** + * Checks whether the listener would accept the given package data array + * + * @param $packageData Raw package data + * @return $accepts Whether this listener does accept + */ + function ifListenerAcceptsPackageData (array $packageData); + + /** + * Monitors incoming raw data from the handler and transfers it to the + * given receiver instance. + * + * @return void + */ + function monitorIncomingRawData (); + + /** + * Getter for listen address + * + * @return $listenAddress The address this listener should listen on + */ + function getListenAddress (); + + /** + * Getter for listen port + * + * @return $listenPort The port this listener should listen on + */ + function getListenPort (); + + /** + * Getter for connection type + * + * @return $connectionType Connection type for this listener + */ + function getConnectionType (); + + /** + * Getter for peer pool instance + * + * @return $poolInstance The peer pool instance we shall set + */ + function getPoolInstance (); +} + +// [EOF] +?> -- 2.39.5