<?php
/**
- * An ??? template engine class for XML templates
+ * An AnnouncementAnswer template engine class for XML templates
*
- * @author Roland Haeder <webmaster@ship-simu.org>
+ * @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
+ * @link http://www.shipsimu.org
* @todo This template engine does not make use of setTemplateType()
*
* This program is free software: you can redistribute it and/or modify
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable {
+class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable {
/**
* Some XML nodes must be available for later data extraction
*/
- const ANNOUNCEMENT_DATA_SESSION_ID = 'my-session-id';
- const ANNOUNCEMENT_DATA_NODE_STATUS = 'my-status';
- const ANNOUNCEMENT_DATA_EXTERNAL_IP = 'my-external-ip';
- const ANNOUNCEMENT_DATA_INTERNAL_IP = 'my-internal-ip';
- const ANNOUNCEMENT_DATA_TCP_PORT = 'my-tcp-port';
- const ANNOUNCEMENT_DATA_UDP_PORT = 'my-udp-port';
- const ANNOUNCEMENT_DATA_ANSWER_STATUS = 'answer-status';
+ const ANNOUNCEMENT_DATA_NODE_ID = 'my-node-id';
+ const ANNOUNCEMENT_DATA_SESSION_ID = 'my-session-id';
+ const ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH = 'my-private-key-hash';
+ const ANNOUNCEMENT_DATA_NODE_STATUS = 'my-status';
+ const ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS = 'my-external-address';
+ const ANNOUNCEMENT_DATA_INTERNAL_ADDRESS = 'my-internal-address';
/**
* Protected constructor
parent::__construct(__CLASS__);
// Init sub-nodes array
- $this->subNodes = array(
+ $this->setSubNodes(array(
// These nodes don't contain any data
'my-data',
'your-data',
// Data from *this* node
- self::ANNOUNCEMENT_DATA_EXTERNAL_IP,
- self::ANNOUNCEMENT_DATA_INTERNAL_IP,
- self::ANNOUNCEMENT_DATA_TCP_PORT,
- self::ANNOUNCEMENT_DATA_UDP_PORT,
+ self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
+ self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
self::ANNOUNCEMENT_DATA_NODE_STATUS,
+ self::ANNOUNCEMENT_DATA_NODE_ID,
self::ANNOUNCEMENT_DATA_SESSION_ID,
+ self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH,
// Data from other node
- 'your-external-ip',
- 'your-internal-ip',
+ 'your-external-address',
+ 'your-internal-address',
+ 'your-node-id',
'your-session-id',
- // Answer status (code)
- self::ANNOUNCEMENT_DATA_ANSWER_STATUS
- );
+ 'your-private-key-hash',
+ // Answer status (generic field)
+ self::ANSWER_STATUS,
+ ));
}
/**
return $templateInstance;
}
- /**
- * Load a specified announcement-answer template into the engine
- *
- * @param $template The announcement-answer template we shall load which is
- * located in 'announcement_answer' by default
- * @return void
- */
- public function loadAnnouncementAnswerTemplate ($template = 'announcement_answer') {
- // Set template type
- $this->setTemplateType($this->getConfigInstance()->getConfigEntry('node_announcement_answer_template_type'));
-
- // Load the special template
- $this->loadTemplate($template);
- }
-
/**
* Currently not used
*
// Is this string empty?
if (empty($characters)) {
// Then skip it silently
- return false;
+ return;
} // END - if
/*
* Assign the found characters to variable and use the last entry from
* stack as the name.
*/
- 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;
+ parent::assignVariable($this->getStackInstance()->getNamed('node_announcement_answer'), $characters);
}
/**
*/
protected function startAnnouncementAnswer () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement_answer', 'announcement-answer');
+ $this->getStackInstance()->pushNamed('node_announcement_answer', 'announcement-answer');
}
/**
*/
protected function startMyData () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement_answer', 'my-data');
+ $this->getStackInstance()->pushNamed('node_announcement_answer', 'my-data');
}
/**
- * Starts the my-external-ip
+ * Starts the my-external-address
*
* @return void
*/
- protected function startMyExternalIp () {
+ protected function startMyExternalAddress () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_EXTERNAL_IP);
+ $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS);
}
/**
- * Starts the my-internal-ip
+ * Starts the my-internal-address
*
* @return void
*/
- protected function startMyInternalIp () {
+ protected function startMyInternalAddress () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_INTERNAL_IP);
+ $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS);
}
/**
- * Starts the my-tcp-port
+ * Starts the my-node-id
*
* @return void
*/
- protected function startMyTcpPort () {
+ protected function startMyNodeId () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_TCP_PORT);
+ $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_NODE_ID);
}
/**
- * Starts the my-udp-port
+ * Starts the my-session-id
*
* @return void
*/
- protected function startMyUdpPort () {
+ protected function startMySessionId () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_UDP_PORT);
+ $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_SESSION_ID);
}
/**
- * Starts the my-session-id
+ * Starts the my-private-key-hash
*
* @return void
*/
- protected function startMySessionId () {
+ protected function startMyPrivateKeyHash () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_SESSION_ID);
+ $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH);
}
/**
*/
protected function startMyStatus () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_NODE_STATUS);
+ $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_NODE_STATUS);
}
/**
*/
protected function finishMyStatus () {
// Pop the last entry
- $this->getStackerInstance()->popNamed('announcement_answer');
+ $this->getStackInstance()->popNamed('node_announcement_answer');
}
/**
- * Finishes the my-session-id
+ * Finishes the my-private-key-hash
*
* @return void
*/
- protected function finishMySessionId () {
+ protected function finishMyPrivateKeyhash () {
// Pop the last entry
- $this->getStackerInstance()->popNamed('announcement_answer');
+ $this->getStackInstance()->popNamed('node_announcement_answer');
}
/**
- * Finishes the my-udp-port
+ * Finishes the my-session-id
*
* @return void
*/
- protected function finishMyUdpPort () {
+ protected function finishMySessionId () {
// Pop the last entry
- $this->getStackerInstance()->popNamed('announcement_answer');
+ $this->getStackInstance()->popNamed('node_announcement_answer');
}
/**
- * Finishes the my-tcp-port
+ * Finishes the my-node-id
*
* @return void
*/
- protected function finishMyTcpPort () {
+ protected function finishMyNodeId () {
// Pop the last entry
- $this->getStackerInstance()->popNamed('announcement_answer');
+ $this->getStackInstance()->popNamed('node_announcement_answer');
}
/**
- * Finishes the my-internal-ip
+ * Finishes the my-internal-address
*
* @return void
*/
- protected function finishMyInternalIp () {
+ protected function finishMyInternalAddress () {
// Pop the last entry
- $this->getStackerInstance()->popNamed('announcement_answer');
+ $this->getStackInstance()->popNamed('node_announcement_answer');
}
/**
- * Finishes the my-external-ip
+ * Finishes the my-external-address
*
* @return void
*/
- protected function finishMyExternalIp () {
+ protected function finishMyExternalAddress () {
// Pop the last entry
- $this->getStackerInstance()->popNamed('announcement_answer');
+ $this->getStackInstance()->popNamed('node_announcement_answer');
}
/**
*/
protected function finishMyData () {
// Pop the last entry
- $this->getStackerInstance()->popNamed('announcement_answer');
+ $this->getStackInstance()->popNamed('node_announcement_answer');
}
/**
*/
protected function startYourData () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement_answer', 'your-data');
+ $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-data');
}
/**
- * Starts the your-external-ip
+ * Starts the your-external-address
*
* @return void
*/
- protected function startYourExternalIp () {
+ protected function startYourExternalAddress () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement_answer', 'your-external-ip');
+ $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-external-address');
}
/**
- * Starts the your-internal-ip
+ * Starts the your-internal-address
*
* @return void
*/
- protected function startYourInternalIp () {
+ protected function startYourInternalAddress () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement_answer', 'your-internal-ip');
+ $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-internal-address');
}
/**
*/
protected function startYourSessionId () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement_answer', 'your-session-id');
+ $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-session-id');
}
/**
- * Finishes the your-session-id
+ * Starts the your-node-id
*
* @return void
*/
- protected function finishYourSessionId () {
+ protected function startYourNodeId () {
+ // Push the node name on the stacker
+ $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-node-id');
+ }
+
+ /**
+ * Starts the your-private-key-hash
+ *
+ * @return void
+ */
+ protected function startYourPrivateKeyHash () {
+ // Push the node name on the stacker
+ $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-private-key-hash');
+ }
+
+ /**
+ * Finishes the your-private-key-hash
+ *
+ * @return void
+ */
+ protected function finishYourPrivateKeyHash () {
// Pop the last entry
- $this->getStackerInstance()->popNamed('announcement_answer');
+ $this->getStackInstance()->popNamed('node_announcement_answer');
}
/**
- * Finishes the your-internal-ip
+ * Finishes the your-node-id
*
* @return void
*/
- protected function finishYourInternalIp () {
+ protected function finishYourNodeId () {
// Pop the last entry
- $this->getStackerInstance()->popNamed('announcement_answer');
+ $this->getStackInstance()->popNamed('node_announcement_answer');
}
/**
- * Finishes the your-external-ip
+ * Finishes the your-session-id
*
* @return void
*/
- protected function finishYourExternalIp () {
+ protected function finishYourSessionId () {
// Pop the last entry
- $this->getStackerInstance()->popNamed('announcement_answer');
+ $this->getStackInstance()->popNamed('node_announcement_answer');
}
/**
- * Finishes the your-data
+ * Finishes the your-internal-address
*
* @return void
*/
- protected function finishYourData () {
+ protected function finishYourInternalAddress () {
// Pop the last entry
- $this->getStackerInstance()->popNamed('announcement_answer');
+ $this->getStackInstance()->popNamed('node_announcement_answer');
}
/**
- * Starts the answer-status
+ * Finishes the your-external-address
*
* @return void
*/
- protected function startAnswerStatus () {
- // Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_ANSWER_STATUS);
+ protected function finishYourExternalAddress () {
+ // Pop the last entry
+ $this->getStackInstance()->popNamed('node_announcement_answer');
}
/**
- * Finishes the answer-status
+ * Finishes the your-data
*
* @return void
*/
- protected function finishAnswerStatus () {
+ protected function finishYourData () {
// Pop the last entry
- $this->getStackerInstance()->popNamed('announcement_answer');
+ $this->getStackInstance()->popNamed('node_announcement_answer');
}
/**
*/
protected function finishAnnouncementAnswer () {
// Pop the last entry
- $this->getStackerInstance()->popNamed('announcement_answer');
+ $this->getStackInstance()->popNamed('node_announcement_answer');
}
}