From a8fa4d6c9a3710bbd8bc4ea12d06edc40b2d442f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 21 May 2017 15:50:58 +0200 Subject: [PATCH] Rewrite: - Listenable now hold StorableSocket is no longer generic, so re-imported it - updated core framework MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../hub/classes/class_BaseHubSystem.php | 2 +- .../socket/class_SocketContainer.php | 2 +- .../socket/class_PackageSocketDiscovery.php | 2 +- .../factories/client/class_ClientFactory.php | 4 +- .../factories/socket/class_SocketFactory.php | 2 +- .../hub/classes/handler/network/tcp/class_ | 2 +- .../info/connection/class_ConnectionInfo.php | 2 +- application/hub/classes/listener/class_ | 2 +- .../classes/listener/class_BaseListener.php | 24 +++++ .../socket/class_SocketFileListener.php | 2 +- .../class_SocketFileListenerDecorator.php | 2 +- application/hub/classes/listener/tcp/class_ | 2 +- .../listener/tcp/class_TcpListener.php | 2 +- .../class_ClientTcpListenerDecorator.php | 2 +- .../class_HubTcpListenerDecorator.php | 2 +- application/hub/classes/listener/udp/class_ | 2 +- .../listener/udp/class_UdpListener.php | 2 +- .../class_ClientUdpListenerDecorator.php | 2 +- .../class_HubUdpListenerDecorator.php | 2 +- application/hub/classes/pools/class_ | 2 +- .../listener/class_DefaultListenerPool.php | 2 +- .../pools/peer/class_DefaultPeerPool.php | 2 +- .../registry/socket/class_SocketRegistry.php | 2 +- .../tags/package/class_PackageTags.php | 2 +- .../class_RawDataPoolMonitorVisitor.php | 2 +- .../class_ShutdownListenerPoolVisitor.php | 2 +- .../visitor/tasks/class_ActiveTaskVisitor.php | 2 +- .../tasks/class_ShutdownTaskVisitor.php | 2 +- .../hub/interfaces/class_HubInterface.php | 15 ++++ application/hub/interfaces/listener/.htaccess | 1 + .../interfaces/listener/class_Listenable.php | 89 +++++++++++++++++++ .../pool/listener/class_PoolableListener.php | 2 +- .../socket/class_RegisterableSocket.php | 2 +- .../shareable/info/class_ShareableInfo.php | 2 +- .../hub/interfaces/tags/class_Tagable.php | 2 +- .../listener/class_ListenerPoolVisitor.php | 4 +- core | 2 +- 37 files changed, 166 insertions(+), 33 deletions(-) create mode 100644 application/hub/interfaces/listener/.htaccess create mode 100644 application/hub/interfaces/listener/class_Listenable.php diff --git a/application/hub/classes/class_BaseHubSystem.php b/application/hub/classes/class_BaseHubSystem.php index 2ffff9cd0..f4faee74d 100644 --- a/application/hub/classes/class_BaseHubSystem.php +++ b/application/hub/classes/class_BaseHubSystem.php @@ -7,12 +7,12 @@ use Hub\Handler\Protocol\HandleableProtocol; use Hub\Handler\RawData\BaseRawDataHandler; use Hub\Information\ShareableInfo; use Hub\Listener\BaseListener; +use Hub\Listener\Listenable; use Hub\Network\Deliver\Deliverable; use Hub\Network\Receive\Receivable; use Hub\Pool\Poolable; // Import framework stuff -use CoreFramework\Listener\Listenable; use CoreFramework\Object\BaseFrameworkSystem; use CoreFramework\Socket\InvalidSocketException; diff --git a/application/hub/classes/container/socket/class_SocketContainer.php b/application/hub/classes/container/socket/class_SocketContainer.php index 9197e73b1..a09071889 100644 --- a/application/hub/classes/container/socket/class_SocketContainer.php +++ b/application/hub/classes/container/socket/class_SocketContainer.php @@ -7,12 +7,12 @@ use Hub\Handler\RawData\BaseRawDataHandler; use Hub\Helper\Connection\BaseConnectionHelper; use Hub\Information\ShareableInfo; use Hub\Listener\BaseListener; +use Hub\Listener\Listenable; use Hub\Network\Package\NetworkPackage; // Import framework stuff use CoreFramework\Container\BaseContainer; use CoreFramework\Factory\ObjectFactory; -use CoreFramework\Listener\Listenable; use CoreFramework\Registry\Registerable; use CoreFramework\Socket\InvalidSocketException; use CoreFramework\Socket\NoSocketErrorDetectedException; diff --git a/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php b/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php index 22eb61829..4d13f8375 100644 --- a/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php +++ b/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php @@ -9,10 +9,10 @@ use Hub\Factory\Socket\SocketFactory; use Hub\Generic\BaseHubSystem; use Hub\Handler\Protocol\HandleableProtocol; use Hub\Helper\Connection\BaseConnectionHelper; +use Hub\Listener\Listenable; use Hub\Network\Package\NetworkPackage; // Import framework stuff -use CoreFramework\Listener\Listenable; use CoreFramework\Registry\Registerable; use CoreFramework\Registry\Registry; use CoreFramework\Socket\InvalidSocketException; diff --git a/application/hub/classes/factories/client/class_ClientFactory.php b/application/hub/classes/factories/client/class_ClientFactory.php index d5e9c457b..734a070d4 100644 --- a/application/hub/classes/factories/client/class_ClientFactory.php +++ b/application/hub/classes/factories/client/class_ClientFactory.php @@ -45,7 +45,9 @@ class ClientFactory extends ObjectFactory { /** * Creates a client object for given protocol. This method uses the - * registry pattern to cache those instances. + * registry pattern to cache those instances. Please note that on an + * existing instance, the provided socket instance is being set and + * overwrites the existing one. * * @param $protocolInstance An instance of a HandleableProtocol class to create a client object for (e.g. 'http' for a HTTP/1.1 client) * @param $socketInstance An instance of a StorableSocket class (or NULL) diff --git a/application/hub/classes/factories/socket/class_SocketFactory.php b/application/hub/classes/factories/socket/class_SocketFactory.php index 4bec13a89..8262f2ce9 100644 --- a/application/hub/classes/factories/socket/class_SocketFactory.php +++ b/application/hub/classes/factories/socket/class_SocketFactory.php @@ -5,13 +5,13 @@ namespace Hub\Factory\Socket; // Import application-specific stuff use Hub\Handler\Protocol\HandleableProtocol; use Hub\Listener\BaseListener; +use Hub\Listener\Listenable; use Hub\Network\Package\NetworkPackage; // Import framework stuff use CoreFramework\Bootstrap\FrameworkBootstrap; use CoreFramework\Configuration\FrameworkConfiguration; use CoreFramework\Factory\ObjectFactory; -use CoreFramework\Listener\Listenable; use CoreFramework\Registry\Registry; use CoreFramework\Socket\InvalidSocketException; diff --git a/application/hub/classes/handler/network/tcp/class_ b/application/hub/classes/handler/network/tcp/class_ index 27e450087..c09a61e2a 100644 --- a/application/hub/classes/handler/network/tcp/class_ +++ b/application/hub/classes/handler/network/tcp/class_ @@ -139,9 +139,9 @@ namespace Hub\Listener\; // Import application-specific stuff use Hub\Helper\Node\NodeHelper; use Hub\Listener\BaseListener; +use Hub\Listener\Listenable; // Import framework stuff -use CoreFramework\Listener\Listenable; use CoreFramework\Visitor\Visitable; getIteratorInstance()->next(); } + /** + * Setter for socket instance + * + * @param $socketInstance A StorableSocket instance + * @return void + */ + public final function setSocketInstance (StorableSocket $socketInstance) { + $this->socketInstance = $socketInstance; + } + + /** + * Getter for socket instance + * + * @return $socketInstance An instance of a StorableSocket class + */ + public final function getSocketInstance () { + return $this->socketInstance; + } + } diff --git a/application/hub/classes/listener/socket/class_SocketFileListener.php b/application/hub/classes/listener/socket/class_SocketFileListener.php index e939c9f82..823924977 100644 --- a/application/hub/classes/listener/socket/class_SocketFileListener.php +++ b/application/hub/classes/listener/socket/class_SocketFileListener.php @@ -6,11 +6,11 @@ namespace Hub\Listener\Socket; use Hub\Factory\Socket\SocketFactory; use Hub\Helper\Connection\BaseConnectionHelper; use Hub\Listener\BaseListener; +use Hub\Listener\Listenable; // Import framework stuff use CoreFramework\Bootstrap\FrameworkBootstrap; use CoreFramework\Factory\ObjectFactory; -use CoreFramework\Listener\Listenable; /** * A file-based socket listener diff --git a/application/hub/classes/listener/socket/decorator/class_SocketFileListenerDecorator.php b/application/hub/classes/listener/socket/decorator/class_SocketFileListenerDecorator.php index 8287aa9d2..eec70ec0c 100644 --- a/application/hub/classes/listener/socket/decorator/class_SocketFileListenerDecorator.php +++ b/application/hub/classes/listener/socket/decorator/class_SocketFileListenerDecorator.php @@ -4,9 +4,9 @@ namespace Hub\Listener\Socket; // Import application-specific stuff use Hub\Listener\BaseListenerDecorator; +use Hub\Listener\Listenable; // Import framework stuff -use CoreFramework\Listener\Listenable; /** * A decorator for the SocketFileListener to communicate to hubs diff --git a/application/hub/classes/listener/tcp/class_ b/application/hub/classes/listener/tcp/class_ index 2f6778016..1bca41f6f 100644 --- a/application/hub/classes/listener/tcp/class_ +++ b/application/hub/classes/listener/tcp/class_ @@ -138,9 +138,9 @@ namespace Hub\Listener\Tcp\; // Import application-specific stuff use Hub\Helper\Node\NodeHelper; use Hub\Listener\BaseListener; +use Hub\Listener\Listenable; // Import framework stuff -use CoreFramework\Listener\Listenable; use CoreFramework\Visitor\Visitable; + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 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 HubInterface { + /** + * 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 (); + +} diff --git a/application/hub/interfaces/pool/listener/class_PoolableListener.php b/application/hub/interfaces/pool/listener/class_PoolableListener.php index 114a27659..d3f1cc69f 100644 --- a/application/hub/interfaces/pool/listener/class_PoolableListener.php +++ b/application/hub/interfaces/pool/listener/class_PoolableListener.php @@ -3,10 +3,10 @@ namespace Hub\Pool\Listener; // Import application-specific stuff +use Hub\Listener\Listenable; use Hub\Pool\Poolable; // Import framework stuff -use CoreFramework\Listener\Listenable; /** * A Poolable interface for listener diff --git a/application/hub/interfaces/registry/socket/class_RegisterableSocket.php b/application/hub/interfaces/registry/socket/class_RegisterableSocket.php index d02c0dd99..9fe5d0cbb 100644 --- a/application/hub/interfaces/registry/socket/class_RegisterableSocket.php +++ b/application/hub/interfaces/registry/socket/class_RegisterableSocket.php @@ -5,9 +5,9 @@ namespace Hub\Registry\Socket; // Import application-specific stuff use Hub\Container\Socket\StorableSocket; use Hub\Information\ShareableInfo; +use Hub\Listener\Listenable; // Import framework stuff -use CoreFramework\Listener\Listenable; use CoreFramework\Registry\Registerable; /** diff --git a/application/hub/interfaces/shareable/info/class_ShareableInfo.php b/application/hub/interfaces/shareable/info/class_ShareableInfo.php index 7b1a0f51c..6aada607a 100644 --- a/application/hub/interfaces/shareable/info/class_ShareableInfo.php +++ b/application/hub/interfaces/shareable/info/class_ShareableInfo.php @@ -4,12 +4,12 @@ namespace Hub\Information; // Import application-specific stuff use Hub\Helper\Connection\ConnectionHelper; +use Hub\Listener\Listenable; // Import application-specific stuff use Hub\Generic\HubInterface; // Import framework stuff -use CoreFramework\Listener\Listenable; /** * An interface for shareable informations diff --git a/application/hub/interfaces/tags/class_Tagable.php b/application/hub/interfaces/tags/class_Tagable.php index 0a683eb52..f8e35b61b 100644 --- a/application/hub/interfaces/tags/class_Tagable.php +++ b/application/hub/interfaces/tags/class_Tagable.php @@ -4,9 +4,9 @@ namespace Hub\Tag; // Import application-specific stuff use Hub\Generic\HubInterface; +use Hub\Listener\Listenable; // Import framework stuff -use CoreFramework\Listener\Listenable; /** * An interface for tags diff --git a/application/hub/interfaces/visitor/pool/listener/class_ListenerPoolVisitor.php b/application/hub/interfaces/visitor/pool/listener/class_ListenerPoolVisitor.php index e89db8866..39af5e263 100644 --- a/application/hub/interfaces/visitor/pool/listener/class_ListenerPoolVisitor.php +++ b/application/hub/interfaces/visitor/pool/listener/class_ListenerPoolVisitor.php @@ -2,8 +2,10 @@ // Own namespace namespace Hub\Visitor\Pool\Listener; +// Import application-specific stuff +use Hub\Listener\Listenable; + // Import framework stuff -use CoreFramework\Listener\Listenable; /** * An interface for the visitor implementation for pools diff --git a/core b/core index 675124434..ca40302a3 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 6751244349667c1165f05a319f3d66d3f6781b40 +Subproject commit ca40302a326b814bbd5273a0540e18d672cf2d70 -- 2.39.5