From 2fc854101a7c2e7ef527f92339665e9ce892dc7e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 20 May 2012 12:30:20 +0000 Subject: [PATCH] Renamed all 'node-foo' to 'my-foo' and 'other-bar' to 'your-bar' to make them more clear --- ...ass_PackageAnnouncementAnswerTagFilter.php | 3 + ...s_NodeMessageAnnouncementAnswerHandler.php | 2 +- ...ss_XmlAnnouncementAnswerTemplateEngine.php | 147 ++++++++++-------- .../announcement/announcement_answer.xml | 26 ++-- 4 files changed, 98 insertions(+), 80 deletions(-) diff --git a/application/hub/main/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php b/application/hub/main/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php index 43d5df34b..f0d6bf520 100644 --- a/application/hub/main/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php +++ b/application/hub/main/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php @@ -90,6 +90,9 @@ class PackageAnnouncementAnswerTagFilter extends BaseFilter implements Filterabl * @todo Exceptions from renderXmlContent() are currently unhandled */ public function processMessage ($messageContent, Receivable $packageInstance) { + // Debug message + /* NOISY-DEBUG: */ $this->debugOutput('ANNOUNCEMENT-ANSWER-TAG: messageContent(' . strlen($messageContent) . ')=' . $messageContent); + // Get a template instance from the factory $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_announcement_answer_template_class'); diff --git a/application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php b/application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php index 1ca0e411e..540f5279b 100644 --- a/application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php +++ b/application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php @@ -64,7 +64,7 @@ class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements * @return void */ public function handleMessageData (array $messageData, Receivable $packageInstance) { - die('messageData=' . print_r($messageData, true); + die('messageData=' . print_r($messageData, true)); // Register the announcing node with this node $this->registerNodeByMessageData($messageData); } diff --git a/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php b/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php index d8fdc010f..3ec35f132 100644 --- a/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php +++ b/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php @@ -35,19 +35,19 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseTemplateEngine implements */ private $subNodes = array( // These nodes don't contain any data - 'node-data', - 'other-data', + 'my-data', + 'your-data', // Data from *this* node - 'node-external-ip', - 'node-internal-ip', - 'node-tcp-port', - 'node-udp-port', - 'node-session-id', - 'node-status', + 'my-external-ip', + 'my-internal-ip', + 'my-tcp-port', + 'my-udp-port', + 'my-session-id', + 'my-status', // Data from other node - 'other-external-ip', - 'other-internal-ip', - 'other-session-id', + 'your-external-ip', + 'your-internal-ip', + 'your-session-id', // Answer status (code) 'answer-status' ); @@ -263,6 +263,21 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseTemplateEngine implements parent::assignVariable($this->getStackerInstance()->getNamed('announcement_answer'), $characters); } + /** + * Read announcement-answer variables by calling readVariable() with 'general' as + * variable stack. + * + * @param $key Key to read from + * @return $value Value from variable + */ + public function readAnnouncementAnswerData ($key) { + // Read the variable + $value = parent::readVariable($key, 'general'); + + // Return value + return $value; + } + /** * Getter for cache file (FQFN) * @@ -283,221 +298,221 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseTemplateEngine implements } /** - * Starts the node-data + * Starts the my-data * * @return void */ - private function startNodeData () { + private function startMyData () { // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('announcement_answer', 'node-data'); + $this->getStackerInstance()->pushNamed('announcement_answer', 'my-data'); } /** - * Starts the node-external-ip + * Starts the my-external-ip * * @return void */ - private function startNodeExternalIp () { + private function startMyExternalIp () { // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('announcement_answer', 'node-external-ip'); + $this->getStackerInstance()->pushNamed('announcement_answer', 'my-external-ip'); } /** - * Starts the node-internal-ip + * Starts the my-internal-ip * * @return void */ - private function startNodeInternalIp () { + private function startMyInternalIp () { // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('announcement_answer', 'node-internal-ip'); + $this->getStackerInstance()->pushNamed('announcement_answer', 'my-internal-ip'); } /** - * Starts the node-tcp-port + * Starts the my-tcp-port * * @return void */ - private function startNodeTcpPort () { + private function startMyTcpPort () { // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('announcement_answer', 'node-tcp-port'); + $this->getStackerInstance()->pushNamed('announcement_answer', 'my-tcp-port'); } /** - * Starts the node-udp-port + * Starts the my-udp-port * * @return void */ - private function startNodeUdpPort () { + private function startMyUdpPort () { // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('announcement_answer', 'node-udp-port'); + $this->getStackerInstance()->pushNamed('announcement_answer', 'my-udp-port'); } /** - * Starts the node-session-id + * Starts the my-session-id * * @return void */ - private function startNodeSessionId () { + private function startMySessionId () { // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('announcement_answer', 'node-session-id'); + $this->getStackerInstance()->pushNamed('announcement_answer', 'my-session-id'); } /** - * Starts the node-status + * Starts the my-status * * @return void */ - private function startNodeStatus () { + private function startMyStatus () { // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('announcement_answer', 'node-status'); + $this->getStackerInstance()->pushNamed('announcement_answer', 'my-status'); } /** - * Finishes the node-status + * Finishes the my-status * * @return void */ - private function finishNodeStatus () { + private function finishMyStatus () { // Pop the last entry $this->getStackerInstance()->popNamed('announcement_answer'); } /** - * Finishes the node-session-id + * Finishes the my-session-id * * @return void */ - private function finishNodeSessionId () { + private function finishMySessionId () { // Pop the last entry $this->getStackerInstance()->popNamed('announcement_answer'); } /** - * Finishes the node-udp-port + * Finishes the my-udp-port * * @return void */ - private function finishNodeUdpPort () { + private function finishMyUdpPort () { // Pop the last entry $this->getStackerInstance()->popNamed('announcement_answer'); } /** - * Finishes the node-tcp-port + * Finishes the my-tcp-port * * @return void */ - private function finishNodeTcpPort () { + private function finishMyTcpPort () { // Pop the last entry $this->getStackerInstance()->popNamed('announcement_answer'); } /** - * Finishes the node-internal-ip + * Finishes the my-internal-ip * * @return void */ - private function finishNodeInternalIp () { + private function finishMyInternalIp () { // Pop the last entry $this->getStackerInstance()->popNamed('announcement_answer'); } /** - * Finishes the node-external-ip + * Finishes the my-external-ip * * @return void */ - private function finishNodeExternalIp () { + private function finishMyExternalIp () { // Pop the last entry $this->getStackerInstance()->popNamed('announcement_answer'); } /** - * Finishes the node-data + * Finishes the my-data * * @return void */ - private function finishNodeData () { + private function finishMyData () { // Pop the last entry $this->getStackerInstance()->popNamed('announcement_answer'); } /** - * Starts the other-data + * Starts the your-data * * @return void */ - private function startOtherData () { + private function startYourData () { // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('announcement_answer', 'other-data'); + $this->getStackerInstance()->pushNamed('announcement_answer', 'your-data'); } /** - * Starts the other-external-ip + * Starts the your-external-ip * * @return void */ - private function startOtherExternalIp () { + private function startYourExternalIp () { // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('announcement_answer', 'other-external-ip'); + $this->getStackerInstance()->pushNamed('announcement_answer', 'your-external-ip'); } /** - * Starts the other-internal-ip + * Starts the your-internal-ip * * @return void */ - private function startOtherInternalIp () { + private function startYourInternalIp () { // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('announcement_answer', 'other-internal-ip'); + $this->getStackerInstance()->pushNamed('announcement_answer', 'your-internal-ip'); } /** - * Starts the other-session-id + * Starts the your-session-id * * @return void */ - private function startOtherSessionId () { + private function startYourSessionId () { // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('announcement_answer', 'other-session-id'); + $this->getStackerInstance()->pushNamed('announcement_answer', 'your-session-id'); } /** - * Finishes the other-session-id + * Finishes the your-session-id * * @return void */ - private function finishOtherSessionId () { + private function finishYourSessionId () { // Pop the last entry $this->getStackerInstance()->popNamed('announcement_answer'); } /** - * Finishes the other-internal-ip + * Finishes the your-internal-ip * * @return void */ - private function finishOtherInternalIp () { + private function finishYourInternalIp () { // Pop the last entry $this->getStackerInstance()->popNamed('announcement_answer'); } /** - * Finishes the other-external-ip + * Finishes the your-external-ip * * @return void */ - private function finishOtherExternalIp () { + private function finishYourExternalIp () { // Pop the last entry $this->getStackerInstance()->popNamed('announcement_answer'); } /** - * Finishes the other-data + * Finishes the your-data * * @return void */ - private function finishOtherData () { + private function finishYourData () { // Pop the last entry $this->getStackerInstance()->popNamed('announcement_answer'); } diff --git a/application/hub/templates/xml/answer/announcement/announcement_answer.xml b/application/hub/templates/xml/answer/announcement/announcement_answer.xml index 9360edd83..7694b4449 100644 --- a/application/hub/templates/xml/answer/announcement/announcement_answer.xml +++ b/application/hub/templates/xml/answer/announcement/announcement_answer.xml @@ -26,50 +26,50 @@ along with this program. If not, see - + - {?external_ip?} + {?external_ip?} - {?internal_ip?} + {?internal_ip?} - {?node_tcp_listen_port?} + {?node_tcp_listen_port?} - {?node_udp_listen_port?} + {?node_udp_listen_port?} - {?session_id?} + {?session_id?} - {?node_status?} - + {?node_status?} + - + - {?other_external_ip?} + {?your_external_ip?} - {?other_internal_ip?} + {?your_internal_ip?} - {?other_session_id?} - + {?your_session_id?} +