]> git.mxchange.org Git - hub.git/commitdiff
Continued with refactoring:
authorRoland Haeder <roland@mxchange.org>
Thu, 29 Jan 2015 20:53:48 +0000 (21:53 +0100)
committerRoland Haeder <roland@mxchange.org>
Thu, 29 Jan 2015 20:53:48 +0000 (21:53 +0100)
- Added ShareableInfo interface
- Added ConnectionInfo class which can be filled by Listenable classes and
  ConnectionHelper classes. This fixes a bug that isSocketRegistered(),
  registerSocket() and so on, are only accepting a Listenable class and not
  the other.
- Updated 'core'
- UNFINISHED!

Signed-off-by: Roland Haeder <roland@mxchange.org>
21 files changed:
application/hub/config.php
application/hub/exceptions.php
application/hub/interfaces/shareable/.htaccess [new file with mode: 0644]
application/hub/interfaces/shareable/info/.htaccess [new file with mode: 0644]
application/hub/interfaces/shareable/info/class_ShareableInfo.php [new file with mode: 0644]
application/hub/main/factories/class_
application/hub/main/factories/info/.htaccess [new file with mode: 0644]
application/hub/main/factories/info/class_ConnectionInfoFactory.php [new file with mode: 0644]
application/hub/main/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php
application/hub/main/info/.htaccess [new file with mode: 0644]
application/hub/main/info/class_ [new file with mode: 0644]
application/hub/main/info/class_BaseInfo.php [new file with mode: 0644]
application/hub/main/info/connection/.htaccess [new file with mode: 0644]
application/hub/main/info/connection/class_ConnectionInfo.php [new file with mode: 0644]
application/hub/main/listener/class_BaseListener.php
application/hub/main/listener/tcp/class_TcpListener.php
application/hub/main/package/class_NetworkPackage.php
application/hub/main/registry/connection/class_ConnectionRegistry.php
application/hub/main/registry/socket/class_SocketRegistry.php
application/hub/main/source/urls/class_CrawlerUploadedListUrlSource.php
core

index 855dbfd3d791414b88c0ea8ab0bd3504d03728ce..f84c45302c8e3ad093613d03c37c71fcacc70eaa 100644 (file)
@@ -845,6 +845,9 @@ $cfg->setConfigEntry('node_dht_class', 'NodeDhtFacade');
 // CFG: MAX-DHT-RECIPIENTS
 $cfg->setConfigEntry('max_dht_recipients', 10);
 
+// CFG: CONNECTION-INFO-CLASS
+$cfg->setConfigEntry('connection_info_class', 'ConnectionInfo');
+
 ///////////////////////////////////////////////////////////////////////////////
 //                              Node states
 ///////////////////////////////////////////////////////////////////////////////
index 0ada1c1d2599f9c50765dcfa2f311068fd1e0b4a..226ef6ff524b8a1aba15d76f8884704ddacd8e97 100644 (file)
@@ -84,9 +84,11 @@ Backtrace:
                // Output the message
                print($message);
        } else {
-               // Invalid exception instance detected! Do *only* throw exceptions that
-               // extends our own exception 'FrameworkException' to get such nice
-               // outputs like above.
+               /*
+                * Invalid exception instance detected! Do *only* throw exceptions that
+                * extends our own exception 'FrameworkException' to get such nice
+                * outputs like above.
+                */
                print('exceptionInstance[]=' . gettype($exceptionInstance) . ' is invalid! Please inform the core developer team.');
        }
 }
@@ -120,7 +122,7 @@ function __assertHandler ($file, $line, $code) {
        );
 
        // Log assert
-       die($message);
+       die($message . PHP_EOL);
        syslog(LOG_WARNING, $message);
 
        // Throw an exception here
