*
* @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
*
parent::__construct(__CLASS__);
// Set the protocol to TCP
- $this->setProtocol('tcp');
+ $this->setProtocolName('tcp');
}
/**
// Get new instance
$listenerInstance = new TcpListener();
- // Set the application instance
- $listenerInstance->setNodeInstance($nodeInstance);
-
// Return the prepared instance
return $listenerInstance;
}
$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(
$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?