use Org\Shipsimu\Hub\Information\ShareableInfo;
use Org\Shipsimu\Hub\Listener\Listenable;
use Org\Shipsimu\Hub\Locator\Node\LocateableNode;
+use Org\Shipsimu\Hub\Node\Node;
use Org\Shipsimu\Hub\Pool\Poolable;
// Import framework stuff
*/
private $infoInstance = NULL;
+ /**
+ * Node instance
+ */
+ private $nodeInstance = NULL;
+
/**
* A StorableSocket instance
*/
return $this->listenerInstance;
}
+ /**
+ * Setter for node instance
+ *
+ * @param $nodeInstance A Node instance
+ * @return void
+ */
+ public final function setNodeInstance (Node $nodeInstance) {
+ $this->nodeInstance = $nodeInstance;
+ }
+
+ /**
+ * Getter for node instance
+ *
+ * @return $nodeInstance A Node instance
+ */
+ public function getNodeInstance () {
+ return $this->nodeInstance;
+ }
+
}
// Get node instance
$nodeInstance = NodeObjectFactory::createNodeInstance();
+ // Set it locally
+ $packageInstance->setNodeInstance($nodeInstance);
+
// Get pool instance from node
$poolInstance = $nodeInstance->getListenerPoolInstance();
* @return $hash Hash for given package content
*/
private function getHashFromContent ($content) {
- // Get node instance
- $nodeInstance = NodeObjectFactory::createNodeInstance();
-
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($content) . ',sender=' . $nodeInstance->getSessionId() . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($content) . ',sender=' . $this->getNodeInstance()->getSessionId() . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
// Create the hash
// @TODO md5() is very weak, but it needs to be fast
$hash = md5(
$content .
self::PACKAGE_CHECKSUM_SEPARATOR .
- $nodeInstance->getSessionId() .
+ $this->getNodeInstance()->getSessionId() .
self::PACKAGE_CHECKSUM_SEPARATOR .
$this->getCompressorInstance()->getCompressorExtension()
);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($content) . ',sender=' . $nodeInstance->getSessionId() . ',hash=' . $hash . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($content) . ',sender=' . $this->getNodeInstance()->getSessionId() . ',hash=' . $hash . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
// And return it
return $hash;
$data = array(
self::PACKAGE_CONTENT_SENDER => $senderId,
self::PACKAGE_CONTENT_MESSAGE => $content,
- self::PACKAGE_CONTENT_PRIVATE_KEY_HASH => $this->getPrivateKeyHash(),
+ self::PACKAGE_CONTENT_PRIVATE_KEY_HASH => $this->getNodeInstance()->getPrivateKeyHash(),
);
// Hash content and sender id together, use scrypt
// Make sure required data is there
assert(!empty($content));
- assert($nodeInstance->getSessionId() != '');
+ assert($this->getNodeInstance()->getSessionId() != '');
// Init package instance
$packageInstance = PackageDataFactory::createPackageDataInstance();
- // Get node instance
- $nodeInstance = NodeObjectFactory::createNodeInstance();
-
// Set all data
- $packageInstance->setSenderAddress($nodeInstance->getSessionId());
+ $packageInstance->setSenderAddress($this->getNodeInstance()->getSessionId());
$packageInstance->setSenderPort('0');
$packageInstance->setRecipientType($helperInstance->getRecipientType());
$packageInstance->setPackageContent($packageContent);
$packageInstance->setStatus(self::PACKAGE_STATUS_NEW);
- $packageInstance->setContentHash($this->generatePackageHash($content, $nodeInstance->getSessionId()));
- $packageInstance->setPrivateKeyHash($this->getPrivateKeyHash());
+ $packageInstance->setContentHash($this->generatePackageHash($content, $this->getNodeInstance()->getSessionId()));
+ $packageInstance->setPrivateKeyHash($this->getNodeInstance()->getPrivateKeyHash());
// Now prepare the temporary array and push it on the 'undeclared' stack
$this->getStackInstance()->pushNamed(self::STACKER_NAME_UNDECLARED, $packageInstance);