use Org\Shipsimu\Hub\Factory\Handler\Message\MessageTypeHandlerFactory;
use Org\Shipsimu\Hub\Factory\Information\Connection\ConnectionInfoFactory;
use Org\Shipsimu\Hub\Factory\Network\Locator\UniversalNodeLocatorFactory;
+use Org\Shipsimu\Hub\Factory\Network\Message\NetworkMessageFactory;
use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
use Org\Shipsimu\Hub\Generic\BaseHubSystem;
use Org\Shipsimu\Hub\Handler\BaseHubHandler;
$handlerInstance->setAssemblerInstance($assemblerInstance);
// Get node instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Creating node instance ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('NETWORK-PACKAGE-HANDLER: Creating node instance ...');
$nodeInstance = NodeObjectFactory::createNodeInstance();
// Set it locally
*/
private function determineSenderPrivateKeyHash (DeliverablePackage $packageInstance) {
// Get DHT instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
$dhtInstance = DhtObjectFactory::createDhtInstance('node');
// Ask DHT for sender's id or address (both session id)
- /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Finding local node data for packageInstance->senderId=%s ...', $packageInstance->getSenderId()));
+ /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: Finding local node data for packageInstance->senderId=%s ...', $packageInstance->getSenderId()));
$senderData = $dhtInstance->findNodeLocalBySessionId($packageInstance->getSenderId());
// Is an entry found?
- /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: senderData()=%d', count($senderData)));
+ /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: senderData()=%d', count($senderData)));
//* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: senderData=%s', __METHOD__, __LINE__, print_r($senderData, TRUE)));
if (count($senderData) > 0 || !empty($senderData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH])) {
// Return it
- /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Returning senderData[%s]=%s', NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH, $senderData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH]));
+ /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: Returning senderData[%s]=%s', NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH, $senderData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH]));
return $senderData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH];
}
// There is no DHT entry so, accept the hash from decoded data
- /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Returning packagheInstance->senderPrivateKeyHash=%s - EXIT!', $packageInstance->getSenderPrivateKeyHash()));
+ /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: Returning packagheInstance->senderPrivateKeyHash=%s - EXIT!', $packageInstance->getSenderPrivateKeyHash()));
return $packageInstance->getSenderPrivateKeyHash();
}
*/
private function getHashFromContent ($content) {
// Create the hash
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: content[md5]=%s - CALLED!', md5($content)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: content[md5]=%s - CALLED!', md5($content)));
// @TODO md5() is very weak, but it needs to be fast
$hash = md5(sprintf(self::CONTENT_CHECKSUM_MASK,
$content,
));
// And return it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: content[md5]=%s,sender=%s,hash=%s,compressor=%s - EXIT!', md5($content), $this->getNodeInstance()->getSessionId(), $hash, $this->getCompressorInstance()->getCompressorExtension()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: content[md5]=%s,sender=%s,hash=%s,compressor=%s - EXIT!', md5($content), $this->getNodeInstance()->getSessionId(), $hash, $this->getCompressorInstance()->getCompressorExtension()));
return $hash;
}
*/
private function isChecksumValid (DeliverablePackage $packageInstance) {
// Get checksum
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
$checksum = $this->getHashFromPackageSessionId($packageInstance);
// Is it the same?
$isChecksumValid = ($checksum == $packageInstance->getContentChecksum());
// Return it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isChecksumValid=%d - EXIT!', intval($isChecksumValid)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: isChecksumValid=%d - EXIT!', intval($isChecksumValid)));
return $isChecksumValid;
}
*/
private function changePackageStatus (DeliverablePackage $packageInstance, $stackerName, $newStatus) {
// Skip this for empty stacks
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s,stackerName=%s,newStatus=%s - CALLED!', $packageInstance->__toString(), $stackerName, $newStatus));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s,stackerName=%s,newStatus=%s - CALLED!', $packageInstance->__toString(), $stackerName, $newStatus));
if ($this->getStackInstance()->isStackEmpty($stackerName)) {
// This avoids an exception after all packages has failed
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: stackerName=%s is empty - EXIT!', $stackerName));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: stackerName=%s is empty - EXIT!', $stackerName));
return;
}
// Pop the entry (it should be it)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Getting next stack from stackerName=%s ...', $stackerName));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: Getting next stack from stackerName=%s ...', $stackerName));
$nextPackageInstance = $this->getStackInstance()->popNamed($stackerName);
// Compare both hashes
}
// Temporary set the new status
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Setting newStatus=%s ....', $newStatus));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: Setting newStatus=%s ....', $newStatus));
$packageInstance->setPackageStatus($newStatus);
// And push it again
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Adding packageInstance=%s to stackerName=%s ...', $packageInstance->__toString(), $stackerName));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: Adding packageInstance=%s to stackerName=%s ...', $packageInstance->__toString(), $stackerName));
$this->getStackInstance()->pushNamed($stackerName, $packageInstance);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
*/
public function getHashFromPackageSessionId (DeliverablePackage $packageInstance) {
// Is session id set?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
/* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE)));
if (empty($packageInstance->getSessionId())) {
// Throw exception
));
// And return it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: hash=%s - EXIT!', $hash));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: hash=%s - EXIT!', $hash));
return $hash;
}
* target because it causes an overload on the network and may be
* abused for attacking the network with large packages.
*/
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
$discoveryInstance = PackageDiscoveryFactory::createPackageDiscoveryInstance();
// Discover all recipients, this may throw an exception
$currentRecipient = $iteratorInstance->current();
// Set the recipient
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Setting recipient to ' . $currentRecipient . ',previous=' . $packageInstance->getRecipientUnl());
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('NETWORK-PACKAGE-HANDLER: Setting recipient to ' . $currentRecipient . ',previous=' . $packageInstance->getRecipientUnl());
$packageInstance->setRecipientUnl($currentRecipient);
// Push the declared package to the next stack.
$this->getStackInstance()->pushNamed(self::STACKER_NAME_DECLARED, $packageInstance);
// Skip to next entry
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Package declared for recipient ' . $currentRecipient);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('NETWORK-PACKAGE-HANDLER: Package declared for recipient ' . $currentRecipient);
$iteratorInstance->next();
}
* shall be delivered has already been added for all entries from the
* list.
*/
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Invoking discoveryInstance->clearRecipients() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: Invoking discoveryInstance->clearRecipients() ...');
$discoveryInstance->clearRecipients();
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
* which (configurable!) protocol should be used for that type of
* package.
*/
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
$discoveryInstance = SocketDiscoveryFactory::createSocketDiscoveryInstance();
// Now discover the right socket instance from given package data
$socketInstance = $discoveryInstance->discoverSocket($packageInstance, StorableSocket::CONNECTION_TYPE_OUTGOING);
// Get the connection helper from registry
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Getting helperInstance for connection from registry ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('NETWORK-PACKAGE-HANDLER: Getting helperInstance for connection from registry ...');
$helperInstance = ObjectRegistry::getRegistry('hub')->getInstance('connection');
// Get connection info class
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: stateInstance=%s', $helperInstance->getStateInstance()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: stateInstance=%s', $helperInstance->getStateInstance()));
$infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($helperInstance->getProtocolName(), 'helper');
// Will the info instance with connection helper data
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Invoking infoInstance->fillWithConnectionHelperInformation(%s) ...', $helperInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: Invoking infoInstance->fillWithConnectionHelperInformation(%s) ...', $helperInstance->__toString()));
$infoInstance->fillWithConnectionHelperInformation($helperInstance);
// Is it not there?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: socketInstance->isValidSocket()=%d', intval($socketInstance->isValidSocket())));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: socketInstance->isValidSocket()=%d', intval($socketInstance->isValidSocket())));
if (($socketInstance->isValidSocket()) && (!$this->getRegistryInstance()->isSocketRegistered($infoInstance, $socketInstance))) {
// Then register it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Registering socket %s ...', $socketInstance));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: Registering socket %s ...', $socketInstance));
$this->getRegistryInstance()->registerSocketInstance($infoInstance, $socketInstance);
} elseif (!$helperInstance->getStateInstance()->isPeerStateConnected()) {
// Is not connected, then we cannot send
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Unexpected peer state %s detected.', $helperInstance->getStateInstance()->__toString()));
+ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('NETWORK-PACKAGE-HANDLER: Unexpected peer state %s detected.', $helperInstance->getStateInstance()->__toString()));
// Shutdown the socket
$socketInstance->shutdownSocket();
}
// Make sure the connection is up
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Invoking helperInstance->stateInstance->validatePeerStateConnected() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: Invoking helperInstance->stateInstance->validatePeerStateConnected() ...');
$helperInstance->getStateInstance()->validatePeerStateConnected();
// Enqueue it again on the out-going queue, the connection is up and working at this point
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Invoking this->stackInstance->pushNamed(%s, %s) ...', self::STACKER_NAME_OUTGOING, $packageInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: Invoking this->stackInstance->pushNamed(%s, %s) ...', self::STACKER_NAME_OUTGOING, $packageInstance->__toString()));
$this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING, $packageInstance);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
*/
private function sendOutgoingRawPackageData (DeliverablePackage $packageInstance) {
// Init sent bytes
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
$sentBytes = 0;
// Get the right connection instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Invoking this->registryInstance->determineInfoInstanceByPackageInstance(%s) ...', gettype($packageInstance)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: Invoking this->registryInstance->determineInfoInstanceByPackageInstance(%s) ...', gettype($packageInstance)));
$infoInstance = $this->getRegistryInstance()->determineInfoInstanceByPackageInstance($packageInstance);
// Test helper instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: infoInstance[]=%s', gettype($infoInstance)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: infoInstance[]=%s', gettype($infoInstance)));
if (is_null($infoInstance)) {
// Throw NPE
throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
$helperInstance->sendRawPackageData($packageInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
* @param $senderId Sender id to generate a hash for
* @return $hash Hash as hex-encoded string
*/
- private function generatePackageHash ($content, $senderId) {
+ private function generatePackageHash (string $content, string $senderId) {
// Assert on variables
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: content()=' . strlen($content) . ',senderId=' . $senderId . ' - CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: content()=' . strlen($content) . ',senderId=' . $senderId . ' - CALLED!');
assert(!empty($content));
assert(!empty($senderId));
// Is the feature enabled?
if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) {
// Feature is not enabled
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Feature "hubcoin_reward" not available, not generating package hash. Returning NULL ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: Feature "hubcoin_reward" not available, not generating package hash. Returning NULL ...');
return NULL;
}
$packageInstance->setSenderPrivateKeyHash($this->getNodeInstance()->getNodePrivateKeyHash());
// Hash content and sender id together, use scrypt
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: senderId=' . $senderId . ',content()=' . strlen($content));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('NETWORK-PACKAGE-HANDLER: senderId=' . $senderId . ',content()=' . strlen($content));
$hash = FrameworkFeature::callFeature('hubcoin_reward', 'generateHash', array(
sprintf('%s:%s:%s',
$senderId,
));
// Return it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: hash=' . $hash . ' - EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: hash=' . $hash . ' - EXIT!');
return $hash;
}
*/
private function isPackageContentHashValid (DeliverablePackage $packageInstance) {
// Is the feature enabled?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) {
// Feature is not enabled, so hashes are always valid
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Feature "hubcoin_reward" not available, not checking hash. Returning TRUE ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: Feature "hubcoin_reward" not available, not checking hash. Returning TRUE ...');
return TRUE;
} elseif (empty($packageInstance->getSenderId())) {
// Empty sender id
}
// Check validity
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance->senderId=%s,packageInstance->packageContent=%s,packageInstance->contentHash=%s', $packageInstance->getSenderId(), $packageInstance->getPackageContent(), $packageInstance->getContentHash()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance->senderId=%s,packageInstance->packageContent=%s,packageInstance->contentHash=%s', $packageInstance->getSenderId(), $packageInstance->getPackageContent(), $packageInstance->getContentHash()));
//* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE)));
$isHashValid = FrameworkFeature::callFeature('hubcoin_reward', 'checkHash', [
sprintf('%s:%s:%s',
]);
// Return it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isHashValid=%s - EXIT!', intval($isHashValid)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: isHashValid=%s - EXIT!', intval($isHashValid)));
return $isHashValid;
}
*/
public function enqueueRawDataFromTemplate (HubHelper $helperInstance) {
// Get the raw content ...
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: helperInstance=' . $helperInstance->__toString() . ' - CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: helperInstance=' . $helperInstance->__toString() . ' - CALLED!');
$rawTemplateData = $helperInstance->getTemplateInstance()->getRawTemplateData();
// Should not be empty
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: rawTemplateData(%d)=%s', strlen($rawTemplateData), $rawTemplateData));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: rawTemplateData(%d)=%s', strlen($rawTemplateData), $rawTemplateData));
if (empty($rawTemplateData)) {
// Abort here
throw new UnexpectedValueException('Variable "rawTemplateData" is unexpectly empty.');
$compressed = $this->getCompressorInstance()->compressStream($rawTemplateData);
// Add magic in front of it and hash behind it, including BASE64 encoding
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: compressed()=%d', strlen($compressed)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: compressed()=%d', strlen($compressed)));
$packageContent = sprintf(self::PACKAGE_MASK,
// 1.) Compressor's extension
$this->getCompressorInstance()->getCompressorExtension(),
);
// Init package instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Enqueueing package for recipientType=' . $helperInstance->getRecipientType() . ' ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('NETWORK-PACKAGE-HANDLER: Enqueueing package for recipientType=' . $helperInstance->getRecipientType() . ' ...');
$packageInstance = ObjectFactory::createObjectByConfiguredName('package_data_class');
// Set all data
$packageInstance->setSenderId($this->getNodeInstance()->getSessionId());
$packageInstance->setRecipientId($helperInstance->getRecipientId());
$packageInstance->setRecipientType($helperInstance->getRecipientType());
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Setting packageContent=%s ...', $packageContent));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: Setting packageContent=%s ...', $packageContent));
$packageInstance->setPackageContent($packageContent);
$packageInstance->setPackageStatus(self::PACKAGE_STATUS_NEW);
$packageInstance->setContentHash($this->generatePackageHash($rawTemplateData, $this->getNodeInstance()->getSessionId()));
$packageInstance->setSenderPrivateKeyHash($this->getNodeInstance()->getNodePrivateKeyHash());
// Now prepare the temporary array and push it on the 'undeclared' stack
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Pushing packageInstance=%s to stack %s ...', $packageInstance->__toString(), self::STACKER_NAME_UNDECLARED));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: Pushing packageInstance=%s to stack %s ...', $packageInstance->__toString(), self::STACKER_NAME_UNDECLARED));
$this->getStackInstance()->pushNamed(self::STACKER_NAME_UNDECLARED, $packageInstance);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
*/
public function isPackageEnqueued () {
// Check whether the stacker is not empty
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: CALLED!');
$isEnqueued = (
($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_UNDECLARED)) &&
(!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_UNDECLARED))
// Return the result
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isEnqueued=%d - EXIT!', intval($isEnqueued)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: isEnqueued=%d - EXIT!', intval($isEnqueued)));
return $isEnqueued;
}
*/
public function isPackageDeclared () {
// Check whether the stacker is not empty
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: CALLED!');
$isDeclared = (
($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_DECLARED)) &&
(!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECLARED))
);
// Return the result
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isDeclared=%d - EXIT!', intval($isDeclared)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: isDeclared=%d - EXIT!', intval($isDeclared)));
return $isDeclared;
}
*/
public function isPackageWaitingForDelivery () {
// Check whether the stacker is not empty
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: CALLED!');
$isWaitingDelivery = (
(
$this->getStackInstance()->isStackInitialized(self::STACKER_NAME_OUTGOING)
);
// Return the result
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isWaitingDelivery=%d - EXIT!', intval($isWaitingDelivery)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: isWaitingDelivery=%d - EXIT!', intval($isWaitingDelivery)));
return $isWaitingDelivery;
}
*/
public function isEncodedDataPending () {
// Check whether the stacker is not empty
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: CALLED!');
$isPending = (
(
$this->getStackInstance()->isStackInitialized(self::STACKER_NAME_OUTGOING_STREAM)
);
// Return the result
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isPending=%d - EXIT!', intval($isPending)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: isPending=%d - EXIT!', intval($isPending)));
return $isPending;
}
*/
public function declareEnqueuedPackage () {
// Make sure this method isn't working if there is no package enqueued
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: CALLED!');
if (!$this->isPackageEnqueued()) {
// This is not fatal but should be avoided
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: No raw package data waiting declaration, but ' . __METHOD__ . ' has been called!');
+ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: No raw package data waiting declaration, but ' . __METHOD__ . ' has been called!');
return;
}
$packageInstance = $this->getStackInstance()->popNamed(self::STACKER_NAME_UNDECLARED);
// Declare the raw package data for delivery
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance->recipientType=%s is undeclared, declaring now ...', $packageInstance->getRecipientType()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance->recipientType=%s is undeclared, declaring now ...', $packageInstance->getRecipientType()));
$this->declareRawPackageData($packageInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
*/
public function processDeclaredPackage () {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: CALLED!');
// Sanity check if we have packages declared
if (!$this->isPackageDeclared()) {
// This is not fatal but should be avoided
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: No package has been declared, but ' . __METHOD__ . ' has been called!');
+ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: No package has been declared, but ' . __METHOD__ . ' has been called!');
return;
}
$this->getStackInstance()->popNamed(self::STACKER_NAME_DECLARED);
} catch (UnexpectedStateException $e) {
// The state is not excepected (shall be 'connected')
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Caught ' . $e->__toString() . ',message=' . $e->getMessage());
+ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage('NETWORK-PACKAGE-HANDLER: Caught ' . $e->__toString() . ',message=' . $e->getMessage());
// Mark the package with status failed
$this->changePackageStatus($packageInstance, self::STACKER_NAME_DECLARED, self::PACKAGE_STATUS_FAILED);
}
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
* @throws UnexpectedValueException If $sessionId is empty
*/
public function sendWaitingPackage () {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
-
// Sanity check if we have packages waiting for delivery
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: CALLED!');
if (!$this->isPackageWaitingForDelivery()) {
// This is not fatal but should be avoided
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: No package is waiting for delivery, but ' . __METHOD__ . ' was called.');
+ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: No package is waiting for delivery, but ' . __METHOD__ . ' was called.');
return;
}
$packageInstance = $this->getStackInstance()->getNamed(self::STACKER_NAME_OUTGOING);
// The UNL should be set but not recipientId
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: recipientUnl(%d)=%s,recipientId(%d)=%s', strlen($packageInstance->getRecipientUnl()), $packageInstance->getRecipientUnl(), strlen($packageInstance->getRecipientId()), $packageInstance->getRecipientId()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: recipientUnl(%d)=%s,recipientId(%d)=%s', strlen($packageInstance->getRecipientUnl()), $packageInstance->getRecipientUnl(), strlen($packageInstance->getRecipientId()), $packageInstance->getRecipientId()));
if (!empty($packageInstance->getRecipientUnl()) && (empty($packageInstance->getRecipientId()) || $packageInstance->getRecipientId() == 'invalid')) {
// Need to resolve UNL -> session id ("recipient id"), so prepare UNL instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: recipientUnl=%s is being solved into a session id ...', $packageInstance->getRecipientUnl()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: recipientUnl=%s is being solved into a session id ...', $packageInstance->getRecipientUnl()));
$locatorInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($packageInstance->getRecipientUnl());
// Get session id and set it back
$sessionId = HubTools::resolveSessionIdByUniversalNodeLocator($locatorInstance);
// Is it empty?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: sessionId[%s]=%s', gettype($sessionId), $sessionId));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: sessionId[%s]=%s', gettype($sessionId), $sessionId));
if (empty($sessionId)) {
// HubTools was not able to resolve this
throw new UnexpectedValueException('sessionId is empty');
$this->getStackInstance()->popNamed(self::STACKER_NAME_OUTGOING);
} catch (InvalidSocketException $e) {
// Output exception message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Package was not delivered: ' . $e->getMessage());
+ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage('NETWORK-PACKAGE-HANDLER: Package was not delivered: ' . $e->getMessage());
// Mark package as failed
$this->changePackageStatus($packageInstance, self::STACKER_NAME_OUTGOING, self::PACKAGE_STATUS_FAILED);
}
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
*/
public function sendEncodedData () {
// Make sure there is pending encoded data
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: CALLED!');
if (!$this->isEncodedDataPending()) {
// Throw exception
throw new BadMethodCallException('No encoded data is pending but this method was called.', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
$encodedDataArray = $this->getStackInstance()->popNamed(self::STACKER_NAME_OUTGOING_STREAM);
// Init in this round sent bytes
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: encodedDataArray()=%d has been "popped" from stack %s.', count($encodedDataArray), self::STACKER_NAME_OUTGOING_STREAM));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: encodedDataArray()=%d has been "popped" from stack %s.', count($encodedDataArray), self::STACKER_NAME_OUTGOING_STREAM));
$sentBytes = 0;
// Check all conditions, throw exceptions if something unexpected happened
$encodedDataArray[self::RAW_INDEX_SOCKET_INSTANCE] = NULL;
// And deliver it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Invoking socketInstance->writeBufferToSocketByArray(%d,%d) ...', count($encodedDataArray), $sentBytes));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: Invoking socketInstance->writeBufferToSocketByArray(%d,%d) ...', count($encodedDataArray), $sentBytes));
if (!$socketInstance->writeBufferToSocketByArray($encodedDataArray, $sentBytes)) {
// Something bad happened while writing to socket
$socketInstance->handleSocketError(__METHOD__, __LINE__);
}
// If there was an error, don't continue here
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: sentBytes[%s]=%d', gettype($sentBytes), $sentBytes));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: sentBytes[%s]=%d', gettype($sentBytes), $sentBytes));
if (($sentBytes === 0) && (strlen($encodedDataArray[self::RAW_INDEX_ENCODED_DATA]) > 0)) {
// Nothing sent means all data has been sent
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: All sent! (LINE=' . __LINE__ . ')');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: All sent! (LINE=' . __LINE__ . ')');
return;
} elseif (strlen($encodedDataArray[self::RAW_INDEX_ENCODED_DATA]) == 0) {
// Abort here, all sent!
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: All sent! (LINE=' . __LINE__ . ')');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: All sent! (LINE=' . __LINE__ . ')');
return;
}
$encodedDataArray[self::RAW_INDEX_SOCKET_INSTANCE] = $socketInstance;
// Push array back in stack
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Pushing raw data back to stacker, as still some data is pending delivery.');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('NETWORK-PACKAGE-HANDLER: Pushing raw data back to stacker, as still some data is pending delivery.');
$this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING_STREAM, $encodedDataArray);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: EXIT!');
}
///////////////////////////////////////////////////////////////////////////
*/
private function isRawDataPending () {
// Just return whether the stack is not empty
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: CALLED!');
$isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECODED_INCOMING));
// Return the status
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isPending=%d - EXIT!', intval($isPending)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: isPending=%d - EXIT!', intval($isPending)));
return $isPending;
}
*/
public function isNewRawDataPending () {
// Visit the pool. This monitors the pool for incoming raw data.
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Invoking this->getListenerPoolInstance()->accept(%s) ... - CALLED!', $this->getVisitorInstance()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: Invoking this->getListenerPoolInstance()->accept(%s) ... - CALLED!', $this->getVisitorInstance()));
$this->getListenerPoolInstance()->accept($this->getVisitorInstance());
// Check for new data arrival
$hasArrived = $this->isRawDataPending();
// Return the status
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: hasArrived=%d - EXIT!', intval($hasArrived)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: hasArrived=%d - EXIT!', intval($hasArrived)));
return $hasArrived;
}
* This method should only be called if decoded raw data is pending,
* so check it again.
*/
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: CALLED!');
if (!$this->isRawDataPending()) {
// Should not be invoked anymore
throw new BadMethodCallException('No incoming decoded data on stack but method was called.', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// "Pop" the next entry (the same array again) from the stack
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Stacker size is %d entries.', $this->getStackInstance()->getStackCount(self::STACKER_NAME_DECODED_INCOMING)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: Stacker size is %d entries.', $this->getStackInstance()->getStackCount(self::STACKER_NAME_DECODED_INCOMING)));
$packageInstance = $this->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_INCOMING);
/*
* only want to handle unhandled packages here.
*/
// Remove the last chunk SEPARATOR (because there is no need for it)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: errorCode=%s/%s', $packageInstance->getErrorCode(), StorableSocket::SOCKET_ERROR_UNHANDLED));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: errorCode=%s/%s', $packageInstance->getErrorCode(), StorableSocket::SOCKET_ERROR_UNHANDLED));
if (substr($packageInstance->getRawData(), -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) {
// It is there and should be removed
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Raw data contains CHUNK_SEPARATOR=%s - Removing ...', PackageFragmenter::CHUNK_SEPARATOR));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: Raw data contains CHUNK_SEPARATOR=%s - Removing ...', PackageFragmenter::CHUNK_SEPARATOR));
$packageInstance->setRawData(substr($packageInstance->getRawData(), 0, -1));
}
// This package is "handled" and can be pushed on the next stack
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Pushing %d(%s) bytes to stack %s ...', strlen($packageInstance->getRawData()), $packageInstance->getRawData(), self::STACKER_NAME_DECODED_HANDLED));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: Pushing %d(%s) bytes to stack %s ...', strlen($packageInstance->getRawData()), $packageInstance->getRawData(), self::STACKER_NAME_DECODED_HANDLED));
$this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_HANDLED, $packageInstance);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
* Get the decoded data from the handler, this is an array with
* 'raw_data' and 'error_code' as elements.
*/
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: handlerInstance=%s - CALLED!', $handlerInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: handlerInstance=%s - CALLED!', $handlerInstance->__toString()));
$packageInstance = $handlerInstance->getNextPackageInstance();
// And push it on our stack
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance->rawData()=%s', strlen($packageInstance->getRawData())));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance->rawData()=%s', strlen($packageInstance->getRawData())));
$this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_INCOMING, $packageInstance);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
*/
public function handleAssemblerPendingData () {
// Handle it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Invoking this->getAssemblerInstance()->handlePendingData() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: Invoking this->getAssemblerInstance()->handlePendingData() ...');
$this->getAssemblerInstance()->handlePendingData();
}
*/
public function handleMultipleMessages () {
// Handle it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Invoking this->getAssemblerInstance()->handleMultipleMessages() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: Invoking this->getAssemblerInstance()->handleMultipleMessages() ...');
$this->getAssemblerInstance()->handleMultipleMessages();
}
*/
public function accept (Visitor $visitorInstance) {
// Visit the package
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: ' . $visitorInstance->__toString() . ' has visited - CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: ' . $visitorInstance->__toString() . ' has visited - CALLED!');
$visitorInstance->visitNetworkPackageHandler($this);
// Then visit the assembler to handle multiple packages
$this->getAssemblerInstance()->accept($visitorInstance);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: ' . $visitorInstance->__toString() . ' has visited - EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: ' . $visitorInstance->__toString() . ' has visited - EXIT!');
}
/**
$this->initStacks(TRUE);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: All stacker have been re-initialized.');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: All stacker have been re-initialized.');
}
/**
*/
public function removeFirstFailedPackage () {
// Get the package again
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: CALLED!');
$packageInstance = $this->getStackInstance()->getNamed(self::STACKER_NAME_DECLARED);
// Is the package status 'failed'?
$this->getStackInstance()->popNamed(self::STACKER_NAME_DECLARED);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
*/
public function decodeRawContent ($rawPackageContent) {
// Check if no double seperator is found
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: rawPackageContent(%d)=%s - CALLED!', strlen($rawPackageContent), $rawPackageContent));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: rawPackageContent(%d)=%s - CALLED!', strlen($rawPackageContent), $rawPackageContent));
if (strpos($rawPackageContent, self::PACKAGE_DATA_SEPARATOR . self::PACKAGE_DATA_SEPARATOR) !== FALSE) {
// Opps, should never happend
throw new InvalidArgumentException(sprintf('rawPackageContent=%s has 2x or more "%s" in it.', $rawPackageContent, self::PACKAGE_DATA_SEPARATOR));
$decodedArray = explode(self::PACKAGE_DATA_SEPARATOR, $rawPackageContent);
// Assert on count (should be always 6)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: decodedArray()=%d', count($decodedArray)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: decodedArray()=%d', count($decodedArray)));
//* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: decodedArray=%s', __METHOD__, __LINE__, print_r($decodedArray, TRUE)));
if (count($decodedArray) != self::DECODED_DATA_ARRAY_SIZE) {
// Count of array elements not expected
$packageInstance->setSenderPrivateKeyHash($decodedArray[self::INDEX_PACKAGE_PRIVATE_KEY_HASH]);
// And return it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - EXIT!', $packageInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - EXIT!', $packageInstance->__toString()));
return $packageInstance;
}
*/
public function handleReceivedPackageInstance (DeliverablePackage $packageInstance) {
// Is the package content set?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
if (empty($packageInstance->getPackageContent())) {
// Package content is not set
throw new InvalidArgumentException(sprintf('Package with receipientId=%s,recipientType=%s has empty packageContent',
$decodedContent = explode(self::PACKAGE_MASK_SEPARATOR, $packageInstance->getPackageContent());
// Assert on array count for a very basic validation
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: decodedContent()=%d', count($decodedContent)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: decodedContent()=%d', count($decodedContent)));
if (count($decodedContent) != self::PACKAGE_CONTENT_ARRAY_SIZE) {
// Not valid decoded content
throw new InvalidArgumentException(sprintf('decodedContent()=%d does not match expected %d. packageContent=%s',
$this->getStackInstance()->pushNamed(self::STACKER_NAME_PACKAGE_DECOMPRESSED_XML, $packageInstance);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
*/
public function isNewMessageArrived () {
// Determine if the stack is not empty
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: CALLED!');
$hasArrived = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_NEW_MESSAGE));
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: hasArrived=%d - EXIT!', intval($hasArrived)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: hasArrived=%d - EXIT!', intval($hasArrived)));
return $hasArrived;
}
*/
public function isDecodedPackageXmlPending () {
// Determine if the stack is not empty
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: CALLED!');
$hasArrived = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_PACKAGE_DECOMPRESSED_XML));
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: hasArrived=%d - EXIT!', intval($hasArrived)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: hasArrived=%d - EXIT!', intval($hasArrived)));
return $hasArrived;
}
*/
public function handleNewlyArrivedMessage () {
// Make sure there is at least one message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: CALLED!');
if (!$this->isNewMessageArrived()) {
// Bad method call
throw new BadMethodCallException('No new message arrived but this method has been called.', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
// Generate the hash of comparing it
/* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: messageInstance=%s', __METHOD__, __LINE__, print_r($messageInstance, TRUE)));
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: messageInstance=%s,senderId=%s,senderPrivateKeyHash=%s', $messageInstance->__toString(), $messageInstance->getSenderId(), $messageInstance->getSenderPrivateKeyHash()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: messageInstance=%s,senderId=%s,senderPrivateKeyHash=%s', $messageInstance->__toString(), $messageInstance->getSenderId(), $messageInstance->getSenderPrivateKeyHash()));
if (empty($messageInstance->getSenderId())) {
// Invalid $messageInstance
throw new InvalidArgumentException('messageInstance does not contain senderId');
$chainInstance->postProcessMessage($this);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
*/
public function handleDecodedPackageXml () {
// Make sure there is at least one package
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: CALLED!');
if (!$this->isDecodedPackageXmlPending()) {
// Bad method call
throw new BadMethodCallException('No package waiting XML parsing', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
// Generate the hash of comparing it
//* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE)));
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s,senderId=%s,senderPrivateKeyHash=%s', $packageInstance->__toString(), $packageInstance->getSenderId(), $packageInstance->getSenderPrivateKeyHash()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s,senderId=%s,senderPrivateKeyHash=%s', $packageInstance->__toString(), $packageInstance->getSenderId(), $packageInstance->getSenderPrivateKeyHash()));
if (empty($packageInstance->getSenderId())) {
// Invalid $packageInstance
throw new InvalidArgumentException('packageInstance does not contain senderId');
}
// Parse package's XML into a message instance
+ $messageInstance = NetworkMessageFactory::createNetworkMessageInstanceFromPackage($packageInstance);
/* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE)));
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
*/
public function isProcessedMessagePending () {
// Check it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: CALLED!');
$isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_PROCESSED_MESSAGE));
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isPending=%d - EXIT!', intval($isPending)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: isPending=%d - EXIT!', intval($isPending)));
return $isPending;
}
*/
public function handleProcessedMessage () {
// Get it from the stacker, it is the full array with the processed message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: CALLED!');
$messageInstance = $this->getStackInstance()->popNamed(self::STACKER_NAME_PROCESSED_MESSAGE);
// Add type for later easier handling
$messageArray[self::MESSAGE_ARRAY_DATA][self::MESSAGE_ARRAY_TYPE] = $messageArray[self::MESSAGE_ARRAY_TYPE];
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: messageArray=' . print_r($messageArray, TRUE));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('NETWORK-PACKAGE-HANDLER: messageArray=' . print_r($messageArray, TRUE));
// Create a handler instance from given message type
$handlerInstance = MessageTypeHandlerFactory::createMessageTypeHandlerInstance($messageArray[self::MESSAGE_ARRAY_TYPE]);
$handlerInstance->postHandleMessageData($messageArray, $this);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
*/
public function feedHashToMiner (DeliverableMessage $messageInstance) {
// Is the feature enabled?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: messageInstance=%s - CALLED!', $messageInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NETWORK-PACKAGE-HANDLER: messageInstance=%s - CALLED!', $messageInstance->__toString()));
if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) {
/*
* Feature is not enabled, don't feed the hash to the miner as it
unset($messageData[self::MESSAGE_ARRAY_DATA]);
// Resolve session id ('sender' is a session id) into node id
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: messageData=' . print_r($messageData, TRUE));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('NETWORK-PACKAGE-HANDLER: messageData=' . print_r($messageData, TRUE));
$nodeId = HubTools::resolveNodeIdBySessionId($messageData[self::MESSAGE_ARRAY_SENDER]);
// Is 'claim_reward' the message type?