const PACKAGE_RECIPIENT_SEPARATOR = ':';
/**
- * Network target (alias): 'upper hubs'
+ * Network target (alias): 'upper nodes'
*/
- const NETWORK_TARGET_UPPER_HUBS = 'upper';
+ const NETWORK_TARGET_UPPER_NODES = 'upper';
/**
* Network target (alias): 'self'
// Init all stacker
$packageInstance->initStackers();
- // Get a visitor instance for speeding up things
+ // Get a visitor instance for speeding up things and set it
$visitorInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_monitor_visitor_class', array($packageInstance));
-
- // Set it in this package
$packageInstance->setVisitorInstance($visitorInstance);
- // Get crypto instance and set it in this package
+ // Get crypto instance and set it, too
$cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
$packageInstance->setCryptoInstance($cryptoInstance);
- // Get a singleton package assembler instance from factory and set it here
+ // Get a singleton package assembler instance from factory and set it here, too
$assemblerInstance = PackageAssemblerFactory::createAssemblerInstance($packageInstance);
$packageInstance->setAssemblerInstance($assemblerInstance);
/**
* "Getter" for hash from given content and sender's session id
*
- * @param $decodedContent Decoded package content
+ * @param $decodedContent Raw package content
* @param $sessionId Session id of the sender
* @return $hash Hash for given package content
*/
// Is it the same?
//$isSignatureValid =
- die(__METHOD__.': signature='.$signature.chr(10).',decodedArray='.print_r($decodedArray,true));
+ exit(__METHOD__.': signature='.$signature.chr(10).',decodedArray='.print_r($decodedArray,true));
}
/**
*
* @return $isPending Whether decoded raw data is pending
*/
- private function isDecodedDataPending () {
+ private function isRawDataPending () {
// Just return whether the stack is not empty
$isPending = (!$this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_DECODED_INCOMING));
$poolInstance->accept($this->getVisitorInstance());
// Check for new data arrival
- $hasArrived = $this->isDecodedDataPending();
+ $hasArrived = $this->isRawDataPending();
// Return the status
return $hasArrived;
* This method should only be called if decoded raw data is pending,
* so check it again.
*/
- if (!$this->isDecodedDataPending()) {
+ if (!$this->isRawDataPending()) {
// This is not fatal but should be avoided
// @TODO Add some logging here
return;
// Make sure both array elements are there
assert(
(is_array($decodedData)) &&
- (isset($decodedData[BaseRawDataHandler::PACKAGE_DECODED_DATA])) &&
+ (isset($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA])) &&
(isset($decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE]))
);
assert($decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] == BaseRawDataHandler::SOCKET_ERROR_UNHANDLED);
// Remove the last chunk SEPARATOR (because it is being added and we don't need it)
- if (substr($decodedData[BaseRawDataHandler::PACKAGE_DECODED_DATA], -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) {
+ if (substr($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA], -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) {
// It is there and should be removed
- $decodedData[BaseRawDataHandler::PACKAGE_DECODED_DATA] = substr($decodedData[BaseRawDataHandler::PACKAGE_DECODED_DATA], 0, -1);
+ $decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA] = substr($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA], 0, -1);
} // END - if
// This package is "handled" and can be pushed on the next stack
* @param $handlerInstance An instance of a Networkable class
* @return void
*/
- public function addDecodedDataToIncomingStack (Networkable $handlerInstance) {
+ public function addRawDataToIncomingStack (Networkable $handlerInstance) {
/*
* Get the decoded data from the handler, this is an array with
- * 'decoded_data' and 'error_code' as elements.
+ * 'raw_data' and 'error_code' as elements.
*/
- $decodedData = $handlerInstance->getNextDecodedData();
+ $decodedData = $handlerInstance->getNextRawData();
// Very noisy debug message:
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE: decodedData[' . gettype($decodedData) . ']=' . print_r($decodedData, true));
*
* @return $isHandled Whether incoming decoded data is handled
*/
- public function isIncomingDecodedDataHandled () {
+ public function isIncomingRawDataHandled () {
// Determine if the stack is not empty
$isHandled = (!$this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_DECODED_HANDLED));
*/
public function assembleDecodedDataToPackage () {
// Make sure the raw decoded package data is handled
- assert($this->isIncomingDecodedDataHandled());
+ assert($this->isIncomingRawDataHandled());
// Get current package content (an array with two elements; see handleIncomingDecodedData() for details)
$packageContent = $this->getStackerInstance()->getNamed(self::STACKER_NAME_DECODED_HANDLED);
* @todo Unsupported feature of "signed" messages commented out
if (!$this->isPackageSignatureValid($decodedArray)) {
// Is not valid, so throw an exception here
- die(__METHOD__ . ':INVALID SIG! UNDER CONSTRUCTION!' . chr(10));
+ exit(__METHOD__ . ':INVALID SIG! UNDER CONSTRUCTION!' . chr(10));
} // END - if
*/
* @return void
* @throws InvalidDataChecksumException If the checksum doesn't match
*/
- public function handleDecodedData (array $decodedData) {
+ public function handleRawData (array $decodedData) {
/*
* "Decode" the package's content by a simple explode() call, for
* details of the array elements, see comments for constant
// Create a handler instance from given message type
$handlerInstance = MessageTypeHandlerFactory::createMessageTypeHandlerInstance($messageArray[self::MESSAGE_ARRAY_TYPE]);
+ // Add type for later easier handling
+ $messageArray[self::MESSAGE_ARRAY_DATA][self::MESSAGE_ARRAY_TYPE] = $messageArray[self::MESSAGE_ARRAY_TYPE];
+
// Handle message data
$handlerInstance->handleMessageData($messageArray[self::MESSAGE_ARRAY_DATA], $this);
}