// Get current package data
$packageInstance = $this->getPackageDataInstance();
+ /* DEBUG-DIE: */ if ($this->getSocketType() == StorableSocket::CONNECTION_TYPE_INCOMING) { die(sprintf('[%s:%d]: this=%s', __METHOD__, __LINE__, print_r($this, TRUE))); }
//* DEBUG-DIE: */ if ($this->getSocketType() == StorableSocket::CONNECTION_TYPE_INCOMING) { die(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE))); }
// So, does both match?
$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)));
$infoInstance = $this->getRegistryInstance()->determineInfoInstanceByPackageInstance($packageInstance);
// Test helper instance
public function enqueueRawDataFromTemplate (HubHelper $helperInstance) {
// Get the raw content ...
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: helperInstance=' . $helperInstance->__toString() . ' - CALLED!');
- $content = $helperInstance->getTemplateInstance()->getRawTemplateData();
+ $rawTemplateData = $helperInstance->getTemplateInstance()->getRawTemplateData();
// Should not be empty
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: content(%d)=%s', strlen($content), $content));
- if (empty($content)) {
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: rawTemplateData(%d)=%s', strlen($rawTemplateData), $rawTemplateData));
+ if (empty($rawTemplateData)) {
// Abort here
- throw new UnexpectedValueException('Parameter "content" is empty');
+ throw new UnexpectedValueException('Variable "rawTemplateData" is unexpectly empty.');
}
// ... and compress it
- $compressed = $this->getCompressorInstance()->compressStream($content);
+ $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)));
$packageContent = sprintf(self::PACKAGE_MASK,
// 1.) Compressor's extension
$this->getCompressorInstance()->getCompressorExtension(),
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Setting packageContent=%s ...', $packageContent));
$packageInstance->setPackageContent($packageContent);
$packageInstance->setPackageStatus(self::PACKAGE_STATUS_NEW);
- $packageInstance->setContentHash($this->generatePackageHash($content, $this->getNodeInstance()->getSessionId()));
+ $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
*
* @param $remoteAddr IP address to checkout against our bootstrapping list
* @return $isFound Whether the IP is found
+ * @throws InvalidArgumentException If a parameter is empty
*/
protected function ifAddressMatchesBootstrapNodes (string $remoteAddr) {
+ // Check parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HUB-NODE: remoteAddr=%s - CALLED!', $remoteAddr));
+ if (empty($remoteAddr)) {
+ // Invalid parameter
+ throw new InvalidArgumentException('Parameter "remoteAddr" is empty');
+ }
+
// By default nothing is found
$isFound = FALSE;
// Init info instance
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-REGISTRY: packageInstance=%s - CALLED!', $packageInstance));
$infoInstance = NULL;
- //* DEBUG-DIE: */ die(__METHOD__ . ':packageData=' . print_r($packageData, TRUE));
+ //* DEBUG-DIE: */ die(__METHOD__ . ':packageInstance=' . print_r($packageInstance, TRUE));
// Get all keys and check them
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-REGISTRY: this->instanceRegistry()=%d', count($this->getInstanceRegistry())));