]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/class_BaseHubSystem.php
Merge branch 'refacuring/protocol_handler' into latest-core/crawler
[hub.git] / application / hub / main / class_BaseHubSystem.php
index 0426bd28a33b75e6b129d93db9dda0595dce27eb..885abc5d08b959e66b8611b317fd8cfba71a7e14 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
+ * @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
  *
@@ -104,6 +104,11 @@ class BaseHubSystem extends BaseFrameworkSystem {
         */
        private $assemblerInstance = NULL;
 
+       /**
+        * Info instance
+        */
+       private $infoInstance = NULL;
+
        /**
         * Name of used protocol
         */
@@ -348,6 +353,25 @@ class BaseHubSystem extends BaseFrameworkSystem {
                return $this->assemblerInstance;
        }
 
+       /**
+        * Setter for info instance
+        *
+        * @param       $infoInstance   A ShareableInfo instance
+        * @return      void
+        */
+       protected final function setInfoInstance (ShareableInfo $infoInstance) {
+               $this->infoInstance = $infoInstance;
+       }
+
+       /**
+        * Getter for info instance
+        *
+        * @return      $infoInstance   A Decodeable instance
+        */
+       public final function getInfoInstance () {
+               return $this->infoInstance;
+       }
+
        /**
         * Setter for node id
         *
@@ -480,20 +504,23 @@ class BaseHubSystem extends BaseFrameworkSystem {
         * @param       $method                         Value of __METHOD__ from calling method
         * @param       $line                           Value of __LINE__ from calling method
         * @param       $socketResource         A valid socket resource
-        * @param       $recipientData          An array with two elements: 0=IP number, 1=port number
+        * @param       $unlData                        A valid UNL data array
         * @return      void
         * @throws      InvalidSocketException  If $socketResource is no socket resource
         * @throws      NoSocketErrorDetectedException  If socket_last_error() gives zero back
         */
-       protected final function handleSocketError ($method, $line, $socketResource, array $recipientData) {
+       protected final function handleSocketError ($method, $line, $socketResource, array $unlData) {
                // This method handles only socket resources
                if (!is_resource($socketResource)) {
                        // No resource, abort here
                        throw new InvalidSocketException(array($this, $socketResource), BaseListener::EXCEPTION_INVALID_SOCKET);
                } // END - if
 
-               // Check count of array, should be two
-               assert(count($recipientData) == 2);
+               // Check UNL array
+               //* DEBUG-DIE: */ die(__METHOD__ . ':unlData=' . print_r($unlData, TRUE));
+               assert(isset($unlData[UniversalNodeLocator::UNL_PART_PROTOCOL]));
+               assert(isset($unlData[UniversalNodeLocator::UNL_PART_ADDRESS]));
+               assert(isset($unlData[UniversalNodeLocator::UNL_PART_PORT]));
 
                // Get error code for first validation (0 is not an error)
                $errorCode = socket_last_error($socketResource);
@@ -508,7 +535,7 @@ class BaseHubSystem extends BaseFrameworkSystem {
                $handlerName = $this->getSocketErrorHandlerFromCode($errorCode);
 
                // Call-back the error handler method
-               call_user_func_array(array($this, $handlerName), array($socketResource, $recipientData));
+               call_user_func_array(array($this, $handlerName), array($socketResource, $unlData));
 
                // Finally clear the error because it has been handled
                socket_clear_error($socketResource);