$discoveryInstance->setListInstance($listInstance);
// Output debug message
- self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY: Initialized.');
+ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __LINE__ . ']: Initialized.');
// Return the prepared instance
return $discoveryInstance;
*/
// Debug output (may flood)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY: Recipient ' . $recipient[0] . ' matches own ip (' . HubTools::determineOwnExternalIp() . ' or ' . $this->getConfigInstance()->getServerAddress() . ')');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __LINE__ . ']: Recipient ' . $recipient[0] . ' matches own ip (' . HubTools::determineOwnExternalIp() . ' or ' . $this->getConfigInstance()->getServerAddress() . ')');
} else {
// Debug output (may flood)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY: Recipient ' . $recipient[0] . ' is different than own external ip (' . HubTools::determineOwnExternalIp() . ') nor internal ip (' . $this->getConfigInstance()->getServerAddress() . '), need to forward (not yet implemented)!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __LINE__ . ']: Recipient ' . $recipient[0] . ' is different than own external ip (' . HubTools::determineOwnExternalIp() . ') nor internal ip (' . $this->getConfigInstance()->getServerAddress() . '), need to forward (not yet implemented)!');
// This package is to be delivered to someone else, so add it
$this->getListInstance()->addEntry('ip_port', $decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
$discoveryInstance = new PackageSocketDiscovery();
// Output debug message
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY: Initialized.');
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: Initialized.');
// Return the prepared instance
return $discoveryInstance;
*/
public function discoverListenerInstance ($protocolName, array $packageData) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY: protocolName=' . $protocolName . ' - ENTERED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: protocolName=' . $protocolName . ' - ENTERED!');
/*
* Get the listener pool instance, we need to lookup the matching
*/
foreach ($poolInstance->getPoolEntriesInstance()->getArrayFromGroup($protocolName) as $listenerInstance) {
// Debug output
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY: protocolName=' . $protocolName . ',listenerInstance=' . $listenerInstance->__toString());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: protocolName=' . $protocolName . ',listenerInstance=' . $listenerInstance->__toString());
// Does the listener want that package?
if ($listenerInstance->ifListenerAcceptsPackageData($packageData)) {
// This listener likes our package data, so abort here
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY: Listener is accepting package data.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: Listener is accepting package data.');
break;
} // END - if
// Debug output
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY: Listener is NOT accepting package data.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: Listener is NOT accepting package data.');
} // END - foreach
// Return it
// Try to create a new socket resource
try {
// Possibly noisy debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY: Trying to establish a ' . strtoupper($protocolName) . ' connection to ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: Trying to establish a ' . strtoupper($protocolName) . ' connection to ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' ...');
// Get a socket resource from our factory (if succeeded)
$socketResource = SocketFactory::createSocketFromPackageData($packageData, $protocolName);
} catch (SocketConnectionException $e) {
// The connection fails of being established, so log it away
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY: Caught ' . $e->__toString() . ',message=' . $e->getMessage());
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: Caught ' . $e->__toString() . ',message=' . $e->getMessage());
}
} // END - if
$helperInstance = Registry::getRegistry()->getInstance('connection');
// Possibly noisy debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY: Going to resolve socket from peer state and given package data ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: Going to resolve socket from peer state and given package data ...');
// Resolve the peer's state (but ignore return value)
PeerStateResolver::resolveStateByPackage($helperInstance, $packageData, $socketResource);
} catch (InvalidSocketException $e) {
// This cannot be fixed, so log it away
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY: Cannot discover socket resource for recipient ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ': ' . $e->getMessage());
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: Cannot discover socket resource for recipient ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ': ' . $e->getMessage());
// Make any failed attempts to 'false'
$socketResource = false;
}
// And return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY: socketResource=' . $socketResource . ',packageData=' . print_r($packageData, true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: socketResource=' . $socketResource . ',packageData=' . print_r($packageData, true));
return $socketResource;
}
}
$registryKey = 'socket_' . $protocolName . '_' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT];
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY: Trying to find a socket with registryKey=' . $registryKey);
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __LINE__ . ']: Trying to find a socket with registryKey=' . $registryKey);
// Is the key there?
if (Registry::getRegistry()->instanceExists($registryKey)) {
$socketResource = $containerInstance->getSocketResource();
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY: Using socket ' . $socketResource . '(' . gettype($socketResource) . ') from registry.');
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __LINE__ . ']: Using socket ' . $socketResource . '(' . gettype($socketResource) . ') from registry.');
} else {
// Construct configuration entry for object factory and get it
$className = FrameworkConfiguration::getSelfInstance()->getConfigEntry($protocolName . '_connection_helper_class');
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY: Going to use class ' . $className . ' for creating a socket resource ...');
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __LINE__ . ']: Going to use class ' . $className . ' for creating a socket resource ...');
// And call the static method
$socketResource = call_user_func($className . '::createConnectionFromPackageData', $packageData);
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY: Created socket ' . $socketResource . '(' . gettype($socketResource) . ') from class ' . $className . '.');
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __LINE__ . ']: Created socket ' . $socketResource . '(' . gettype($socketResource) . ') from class ' . $className . '.');
// Construct container class, this won't be reached if an exception is thrown
$containerInstance = self::CreateObjectByConfiguredName('socket_container_class', array($socketResource, NULL, $packageData));
Registry::getRegistry()->addInstance($registryKey, $containerInstance);
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY: Socket is now registered in registry.');
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __LINE__ . ']: Socket is now registered in registry.');
}
// Return the resource
$chunkHash = $this->getCryptoInstance()->hashString($chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA], $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH], false);
// Debug output
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER: chunkHash=' . $chunkHash . ',chunkSplits[chunk_hash]=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH] . ',chunkSplits[serial]=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ',chunkSplits[raw_data]=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __LINE__ . ']: chunkHash=' . $chunkHash . ',chunkSplits[chunk_hash]=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH] . ',chunkSplits[serial]=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ',chunkSplits[raw_data]=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA]);
// Check it
$isValid = ($chunkSplits[self::CHUNK_SPLITS_INDEX_HASH] === $chunkHash);
} // END - if
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER: serialNumber=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ',hash=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __LINE__ . ']: serialNumber=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ',hash=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH]);
// Add the chunk data (index 2) to the final array and use the serial number as index
$this->finalPackageChunks['content'][$chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL]] = $chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA];
$nextSerial = $this->getFragmenterInstance()->getNextHexSerialNumber();
// Debug output
- //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER: serialNumber=' . $serialNumber . ',nextSerial=' . $nextSerial);
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __LINE__ . ']: serialNumber=' . $serialNumber . ',nextSerial=' . $nextSerial);
// Is it not the same? Then re-request it
if ($serialNumber != $nextSerial) {
// That went well, so start assembling all chunks
foreach ($this->finalPackageChunks['content'] as $serialNumber => $content) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER: serialNumber=' . $serialNumber . ' - validating ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __LINE__ . ']: serialNumber=' . $serialNumber . ' - validating ...');
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('finalPackageChunks=' . print_r($this->finalPackageChunks,true) . 'chunkHashes=' . print_r($this->chunkHashes,true));
// Is this chunk valid? This should be the case
} // END - foreach
// Debug output
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER: eopChunk[1]=' . $this->eopChunk[1] . ',' . chr(10) . 'index=' . (count($this->chunkHashes) - 2) . ',' . chr(10) . 'chunkHashes='.print_r($this->chunkHashes,true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __LINE__ . ']: eopChunk[1]=' . $this->eopChunk[1] . ',' . chr(10) . 'index=' . (count($this->chunkHashes) - 2) . ',' . chr(10) . 'chunkHashes='.print_r($this->chunkHashes,true));
// The last chunk hash must match with the one from eopChunk[1]
assert($this->eopChunk[1] == $this->chunkHashes[count($this->chunkHashes) - 2]);
// Is the generated hash from data same ("valid") as given hash?
if (!$this->isChunkHashValid($chunkSplits)) {
// Do some logging
- self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER: Chunk content is not validating against given hash.');
+ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __LINE__ . ']: Chunk content is not validating against given hash.');
// Re-request this chunk (trust the hash in index # 0)
$this->rerequestChunkBySplitsArray($chunkSplits);
// Is the serial number valid (chars 0-9, length equals PackageFragmenter::MAX_SERIAL_LENGTH)?
if (!$this->isSerialNumberValid($chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL])) {
// Do some logging
- self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER: Chunk serial number ' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ' for hash ' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH] . ' is invalid.');
+ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __LINE__ . ']: Chunk serial number ' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ' for hash ' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH] . ' is invalid.');
// Re-request this chunk
$this->rerequestChunkBySplitsArray($chunkSplits);
break;
default: // Invalid step found
- self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER: Invalid step ' . $this->finalPackageChunks['assemble_steps'] . ' detected.');
+ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __LINE__ . ']: Invalid step ' . $this->finalPackageChunks['assemble_steps'] . ' detected.');
break;
} // END - switch
}
*/
protected function initMessageConfigurationData (array $messageData) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER: messageData=' . print_r($messageData, true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER[' . __LINE__ . ']: messageData=' . print_r($messageData, true));
// "Walk" throught the translation array
foreach ($this->messageToConfig as $messageKey => $configKey) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER[' . __LINE__ . ']: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]);
// Set the element in configuration
$this->getConfigInstance()->setConfigEntry($configKey, $messageData[$messageKey]);
// "Walk" throught the config-copy array
foreach ($this->configCopy as $targetKey => $sourceKey) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER[' . __LINE__ . ']: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
// Copy from source to targetKey
$this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey));
parent::addArrayToDataSet($dataSetInstance, $messageData);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANSWER-HANDLER: messageData=' . print_r($messageData, true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANSWER-HANDLER[' . __LINE__ . ']: messageData=' . print_r($messageData, true));
// Add all ements
foreach ($this->messageDataElements as $key) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANSWER-HANDLER: messageData[' . $key . ']=' . $messageData[$key]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANSWER-HANDLER[' . __LINE__ . ']: messageData[' . $key . ']=' . $messageData[$key]);
// Is it there?
assert(isset($messageData[$key]));
*/
protected function initMessageConfigurationData (array $messageData) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(' REQUEST-HANDLER: messageData=' . print_r($messageData, true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(' REQUEST-HANDLER[' . __LINE__ . ']: messageData=' . print_r($messageData, true));
// "Walk" throught the config-copy array
foreach ($this->configCopy as $targetKey => $sourceKey) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __LINE__ . ']: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
// Copy from source to targetKey
$this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey));
$this->setErrorCode(self::SOCKET_ERROR_UNHANDLED);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER: Handling TCP package from resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $socketArray[BasePool::SOCKET_ARRAY_CONN_TYPE] . ',last error=' . socket_strerror(socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE])));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: Handling TCP package from resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $socketArray[BasePool::SOCKET_ARRAY_CONN_TYPE] . ',last error=' . socket_strerror(socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE])));
/*
* Read the raw data from socket. If you change PHP_BINARY_READ to
$rawData = socket_read($socketArray[BasePool::SOCKET_ARRAY_RESOURCE], $this->getConfigInstance()->getConfigEntry('tcp_buffer_length'), PHP_BINARY_READ);
// Debug output of read data length
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER: rawData[' . gettype($rawData) . ']=' . strlen($rawData) . ',MD5=' . md5($rawData) . ',resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',error=' . socket_strerror(socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE])));
- //* NOISY-DEBUG: */ if ($rawData !== false) self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER: rawData=' . $rawData);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: rawData[' . gettype($rawData) . ']=' . strlen($rawData) . ',MD5=' . md5($rawData) . ',resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',error=' . socket_strerror(socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE])));
+ //* NOISY-DEBUG: */ if ($rawData !== false) self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: rawData=' . $rawData);
// Is it valid?
if (socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]) == 11) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER: Ignoring error 11 (Resource temporary unavailable) from socket resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: Ignoring error 11 (Resource temporary unavailable) from socket resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE]);
/*
* Error code 11 (Resource temporary unavailable) can be safely
$handlerInstance = new TaskHandler();
// Output debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER: Initializing task handler.');
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Initializing task handler.');
// Init the task list
$handlerInstance->setListInstance(ObjectFactory::createObjectByConfiguredName('task_list_class'));
$handlerInstance->registerTask('idle_loop', $taskInstance);
// Output debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER: Task handler initialized.');
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Task handler initialized.');
// Return the prepared instance
return $handlerInstance;
$updateTask = true;
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER: Task ' . $currentTask['id'] . ' started with startup_delay=' . $currentTask['task_startup_delay'] . 'ms');
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Task ' . $currentTask['id'] . ' started with startup_delay=' . $currentTask['task_startup_delay'] . 'ms');
} // END - if
// Get time difference from interval delay
*/
private function unregisterTask (array $taskData) {
// Debug output
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER: Removing task ' . $taskData['id'] . ' from queue - START');
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Removing task ' . $taskData['id'] . ' from queue - START');
// Remove the entry
$this->getListInstance()->removeEntry('tasks', $taskData);
// Debug output
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER: Removing task ' . $taskData['id'] . ' from queue - FINISHED');
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Removing task ' . $taskData['id'] . ' from queue - FINISHED');
}
/**
$this->getListInstance()->addEntry('tasks', $taskEntry);
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER: Task registered: taskName=' . $taskName .
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Task registered: taskName=' . $taskName .
' (taskInstance=' . $taskInstance->__toString() . ')' .
', startupDelay=' . $taskEntry['task_startup_delay'] . 'ms' .
', intervalDelay=' . $taskEntry['task_interval_delay'] . 'ms' .
$this->getListInstance()->getIterator()->rewind();
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER: Shutting down all ' . $this->getListInstance()->count() . ' tasks...');
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Shutting down all ' . $this->getListInstance()->count() . ' tasks...');
// Remember all tasks that has been shutdown for removal
$tasks = array();
$currentTask = $this->getListInstance()->getIterator()->current();
// Output debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER: Shutting down task ' . $currentTask['id'] . ' (taskInstance=' . $currentTask['task_instance']->__toString() . ') ...');
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Shutting down task ' . $currentTask['id'] . ' (taskInstance=' . $currentTask['task_instance']->__toString() . ') ...');
// Shutdown the task
$currentTask['task_instance']->accept($this->getVisitorInstance());
} // END - while
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER: Shutdown of all tasks completed.');
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Shutdown of all tasks completed.');
// Remove all tasks
foreach ($tasks as $entry) {
$timeout = $this->getConfigInstance()->getConfigEntry('socket_timeout_seconds');
// Debug output
- self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: Trying to connect to ' . $recipientData[0] . ':' . $recipientData[1] . ' with socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' ...');
+ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: Trying to connect to ' . $recipientData[0] . ':' . $recipientData[1] . ' with socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' ...');
// Try to connect until it is connected
while ($isConnected = !@socket_connect($socketResource, $recipientData[0], $recipientData[1])) {
} // END - if
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: currentFinalHash=' . $this->currentFinalHash);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: currentFinalHash=' . $this->currentFinalHash);
// Get the next raw data chunk from the fragmenter
$rawDataChunk = $this->getFragmenterInstance()->getNextRawDataChunk($this->currentFinalHash);
$chunkData = array_values($rawDataChunk);
// Is the required data there?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: chunkHashes[]=' . count($chunkHashes) . ',chunkData[]=' . count($chunkData));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: chunkHashes[]=' . count($chunkHashes) . ',chunkData[]=' . count($chunkData));
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('chunkData='.print_r($chunkData,true));
if ((isset($chunkHashes[0])) && (isset($chunkData[0]))) {
// Remember this chunk as queued
$this->queuedChunks[$chunkHashes[0]] = $chunkData[0];
// Return the raw data
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: Returning ' . strlen($chunkData[0]) . ' bytes from ' . __METHOD__ . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: Returning ' . strlen($chunkData[0]) . ' bytes from ' . __METHOD__ . ' ...');
return $chunkData[0];
} else {
// Return zero string
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: Returning zero bytes from ' . __METHOD__ . '!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: Returning zero bytes from ' . __METHOD__ . '!');
return '';
}
}
while (strlen($dataStream) > 0) {
// Convert the package data array to a raw data stream
$dataStream = $this->getRawDataFromPackageArray($packageData);
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: Adding ' . strlen($dataStream) . ' bytes to the sending buffer ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: Adding ' . strlen($dataStream) . ' bytes to the sending buffer ...');
$rawData .= $dataStream;
} // END - while
$encodedData = $this->getOutputStreamInstance()->streamData($rawData);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: rawData()=' . strlen($rawData) . ',encodedData()=' . strlen($encodedData));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: rawData()=' . strlen($rawData) . ',encodedData()=' . strlen($encodedData));
// Calculate difference
$this->diff = $bufferSize - strlen($encodedData);
// Deliver all data
while ($sentBytes !== false) {
// And deliver it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: Sending out ' . strlen($encodedData) . ' bytes,bufferSize=' . $bufferSize . ',diff=' . $this->diff);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: Sending out ' . strlen($encodedData) . ' bytes,bufferSize=' . $bufferSize . ',diff=' . $this->diff);
if ($this->diff >= 0) {
// Send all out (encodedData is smaller than or equal buffer size)
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: MD5=' . md5(substr($encodedData, 0, ($bufferSize - $this->diff))));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: MD5=' . md5(substr($encodedData, 0, ($bufferSize - $this->diff))));
$sentBytes = socket_write($socketResource, $encodedData, ($bufferSize - $this->diff));
} else {
// Send buffer size out
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: MD5=' . md5(substr($encodedData, 0, $bufferSize)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: MD5=' . md5(substr($encodedData, 0, $bufferSize)));
$sentBytes = socket_write($socketResource, $encodedData, $bufferSize);
}
throw new InvalidSocketException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
} elseif (($sentBytes == 0) && (strlen($encodedData) > 0)) {
// Nothing sent means we are done
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: All sent! (LINE=' . __LINE__ . ')');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: All sent! (LINE=' . __LINE__ . ')');
break;
}
$totalSentBytes += $sentBytes;
// Cut out the last unsent bytes
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: Sent out ' . $sentBytes . ' of ' . strlen($encodedData) . ' bytes ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: Sent out ' . $sentBytes . ' of ' . strlen($encodedData) . ' bytes ...');
$encodedData = substr($encodedData, $sentBytes);
// Calculate difference again
// Can we abort?
if (strlen($encodedData) <= 0) {
// Abort here, all sent!
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: All sent! (LINE=' . __LINE__ . ')');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: All sent! (LINE=' . __LINE__ . ')');
break;
} // END - if
} // END - while
// Return sent bytes
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: totalSentBytes=' . $totalSentBytes . ',diff=' . $this->diff);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: totalSentBytes=' . $totalSentBytes . ',diff=' . $this->diff);
return $totalSentBytes;
}
* @return void
*/
protected final function markConnectionShuttedDown () {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: ' . $this->__toString() . ' has been marked as shutted down');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: ' . $this->__toString() . ' has been marked as shutted down');
$this->shuttedDown = true;
// And remove the (now invalid) socket
* @return $shuttedDown Whether this connection is shutted down
*/
public final function isShuttedDown () {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: ' . $this->__toString() . ',shuttedDown=' . intval($this->shuttedDown));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: ' . $this->__toString() . ',shuttedDown=' . intval($this->shuttedDown));
return $this->shuttedDown;
}
* @return void
*/
protected function socketErrorOperationInProgressHandler ($socketResource, array $recipientData) {
- self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: Operation is now in progress, this is usual for non-blocking connections and is no bug.');
+ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: Operation is now in progress, this is usual for non-blocking connections and is no bug.');
}
}
$recipientData = explode(':', HubTools::resolveSessionId($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
} catch (NoValidHostnameException $e) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER: Failed to resolve ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ':' . $e->getMessage());
+ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: Failed to resolve ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ':' . $e->getMessage());
// Is the recipient equal as configured IP
if (substr($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], 0, strlen($helperInstance->getConfigInstance()->getConfigEntry('external_ip'))) == $helperInstance->getConfigInstance()->getConfigEntry('external_ip')) {
*/
public function doShutdown () {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Shutting down socket resource ' . $this->getSocketResource());
+ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __LINE__ . ']: Shutting down socket resource ' . $this->getSocketResource());
// Clear any previous errors
socket_clear_error($this->getSocketResource());
*/
public function loadDescriptorXml () {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Starting with DHT boostrap ...');
+ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __LINE__ . ']: Starting with DHT boostrap ...');
// Get a XML template instance
$templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('dht_bootstrap_template_class');
*/
public function loadDescriptorXml (NodeHelper $nodeInstance) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Starting with announcement to upper hubs...');
+ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __LINE__ . ']: Starting with announcement to upper hubs...');
// Get a XML template instance
$templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_announcement_template_class');
*/
public function loadDescriptorXml (NodeHelper $nodeInstance) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Attempting to answer an announcement...');
+ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __LINE__ . ']: Attempting to answer an announcement...');
// Get a XML template instance
$templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_announcement_answer_template_class');
*/
public function loadDescriptorXml (NodeHelper $nodeInstance) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Attempting to answer a request: node-list...');
+ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __LINE__ . ']: Attempting to answer a request: node-list...');
// Get a XML template instance
$templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_answer_template_class');
*/
public function loadDescriptorXml (NodeHelper $nodeInstance) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Attempting self-connect...');
+ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __LINE__ . ']: Attempting self-connect...');
// Get a XML template instance
$templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_self_connect_template_class');
*/
public function loadDescriptorXml (NodeHelper $nodeInstance) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Attempting to request: node-list...');
+ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __LINE__ . ']: Attempting to request: node-list...');
// Get a XML template instance
$templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_template_class');
*/
public function accept (Visitor $visitorInstance) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL: ' . $visitorInstance->__toString() . ' has visited - START');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - START');
// Visit this pool
$visitorInstance->visitPool($this);
// Is this entry visitable?
if ($poolEntry instanceof Visitable) {
// Visit this entry as well
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-POOL: Going to visit pooled object ' . $poolEntry->__toString() . ' with visitor ' . $visitorInstance->__toString() . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-POOL[' . __LINE__ . ']: Going to visit pooled object ' . $poolEntry->__toString() . ' with visitor ' . $visitorInstance->__toString() . ' ...');
$poolEntry->accept($visitorInstance);
} else {
// Cannot visit this entry
} // END - while
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL: ' . $visitorInstance->__toString() . ' has visited - FINISHED');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - FINISHED');
}
/**
// Debug message
self::createDebugInstance(__CLASS__)->debugOutput(
- 'POOL: Listener ' . $listenerInstance->__toString() .
+ 'POOL[' . __LINE__ . ']: Listener ' . $listenerInstance->__toString() .
' listening to ' . $listenerInstance->getListenAddress() . ':' .
$listenerInstance->getListenPort() . ' added to listener pool.'
);
*/
public function doShutdown () {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('POOL: Shutting down listener pool - START');
+ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: Shutting down listener pool - START');
// Get a new visitor
$visitorInstance = ObjectFactory::createObjectByConfiguredName('shutdown_listener_pool_visitor_class');
$this->accept($visitorInstance);
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('POOL: Shutting down listener pool - FINISHED');
+ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: Shutting down listener pool - FINISHED');
}
}
} // END - if
} else {
// Server sockets won't work with socket_getpeername()
- self::createDebugInstance(__CLASS__)->debugOutput('POOL: Socket resource is server socket (' . $socketResource . '). This is not a bug.');
+ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: Socket resource is server socket (' . $socketResource . '). This is not a bug.');
}
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('POOL: Adding peer ' . $peerName . ',socketResource=' . $socketResource . ',type=' . $connectionType);
+ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: Adding peer ' . $peerName . ',socketResource=' . $socketResource . ',type=' . $connectionType);
// Construct the array
$socketArray = array(
assert(count($recipientIpArray) == 2);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL: Checking ' . count($this->getAllSockets()) . ' socket(s),recipientIpArray[0]=' . $recipientIpArray[0] . ',recipientIpArray[1]=' . $recipientIpArray[1] . ' ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: Checking ' . count($this->getAllSockets()) . ' socket(s),recipientIpArray[0]=' . $recipientIpArray[0] . ',recipientIpArray[1]=' . $recipientIpArray[1] . ' ...');
// Default is all sockets
$sockets = $this->getAllSockets();
// Is this a server socket?
if ($socketArray[self::SOCKET_ARRAY_RESOURCE] === $this->getListenerInstance()->getSocketResource()) {
// Skip 'server' sockets (local socket)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL: Skipping server socket ' . $socketArray[self::SOCKET_ARRAY_RESOURCE] . ' ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: Skipping server socket ' . $socketArray[self::SOCKET_ARRAY_RESOURCE] . ' ...');
continue;
} // END - if
$socketResource = $socketArray[self::SOCKET_ARRAY_RESOURCE];
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL: peerIp=' . $peerIp . ' matches with recipient IP address. Taking socket=' . $socketArray[self::SOCKET_ARRAY_RESOURCE] . ',type=' . $socketArray[self::SOCKET_ARRAY_CONN_TYPE]);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: peerIp=' . $peerIp . ' matches with recipient IP address. Taking socket=' . $socketArray[self::SOCKET_ARRAY_RESOURCE] . ',type=' . $socketArray[self::SOCKET_ARRAY_CONN_TYPE]);
break;
} // END - if
} // END - foreach
// Return the determined socket resource
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL: socketResource[' . gettype($socketResource) . ']=' . $socketResource);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: socketResource[' . gettype($socketResource) . ']=' . $socketResource);
return $socketResource;
}
}
$socketInstance = ObjectFactory::CreateObjectByConfiguredName('socket_container_class', array($socketResource, $connectionInstance, $packageData));
// We have a sub-registry, the socket key and the socket, now we need to put all together
- /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY: socketKey=' . $socketKey . ',socketResource=' . $socketResource . ' - adding socket container instance ...');
+ /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __LINE__ . ']: socketKey=' . $socketKey . ',socketResource=' . $socketResource . ' - adding socket container instance ...');
$registryInstance->addInstance($socketKey, $socketInstance);
}
// This is always a SubRegistry instance
foreach ($registryInstance->getInstanceRegistry() as $subKey => $containerInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY: key=' . $key . ',subKey=' . $subKey . ',containerInstance=' . $containerInstance->__toString());
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __LINE__ . ']: key=' . $key . ',subKey=' . $subKey . ',containerInstance=' . $containerInstance->__toString());
// This is a ConnectionContainer instance, so does the recipient match?
if ($containerInstance->ifAddressMatches($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) {
$key = $this->getRegistryKeyFromProtocol($protocolInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY: protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ' - Trying to get instance ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __LINE__ . ']: protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ' - Trying to get instance ...');
// Get the registry
$registryInstance = $this->getInstance($key);
$socketKey = $this->getSubRegistryKey($protocolInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY: protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __LINE__ . ']: protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...');
// Is it there?
if ($registryInstance->instanceExists($socketKey)) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY: Found instance for socketKey=' . $socketKey . ':' . $registryInstance->getInstance($socketKey));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __LINE__ . ']: Found instance for socketKey=' . $socketKey . ':' . $registryInstance->getInstance($socketKey));
// Get the instance
$registeredInstance = $registryInstance->getInstance($socketKey);
$isRegistered = (($registeredInstance instanceof SocketContainer) && ($registeredInstance->ifSocketResourceMatches($socketResource)));
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY: Final result: isRegistered(' . $socketResource . ')=' . intval($isRegistered));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __LINE__ . ']: Final result: isRegistered(' . $socketResource . ')=' . intval($isRegistered));
} // END - if
} // END - if
// Does the instance exist?
if (!$this->isProtocolRegistered($protocolInstance)) {
// No, not found so we create a sub registry (not needed to configure!)
- $registryInstance = SubRegistry::createSubRegistry();
+ $registryInstance = SubREGISTRY[' . __LINE__ . ']::createSubRegistry();
// Now we can create the sub-registry for this protocol
$this->addInstance($this->getRegistryKeyFromProtocol($protocolInstance), $registryInstance);
$socketInstance = ObjectFactory::CreateObjectByConfiguredName('socket_container_class', array($socketResource, $protocolInstance, $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: socketKey=' . $socketKey . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - adding socket container instance ...');
+ /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __LINE__ . ']: socketKey=' . $socketKey . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - adding socket container instance ...');
$registryInstance->addInstance($socketKey, $socketInstance);
}
// Get all keys and check them
foreach ($this->getInstanceRegistry() as $key => $registryInstance) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',registryInstance=' . $registryInstance->__toString());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __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: key=' . $key . ',subKey=' . $subKey . ',containerInstance=' . $containerInstance->__toString());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __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]))) {
*/
private function initObjectRegistry () {
// Output debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TAGS: Initializing object registry - START');
+ self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __LINE__ . ']: Initializing object registry - START');
// Get the application instance
$applicationInstance = Registry::getRegistry()->getInstance('app');
$this->getTemplateInstance()->renderXmlContent();
// Output debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TAGS: Initializing object registry - FINISHED');
+ self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __LINE__ . ']: Initializing object registry - FINISHED');
}
/**
// "Walk" over all tags
foreach ($this->getTags() as $tag) {
// Debug output
- self::createDebugInstance(__CLASS__)->debugOutput('TAGS: Validating tag ' . $tag . ' ...');
+ self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __LINE__ . ']: Validating tag ' . $tag . ' ...');
// Get an array from this tag
$entry = $objectRegistryInstance->getArrayFromKey(XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_NAME, $tag);
// Is the node name self::OBJECT_TYPE_DATA_NAME?
if ($nodeName == self::OBJECT_TYPE_DATA_NAME) {
// Output debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TAGS: Adding object type ' . $characters . ' to registry.');
+ self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __LINE__ . ']: Adding object type ' . $characters . ' to registry.');
} // END - if
// Add it to the registry
// Does it match a direct ip:port? (hint: see www.regexlib.com for the regular expression)
if (preg_match('/((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])):([0-9]{3,5})/', $sessionId)) {
// Direct ip:port found
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS: Direct ip:port ' . $sessionId . ' detected.');
+ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __LINE__ . ']: Direct ip:port ' . $sessionId . ' detected.');
} elseif (isset($selfInstance->sessionIdCache[$sessionId])) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS: Using entry from sessionIdCache[] array.');
+ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __LINE__ . ']: Using entry from sessionIdCache[] array.');
// Found in cache!
$recipient = $selfInstance->sessionIdCache[$sessionId];
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS: sessionIdCache[' . $sessionId . ']=' . $recipient);
+ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __LINE__ . ']: sessionIdCache[' . $sessionId . ']=' . $recipient);
} elseif (preg_match('/([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}:([0-9]{3,5})/', $sessionId)) {
// Hostname:port found
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS: hostname:port ' . $sessionId . ' detected.');
+ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __LINE__ . ']: hostname:port ' . $sessionId . ' detected.');
// Hostname:port found
$hostnameArray = explode(':', $sessionId);
} // END - if
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS: hostname:port ' . $sessionId . ' resolved to ' . $recipient);
+ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __LINE__ . ']: hostname:port ' . $sessionId . ' resolved to ' . $recipient);
} elseif (preg_match('/([a-f0-9]{' . $selfInstance->getSessionIdLength() . '})/', $sessionId)) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS: Using internal session id resolver.');
+ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __LINE__ . ']: Using internal session id resolver.');
// Resolve session id into a ip:port combination
$recipient = $selfInstance->resolveIpPortBySessionId($sessionId);
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS: Session id ' . $sessionId . ' resolved to ' . $recipient);
+ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __LINE__ . ']: Session id ' . $sessionId . ' resolved to ' . $recipient);
} else {
// Invalid session id
throw new InvalidSessionIdException($sessionId, self::EXCEPTION_SESSION_ID_IS_INVALID);