public function handleFatalMessages (array $messageList) {
// Walk through all messages
foreach ($messageList as $message) {
- die(__METHOD__ . ':MSG:' . $message);
+ exit(__METHOD__ . ':MSG:' . $message);
} // END - foreach
}
/**
* "Getter for address:port combination
*
- * @param $handlerInstance A valid Networkable instance
+ * @param $handlerInstance An instance of a Networkable class
* @return $addressPort A address:port combination for this node
*/
function getAddressPort (Networkable $handlerInstance);
// Return result
return $stateName;
}
+
+ /**
+ * Checks whether start/end marker are set
+ *
+ * @param $data Data to be checked
+ * @return $isset Whether start/end marker are set
+ */
+ public final function ifStartEndMarkerSet ($data) {
+ // Determine it
+ $isset = ((substr($data, 0, strlen(BaseRawDataHandler::STREAM_START_MARKER)) == BaseRawDataHandler::STREAM_START_MARKER) && (substr($data, -1 * strlen(BaseRawDataHandler::STREAM_END_MARKER), strlen(BaseRawDataHandler::STREAM_END_MARKER)) == BaseRawDataHandler::STREAM_END_MARKER));
+
+ // ... and return it
+ return $isset;
+ }
}
// [EOF]
$cruncherInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance);
} catch (ClassNotFoundException $e) {
// This exception means, the cruncher mode is invalid.
- // @TODO Can we rewrite this to app_die() ?
+ // @TODO Can we rewrite this to app_exit() ?
$this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: cruncher mode ' . $cruncherMode . ' is invalid.');
}
$nodeInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance);
} catch (ClassNotFoundException $e) {
// This exception means, the node mode is invalid.
- // @TODO Can we rewrite this to app_die() ?
+ // @TODO Can we rewrite this to app_exit() ?
$this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: node mode ' . $nodeMode . ' is invalid.');
}
private function preparePackageAssmble () {
// Make sure both arrays have same count (this however should always be true)
assert(count($this->finalPackageChunks['hashes']) == count($this->finalPackageChunks['content']));
- //* DIE: */ die(__METHOD__ . ':finalPackageChunks='.print_r($this->finalPackageChunks['content'],true));
+ //* DIE: */ exit(__METHOD__ . ':finalPackageChunks='.print_r($this->finalPackageChunks['content'],true));
/*
* Remove last element (hash chunk) from 'hashes'. This hash will never
const PACKAGE_RAW_DATA = 'raw_data';
const PACKAGE_ERROR_CODE = 'error_code';
+ // Start/end marker
+ const STREAM_START_MARKER = '[[S]]';
+ const STREAM_EN_MARKER = '[[E]]';
+
/**
* Stacker for raw data
*/
/**
* "Getter" for address:port combination
*
- * @param $handlerInstance A valid Networkable instance
+ * @param $handlerInstance An instance of a Networkable class
* @return $addressPort A address:port combination for this node
*/
public final function getAddressPort (Networkable $handlerInstance) {
* @return void
*/
public function handleAnswerStatusByMessageData (array $messageData) {
- die('messageData=' . print_r($messageData, true));
+ exit('messageData=' . print_r($messageData, true));
}
}
$assemblerInstance->setPackageInstance($packageInstance);
// Create an instance of a raw data input stream
- $streamInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_input_stream_class', array($packageInstance));
+ $streamInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_input_stream_class');
// And set it
$assemblerInstance->setInputStreamInstance($streamInstance);
*/
private function isPackageContentCompleted (array $packageContent) {
// Check both
- $isCompleted = ((substr($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA], 0, 5) == '[[S]]') && (substr($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA], -5, 5) == '[[E]]'));
+ $isCompleted = $this->ifStartEndMarkerSet($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]);
// Return status
return $isCompleted;
// 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);
// 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));
}
/**
* @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
*/
/**
* Creates an instance of this node class
*
- * @param $handlerInstance An instance of a Networkable class
* @return $streamInstance An instance of this node class
*/
- public final static function createRawDataInputStream (Networkable $handlerInstance) {
+ public final static function createRawDataInputStream () {
// Get a new instance
$streamInstance = new RawDataInputStream();
*/
public function streamData ($data) {
// Do we have start and end marker again?
- assert((substr($data, 0, 5) == '[[S]]') && (substr($data, -5, 5) == '[[E]]'));
+ assert($this->ifStartEndMarkerSet($data));
// Remove both
- $data = substr($data, 6 - 5);
+ $data = substr($data, strlen(BaseRawDataHandler::STREAM_START_MARKER), -1 * strlen(BaseRawDataHandler::STREAM_END_MARKER));
// Can it be validated?
if ((strlen($data) % 4) != 0) {
// Length modulo 4 must be zero, else it is an invalid Base64 message
- $this->getHandlerInstance()->setErrorCode(BaseRawDataHandler::SOCKET_ERROR_INVALID_BASE64_MODULO);
+ $handlerInstance->setErrorCode(BaseRawDataHandler::SOCKET_ERROR_INVALID_BASE64_MODULO);
$data = false;
} elseif (!$this->isBase64Encoded($data)) {
// Is not a valid Base64-encoded message
- $this->getHandlerInstance()->setErrorCode(BaseRawDataHandler::SOCKET_ERROR_INVALID_BASE64_MESSAGE);
+ $handlerInstance->setErrorCode(BaseRawDataHandler::SOCKET_ERROR_INVALID_BASE64_MESSAGE);
$data = false;
} else {
// Decode the data with BASE64-encoding
*
* @param $data The data (string mostly) to "stream"
* @return $data The data (string mostly) to "stream"
- * @todo Do we need to do something more here?
*/
public function streamData ($data) {
/*
* [[S]] - Start marker
* [[E]] - End marker
*/
- $data = '[[S]]' . base64_encode($data) . '[[E]]';
+ $data = BaseRawDataHandler::STREAM_START_MARKER . base64_encode($data) . BaseRawDataHandler::STREAM_END_MARKER;
// Return it
return $data;
// Some sanity checks
if ((empty($app)) || (is_null($app))) {
// Something went wrong!
- ApplicationEntryPoint::app_die(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because the helper class <span class=\"class_name\">%s</span> is not loaded.",
+ ApplicationEntryPoint::app_exit(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because the helper class <span class=\"class_name\">%s</span> is not loaded.",
$application,
FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class')
));
} elseif (!is_object($app)) {
// No object!
- ApplicationEntryPoint::app_die(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because 'app' is not an object.",
+ ApplicationEntryPoint::app_exit(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because 'app' is not an object.",
$application
));
} elseif (!method_exists($app, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method'))) {
// Method not found!
- ApplicationEntryPoint::app_die(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because the method <span class=\"method_name\">%s</span> is missing.",
+ ApplicationEntryPoint::app_exit(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because the method <span class=\"method_name\">%s</span> is missing.",
$application,
FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method')
));
'debug', // Debug output
'db', // Database layer
'io', // Base I/O system (local file [or network])
- 'engine', // Template engine ( for ApplicationEntryPoint::app_die() )
+ 'engine', // Template engine ( for ApplicationEntryPoint::app_exit() )
'lang', // Language sub-system
'app', // The ApplicationHelper instance
);
* @return void
* @todo This method is old code and needs heavy rewrite and should be moved to ApplicationHelper
*/
- public static final function app_die ($message = '', $code = false, $extraData = '', $silentMode = false) {
+ public static final function app_exit ($message = '', $code = false, $extraData = '', $silentMode = false) {
// Is this method already called?
if (isset($GLOBALS['app_die_called'])) {
// Then output the text directly
- die($message);
+ exit($message);
} // END - if
// This method shall not be called twice
// Do we have debug installation?
if (($configInstance->getConfigEntry('product_install_mode') == 'productive') || ($silentMode === true)) {
// Abort here
- die();
+ exit();
} // END - if
// Get some instances
// Get the template instance from our object factory
$templateInstance = ObjectFactory::createObjectByName($tpl);
} catch (FrameworkException $e) {
- die(sprintf("[Main:] Could not initialize template engine for reason: <span class=\"exception_reason\">%s</span>",
+ exit(sprintf("[Main:] Could not initialize template engine for reason: <span class=\"exception_reason\">%s</span>",
$e->getMessage()
));
}
$responseInstance->flushBuffer();
} catch (FileIoException $e) {
// Even the template 'emergency_exit' wasn't found so output both message
- die($message . ', exception: ' . $e->getMessage());
+ exit($message . ', exception: ' . $e->getMessage());
}
// Good bye...
exit();
} else {
// Output message and die
- die(sprintf("[Main:] Emergency exit reached: <span class=\"emergency_span\">%s</span>",
+ exit(sprintf("[Main:] Emergency exit reached: <span class=\"emergency_span\">%s</span>",
$message
));
}