]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/listener/tcp/class_TcpListener.php
Updated 'core'.
[hub.git] / application / hub / main / listener / tcp / class_TcpListener.php
index da332df8f6c1c09ab6ccf83595e59cf8b2168295..d3fbcf35c6dfb11a391de971372d47c781842f1c 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 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
  *
@@ -32,7 +32,7 @@ class TcpListener extends BaseListener implements Listenable {
                parent::__construct(__CLASS__);
 
                // Set the protocol to TCP
-               $this->setProtocol('tcp');
+               $this->setProtocolName('tcp');
        }
 
        /**
@@ -45,9 +45,6 @@ class TcpListener extends BaseListener implements Listenable {
                // Get new instance
                $listenerInstance = new TcpListener();
 
-               // Set the application instance
-               $listenerInstance->setNodeInstance($nodeInstance);
-
                // Return the prepared instance
                return $listenerInstance;
        }
@@ -238,7 +235,7 @@ class TcpListener extends BaseListener implements Listenable {
                        $newSocket = socket_accept($this->getSocketResource());
 
                        // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: newSocket=' . $newSocket . ',serverSocket=' .$this->getSocketResource());
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: newSocket=' . $newSocket . ',serverSocket=' .$this->getSocketResource());
 
                        // Array for timeout settings
                        $options  = array(
@@ -282,19 +279,27 @@ class TcpListener extends BaseListener implements Listenable {
                                $this->handleSocketError(__METHOD__, __LINE__, $newSocket, array('0.0.0.0', '0'));
                        } // END - if
 
+                       // Get node instance
+                       $nodeInstance = Registry::getRegistry()->getInstance('node');
+
                        // Create a faked package data array
                        $packageData = array(
                                NetworkPackage::PACKAGE_DATA_SENDER    => $peerName . ':0',
-                               NetworkPackage::PACKAGE_DATA_RECIPIENT => $this->getSessionId(),
-                               NetworkPackage::PACKAGE_DATA_PROTOCOL  => $this->getProtocol(),
+                               NetworkPackage::PACKAGE_DATA_RECIPIENT => $nodeInstance->getSessionId(),
                                NetworkPackage::PACKAGE_DATA_STATUS    => NetworkPackage::PACKAGE_STATUS_FAKED
                        );
 
+                       // Get a connection info instance
+                       $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($this->getProtocolName(), 'listener');
+
+                       // 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?