diff --git a/application/hub/interfaces/shareable/.htaccess b/application/hub/interfaces/shareable/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/interfaces/shareable/info/.htaccess b/application/hub/interfaces/shareable/info/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/interfaces/shareable/info/class_ShareableInfo.php b/application/hub/interfaces/shareable/info/class_ShareableInfo.php
new file mode 100644 (file)
index 0000000..89b3d24
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+/**
+ * An interface for shareable informations
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+interface ShareableInfo extends FrameworkInterface {
+       /**
+        * Fills the information class with data from a Listenable instance
+        *
+        * @param       $listenerInstanc        An instance of a Listenable class
+        * @return      void
+        */
+       function fillWithListenerInformation (Listenable $listenerInstance);
+}
+
+// [EOF]
+?>
index ee3559981d693cb3708cc446ff01a093bf121f05..467f3007c77ad019ec0ddc6022f138419a06c3e5 100644 (file)
@@ -35,23 +35,23 @@ class ???Factory extends ObjectFactory {
        /**
         * Returns a singleton (registry-based) !!! instance
         *
-        * @return      $handlerInstance        An instance of a !!! class
+        * @return      $%%%Instance    An instance of a !!! class
         */
        public static final function create???Instance () {
                // If there is no handler?
                if (Registry::getRegistry()->instanceExists('|||')) {
                        // Get handler from registry
-                       $handlerInstance = Registry::getRegistry()->getInstance('|||');
+                       $%%%Instance = Registry::getRegistry()->getInstance('|||');
                } else {
                        // Get the handler instance
-                       $handlerInstance = self::createObjectByConfiguredName('|||_class');
+                       $%%%Instance = self::createObjectByConfiguredName('|||_class');
 
                        // Add it to the registry
-                       Registry::getRegistry()->addInstance('|||', $handlerInstance);
+                       Registry::getRegistry()->addInstance('|||', $%%%Instance);
                }
 
                // Return the instance
-               return $handlerInstance;
+               return $%%%Instance;
        }
 }
 
diff --git a/application/hub/main/factories/info/.htaccess b/application/hub/main/factories/info/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/factories/info/class_ConnectionInfoFactory.php b/application/hub/main/factories/info/class_ConnectionInfoFactory.php
new file mode 100644 (file)
index 0000000..a5d049d
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+/**
+ * A factory class for ShareableInfo
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 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 ConnectionInfoFactory extends ObjectFactory {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Returns a singleton (registry-based) ShareableInfo instance
+        *
+        * @return      $infoInstance   An instance of a ShareableInfo class
+        */
+       public static final function createConnectionInfoInstance () {
+               // If there is no info?
+               if (Registry::getRegistry()->instanceExists('connection_info')) {
+                       // Get info from registry
+                       $infoInstance = Registry::getRegistry()->getInstance('connection_info');
+               } else {
+                       // Get the info instance
+                       $infoInstance = self::createObjectByConfiguredName('connection_info_class');
+
+                       // Add it to the registry
+                       Registry::getRegistry()->addInstance('connection_info', $infoInstance);
+               }
+
+               // Return the instance
+               return $infoInstance;
+       }
+}
+
+// [EOF]
+?>
index b8ab391e95fa903880ed3e0021b1d0078bceb5ae..395c5d466fa83820a1347cac77ea20b651755483 100644 (file)
@@ -31,11 +31,12 @@ class BaseIpV4ConnectionHelper extends BaseConnectionHelper {
        /**
         * Protected constructor
         *
+        * @param       $className      Name of implementing class
         * @return      void
         */
-       protected function __construct () {
+       protected function __construct ($className) {
                // Call parent constructor
-               parent::__construct(__CLASS__);
+               parent::__construct($className);
        }
 
        /**
diff --git a/application/hub/main/info/.htaccess b/application/hub/main/info/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/info/class_ b/application/hub/main/info/class_
new file mode 100644 (file)
index 0000000..58c9aa1
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * A ??? information class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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.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 ???Info extends BaseInfo implements ShareableInfo {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $infoInstance   An instance of a ShareableInfo class
+        */
+       public final static function create???Info () {
+               // Get new instance
+               $infoInstance = new ???Info();
+
+               // Return the prepared instance
+               return $infoInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/info/class_BaseInfo.php b/application/hub/main/info/class_BaseInfo.php
new file mode 100644 (file)
index 0000000..1a24194
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * A general Info class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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.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 BaseInfo 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/info/connection/.htaccess b/application/hub/main/info/connection/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/info/connection/class_ConnectionInfo.php b/application/hub/main/info/connection/class_ConnectionInfo.php
new file mode 100644 (file)
index 0000000..3ec070a
--- /dev/null
@@ -0,0 +1,86 @@
+<?php
+/**
+ * A Connection information class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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.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 ConnectionInfo extends BaseInfo implements ShareableInfo, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $infoInstance   An instance of a ShareableInfo class
+        */
+       public final static function createConnectionInfo () {
+               // Get new instance
+               $infoInstance = new ConnectionInfo();
+
+               // Return the prepared instance
+               return $infoInstance;
+       }
+
+       /**
+        * Fills the information class with data from a Listenable instance
+        *
+        * @param       $listenerInstanc        An instance of a Listenable class
+        * @return      void
+        */
+       public function fillWithListenerInformation (Listenable $listenerInstance) {
+               // Fill the generic array with several data from the listener:
+               $this->setProtocolName($listenerInstance->getProtocolName());
+               $this->setGenericArrayElement('listen', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_ADDRESS , $listenerInstance->getListenAddress());
+               $this->setGenericArrayElement('listen', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_PORT    , $listenerInstance->getListenPort());
+
+               // Set listener here
+               $this->setListenerInstance($listenerInstance);
+       }
+
+       /**
+        * Getter for address
+        *
+        * @return      $address        Address from shared information
+        */
+       public final function getAddress () {
+               // Return it from generic array
+               return $this->getGenericArrayElement('listen', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_ADDRESS);
+       }
+
+       /**
+        * Getter for port
+        *
+        * @return      $port   Port from shared information
+        */
+       public final function getPort () {
+               // Return it from generic array
+               return $this->getGenericArrayElement('listen', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_PORT);
+       }
+}
+
+// [EOF]
+?>
index b579030400e2b4ac25becf0ed16aa9e3ecbd1909..adf252d1a52236b299b8f40a3d2e66a84716906c 100644 (file)
@@ -217,8 +217,14 @@ class BaseListener extends BaseHubSystem implements Visitable {
                // Get a socket registry instance (singleton)
                $registryInstance = SocketRegistryFactory::createSocketRegistryInstance();
 
+               // Get a connection info instance
+               $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance();
+
+               // Will the info instance with listener data
+               $infoInstance->fillWithListenerInformation($this);
+
                // Register the socket
-               $registryInstance->registerSocket($this, $socketResource);
+               $registryInstance->registerSocket($infoInstance, $socketResource);
 
                // And set it here
                $this->setSocketResource($socketResource);
@@ -234,8 +240,14 @@ class BaseListener extends BaseHubSystem implements Visitable {
                // Get a socket registry instance (singleton)
                $registryInstance = SocketRegistryFactory::createSocketRegistryInstance();
 
+               // Get a connection info instance
+               $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance();
+
+               // Will the info instance with listener data
+               $infoInstance->fillWithListenerInformation($this);
+
                // Check it
-               $isRegistered = $registryInstance->isSocketRegistered($this, $socketResource);
+               $isRegistered = $registryInstance->isSocketRegistered($infoInstance, $socketResource);
 
                // Return result
                return $isRegistered;
index ed4403515feca878427a48b6451782aa98c5fde9..faacca976f7caca8e842cd22fc7d10ae7116619e 100644 (file)
@@ -289,11 +289,17 @@ class TcpListener extends BaseListener implements Listenable {
                                NetworkPackage::PACKAGE_DATA_STATUS    => NetworkPackage::PACKAGE_STATUS_FAKED
                        );
 
+                       // Get a connection info instance
+                       $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance();
+
+                       // Will the info instance with listener data
+                       $infoInstance->fillWithListenerInformation($this);
+
                        // Get a socket registry
                        $registryInstance = SocketRegistryFactory::createSocketRegistryInstance();
 
                        // Register the socket with the registry and with the faked array
-                       $registryInstance->registerSocket($this, $newSocket, $packageData);
+                       $registryInstance->registerSocket($infoInstance, $newSocket, $packageData);
                } // END - if
 
                // Do we have to rewind?
index 83ca2a85d0436c569a644d9bbbbb2feac4efa63a..4561e08e22fa0708690fb77922f3e5e22c94388a 100644 (file)
@@ -528,13 +528,19 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                // And make sure it is valid
                assert($helperInstance instanceof ConnectionHelper);
 
+               // Get connection info class
+               $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance();
+
+               // Will the info instance with connection helper data
+               $infoInstance->fillWithConnectionHelperInformation($helperInstance);
+
                // Is it not there?
-               if ((is_resource($socketResource)) && (!$registryInstance->isSocketRegistered($helperInstance, $socketResource))) {
+               if ((is_resource($socketResource)) && (!$registryInstance->isSocketRegistered($infoInstance, $socketResource))) {
                        // Debug message
                        //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Registering socket ' . $socketResource . ' ...');
 
                        // Then register it
-                       $registryInstance->registerSocket($helperInstance, $socketResource, $packageData);
+                       $registryInstance->registerSocket($infoInstance, $socketResource, $packageData);
                } elseif (!$helperInstance->getStateInstance()->isPeerStateConnected()) {
                        // Is not connected, then we cannot send
                        self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Unexpected peer state ' . $helperInstance->getStateInstance()->__toString() . ' detected.');
@@ -572,6 +578,9 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                // Get the right connection instance
                $helperInstance = SocketRegistryFactory::createSocketRegistryInstance()->getHandlerInstanceFromPackageData($packageData);
 
+               // Test helper instance
+               assert($helperInstance instanceof ConnectionHelper);
+
                // Is this connection still alive?
                if ($helperInstance->isShuttedDown()) {
                        // This connection is shutting down
index 5d663f171588e07664abb50caab2b25e1afd7ce0..e6aa06d7fd77995850db631f2ff229c20c63a49f 100644 (file)
@@ -84,12 +84,12 @@ class ConnectionRegistry extends BaseRegistry implements Register, RegisterableC
        /**
         * "Getter" to get a string respresentation of the protocol
         *
-        * @param       $connectionInstance             An instance of a ConnectionHelper class
-        * @return      $key                                    A string representation of the protocol for the registry
+        * @param       $infoInstance           An instance of a ShareableInfo class
+        * @return      $key                            A string representation of the protocol for the registry
         */
-       private function getRegistryKeyFromConnection (ConnectionHelper $connectionInstance) {
+       private function getRegistryKeyFromInfo (ShareableInfo $infoInstance) {
                // Get the key
-               $key = $connectionInstance->getProtocolName();
+               $key = $infoInstance->getProtocolName();
 
                // Return resulting key
                return $key;
@@ -98,12 +98,12 @@ class ConnectionRegistry extends BaseRegistry implements Register, RegisterableC
        /**
         * Checks whether the given protocol is registered
         *
-        * @param       $connectionInstance     An instance of a ConnectionHelper class
-        * @return      $isRegistered           Whether the protocol is registered
+        * @param       $connectionInstance             An instance of a ConnectionHelper class
+        * @return      $isRegistered                   Whether the protocol is registered
         */
        private function isConnectionRegistered (ConnectionHelper $connectionInstance) {
                // Get the key
-               $key = $this->getRegistryKeyFromConnection($connectionInstance);
+               $key = $this->getRegistryKeyFromInfo($connectionInstance);
 
                // Determine it
                $isRegistered = $this->instanceExists($key);
@@ -127,7 +127,7 @@ class ConnectionRegistry extends BaseRegistry implements Register, RegisterableC
                // First, check for the instance, there can be only once
                if ($this->isConnectionRegistered($connectionInstance)) {
                        // That one is found so "get" a registry key from it
-                       $key = $this->getRegistryKeyFromConnection($connectionInstance);
+                       $key = $this->getRegistryKeyFromInfo($connectionInstance);
 
                        // Get the registry
                        $registryInstance = $this->getInstance($key);
@@ -165,10 +165,10 @@ class ConnectionRegistry extends BaseRegistry implements Register, RegisterableC
                        $registryInstance = SubRegistry::createSubRegistry();
 
                        // Now we can create the sub-registry for this protocol
-                       $this->addInstance($this->getRegistryKeyFromConnection($connectionInstance), $registryInstance);
+                       $this->addInstance($this->getRegistryKeyFromInfo($connectionInstance), $registryInstance);
                } else {
                        // Get the sub-registry back
-                       $registryInstance = $this->getInstance($this->getRegistryKeyFromConnection($connectionInstance));
+                       $registryInstance = $this->getInstance($this->getRegistryKeyFromInfo($connectionInstance));
                }
 
                // Get a key for sub-registries
@@ -197,7 +197,7 @@ class ConnectionRegistry extends BaseRegistry implements Register, RegisterableC
                } // END - if
 
                // Now get the key from the protocol
-               $key = $this->getRegistryKeyFromConnection($connectionInstance);
+               $key = $this->getRegistryKeyFromInfo($connectionInstance);
 
                // And get the registry
                $registryInstance = $this->getInstance($key);
@@ -224,6 +224,9 @@ class ConnectionRegistry extends BaseRegistry implements Register, RegisterableC
 
                // Get all keys and check them
                foreach ($this->getInstanceRegistry() as $key => $registryInstance) {
+                       // Debug message
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',registryInstance=' . $registryInstance->__toString());
+
                        // This is always a SubRegistry instance
                        foreach ($registryInstance->getInstanceRegistry() as $subKey => $containerInstance) {
                                // Debug message
index c32b10a542f05ea97fa3c42a721abce30a13d884..737faf8c24dace19101d1936209f308684ebedae 100644 (file)
@@ -60,39 +60,28 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
         * "Getter" to get a string respresentation for a key for the sub-registry
         * in this format: class:type:port
         *
-        * @param       $connectionInstance     An instance of a Listenable class
-        * @return      $key                            A string representation of the socket for the registry
+        * @param       $infoInstance   An instance of a ShareableInfo class
+        * @return      $key                    A string representation of the socket for the registry
         */
-       private function getSubRegistryKey (Listenable $connectionInstance) {
+       private function getSubRegistryKey (ShareableInfo $infoInstance) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: connectionInstance=' . $connectionInstance->__toString() . ' - ENTERED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: infoInstance=' . $infoInstance->__toString() . ' - ENTERED!');
 
                // Default address is invalid
                $address = '*invalid*';
                $port    = 0;
 
-               // Which instance is it?
-               // @TODO Tested again base class, rewrite it to a generic interface!
-               if ($connectionInstance instanceof BaseConnectionHelper) {
-                       // Get address
-                       $address = $connectionInstance->getAddress();
-                       $port    = $connectionInstance->getConnectionPort();
-               } elseif ($connectionInstance instanceof BaseListener) {
-                       // Get listen address
-                       $address = $connectionInstance->getListenAddress();
-                       $port    = $connectionInstance->getListenPort();
-               } else {
-                       // Not supported!
-                       $this->debugBackTrace('Unsupported connectionInstance=' . $connectionInstance->__toString() . ' detected. Please fix this!');
-               }
+               // Get address and port
+               $address = $infoInstance->getAddress();
+               $port    = $infoInstance->getPort();
 
                // Debug message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: address=' . $address . ',port=' . $port);
 
                // Get connection type and port number and add both together
                $key = sprintf('%s:%s:%s:%s',
-                       $connectionInstance->__toString(),
-                       $connectionInstance->getConnectionType(),
+                       $infoInstance->__toString(),
+                       $infoInstance->getProtocolName(),
                        $address,
                        $port
                );
@@ -107,15 +96,15 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
        /**
         * "Getter" to get a string respresentation of the listener
         *
-        * @param       $listenerInstance       An instance of a Listenable class
-        * @return      $key                            A string representation of the listener for the registry
+        * @param       $infoInstance   An instance of a ShareableInfo class
+        * @return      $key                    A string representation of the listener for the registry
         */
-       private function getRegistryKeyFromListener (Listenable $listenerInstance) {
+       private function getRegistryKeyFromInfo (ShareableInfo $infoInstance) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',listenerInstance=' . $listenerInstance->__toString() . ' - ENTERED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',infoInstance=' . $infoInstance->__toString() . ' - ENTERED!');
 
                // Get the key
-               $key = $listenerInstance->getConnectionType();
+               $key = $infoInstance->getProtocolName();
 
                // Debug message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' .  $key . ' - EXIT!');
@@ -125,23 +114,23 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
        }
 
        /**
-        * Checks whether the given listener is registered
+        * Checks whether the shared connection info is registered
         *
-        * @param       $listenerInstance       An instance of a Listenable class
-        * @return      $isRegistered           Whether the listener is registered
+        * @param       $infoInstance   An instance of a ShareableInfo class
+        * @return      $isRegistered   Whether the listener is registered
         */
-       private function isListenerRegistered (Listenable $listenerInstance) {
+       private function isInfoRegistered (ShareableInfo $infoInstance) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:listener=' . $listenerInstance->getConnectionType() . ' - ENTERED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:info=' . $infoInstance->getConnectionType() . ' - ENTERED!');
 
                // Get the key
-               $key = $this->getRegistryKeyFromListener($listenerInstance);
+               $key = $this->getRegistryKeyFromInfo($infoInstance);
 
                // Determine it
                $isRegistered = $this->instanceExists($key);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:listener=' . $listenerInstance->getConnectionType() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:info=' . $infoInstance->getConnectionType() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
 
                // Return result
                return $isRegistered;
@@ -151,33 +140,33 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
         * Checks whether given socket resource is registered. If $socketResource is
         * FALSE only the instance will be checked.
         *
-        * @param       $listenerInstance       An instance of a Listenable class
+        * @param       $infoInstance           An instance of a ShareableInfo class
         * @param       $socketResource         A valid socket resource
         * @return      $isRegistered           Whether the given socket resource is registered
         */
-       public function isSocketRegistered (Listenable $listenerInstance, $socketResource) {
+       public function isSocketRegistered (ShareableInfo $infoInstance, $socketResource) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:listener=' . $listenerInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - ENTERED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:info=' . $infoInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - ENTERED!');
 
                // Default is not registered
                $isRegistered = FALSE;
 
                // First, check for the instance, there can be only once
-               if ($this->isListenerRegistered($listenerInstance)) {
+               if ($this->isInfoRegistered($infoInstance)) {
                        // That one is found so "get" a registry key from it
-                       $key = $this->getRegistryKeyFromListener($listenerInstance);
+                       $key = $this->getRegistryKeyFromInfo($infoInstance);
 
                        // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',listener=' . $listenerInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ' - Trying to get instance ...');
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',info=' . $infoInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ' - Trying to get instance ...');
 
                        // Get the registry
                        $registryInstance = $this->getInstance($key);
 
                        // "Get" a key for the socket
-                       $socketKey = $this->getSubRegistryKey($listenerInstance);
+                       $socketKey = $this->getSubRegistryKey($infoInstance);
 
                        // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',listener=' . $listenerInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...');
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',info=' . $infoInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...');
 
                        // Is it there?
                        if ($registryInstance->instanceExists($socketKey)) {
@@ -196,7 +185,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
                } // END - if
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:listener=' . $listenerInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:info=' . $infoInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
 
                // Return the result
                return $isRegistered;
@@ -205,39 +194,39 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
        /**
         * Registeres given socket for listener or throws an exception if it is already registered
         *
-        * @param       $listenerInstance       An instance of a Listenable class
+        * @param       $infoInstance           An instance of a ShareableInfo class
         * @param       $socketResource         A valid socket resource
         * @param       $packageData            Optional raw package data
         * @throws      SocketAlreadyRegisteredException        If the given socket is already registered
         * @return      void
         */
-       public function registerSocket (Listenable $listenerInstance, $socketResource, array $packageData = array()) {
+       public function registerSocket (ShareableInfo $infoInstance, $socketResource, array $packageData = array()) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:listener=' . $listenerInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - ENTERED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:info=' . $infoInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - ENTERED!');
 
                // Is the socket already registered?
-               if ($this->isSocketRegistered($listenerInstance, $socketResource)) {
+               if ($this->isSocketRegistered($infoInstance, $socketResource)) {
                        // Throw the exception
-                       throw new SocketAlreadyRegisteredException(array($listenerInstance, $socketResource), BaseListener::EXCEPTION_SOCKET_ALREADY_REGISTERED);
+                       throw new SocketAlreadyRegisteredException(array($infoInstance, $socketResource), BaseListener::EXCEPTION_SOCKET_ALREADY_REGISTERED);
                } // END - if
 
                // Does the instance exist?
-               if (!$this->isListenerRegistered($listenerInstance)) {
+               if (!$this->isInfoRegistered($infoInstance)) {
                        // No, not found so we create a sub registry (not needed to configure!)
                        $registryInstance = SubRegistry::createSubRegistry();
 
-                       // Now we can create the sub-registry for this listener
-                       $this->addInstance($this->getRegistryKeyFromListener($listenerInstance), $registryInstance);
+                       // Now we can create the sub-registry for this info
+                       $this->addInstance($this->getRegistryKeyFromInfo($infoInstance), $registryInstance);
                } else {
                        // Get the sub-registry back
-                       $registryInstance = $this->getInstance($this->getRegistryKeyFromListener($listenerInstance));
+                       $registryInstance = $this->getInstance($this->getRegistryKeyFromInfo($infoInstance));
                }
 
                // Get a key for sub-registries
-               $socketKey = $this->getSubRegistryKey($listenerInstance);
+               $socketKey = $this->getSubRegistryKey($infoInstance);
 
                // Get a socket container
-               $socketInstance = ObjectFactory::CreateObjectByConfiguredName('socket_container_class', array($socketResource, $listenerInstance, $packageData));
+               $socketInstance = ObjectFactory::CreateObjectByConfiguredName('socket_container_class', array($socketResource, $infoInstance, $packageData));
 
                // We have a sub-registry, the socket key and the socket, now we need to put all together
                /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: socketKey=' . $socketKey . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - adding socket container instance ...');
@@ -256,13 +245,13 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:listener=' . $listenerInstance->getConnectionType() . ' - ENTERED!');
 
                // The socket must be registered before we can return it
-               if (!$this->isListenerRegistered($listenerInstance)) {
+               if (!$this->isInfoRegistered($listenerInstance)) {
                        // Throw the exception
                        throw new NoSocketRegisteredException ($listenerInstance, self::SOCKET_NOT_REGISTERED);
                } // END - if
 
                // Now get the key from the listener
-               $key = $this->getRegistryKeyFromListener($listenerInstance);
+               $key = $this->getRegistryKeyFromInfo($listenerInstance);
 
                // And get the registry
                $registryInstance = $this->getInstance($key);
@@ -289,21 +278,25 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
        public function getHandlerInstanceFromPackageData (array $packageData) {
                // Init protocol instance
                $protocolInstance = NULL;
+               //* DIE-DEBUG: */ die(__METHOD__ . ':packageData=' . print_r($packageData, TRUE));
 
                // Get all keys and check them
                foreach ($this->getInstanceRegistry() as $key => $registryInstance) {
                        // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',registryInstance=' . $registryInstance->__toString());
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',registryInstance=' . $registryInstance->__toString());
 
                        // This is always a SubRegistry instance
                        foreach ($registryInstance->getInstanceRegistry() as $subKey => $containerInstance) {
                                // Debug message
-                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',subKey=' . $subKey . ',containerInstance=' . $containerInstance->__toString());
+                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',subKey=' . $subKey . ',containerInstance=' . $containerInstance->__toString());
 
                                // Is this a SocketContainer instance and is the address the same?
                                if (($containerInstance instanceof SocketContainer) && ($containerInstance->ifAddressMatches($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]))) {
                                        // Found one, so get the protocol instance and abort any further search
                                        $protocolInstance = $containerInstance->getProtocolInstance();
+
+                                       // Debug message
+                                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',subKey=' . $subKey . ',protocolInstance[]=' . gettype($protocolInstance) . ' - FOUND!');
                                        break;
                                } // END - if
                        } // END - foreach
index 395ae5685f76fa288c2b312936c041c43e7eb3d5..3fd94f31d3701b56d4baee362cc3338725810316 100644 (file)
@@ -170,6 +170,8 @@ class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, R
         * Parses the next stacked CSV by reading only one line from it. Then the
         * read line is being validated and if found good being feed to the next
         * stack. The file is removed from stack only if it has been fully parsed.
+        *
+        * @return      void
         */
        private function parseCsvEntry () {
                // Debug message
diff --git a/core b/core
index e20363d6973c8b2cb0aa25a869501d7c7a6ac755..fd8bfc0a9fdc898d7158029673b9dc42ad7fdf01 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit e20363d6973c8b2cb0aa25a869501d7c7a6ac755
+Subproject commit fd8bfc0a9fdc898d7158029673b9dc42ad7fdf01