* @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ class RequestNodeListAnswerOkayHandler extends BaseAnserStatusHandler implements HandleableAnswerStatus, Registerable { /** * Protected constructor * * @return void */ protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); // Init array $this->searchData = array( XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID, ); // Set handler name $this->setHandlerName('request_node_list_answer_okay'); } /** * Creates an instance of this class * * @return $handlerInstance An instance of a HandleableMessage class */ public final static function createRequestNodeListAnswerOkayHandler () { // Get new instance $handlerInstance = new RequestNodeListAnswerOkayHandler(); // Return the prepared instance return $handlerInstance; } /** * Handles given message data array * * @param $messageData An array of message data * @param $packageInstance An instance of a Receivable class * @return void * @throws NodeSessionIdVerficationException If the provided session id is not matching * @todo Do some more here: Handle karma, et cetera? */ public function handleAnswerMessageData (array $messageData, Receivable $packageInstance) { // Make sure node-list is found in array assert(isset($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST])); // Save node list $nodeList = unserialize(base64_decode($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST])); // Make sure it is completely decoded assert(is_array($nodeList)); // ... and remove it as it should not be included now unset($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST]); // Write node list to DHT $this->getDhtInstance()->insertNodeList($nodeList); /* * Query DHT and force update (which will throw an exception if the * node is not found). */ $this->getDhtInstance()->registerNodeByMessageData($messageData, $this, TRUE); // Prepare next message ("hello" message to all returned nodes) //$this->prepareNextMessage($messageData, $packageInstance); } /** * Initializes configuration data from given message data array * * The following array is being handled over: * * session-id => aaabbbcccdddeeefff123456789 * node-list => aabb:ccdd:eeff * answer-status => OKAY * message_type => request_node_list_answer * * @param $messageData An array with all message data * @return void * @todo 0% done */ protected function initMessageConfigurationData (array $messageData) { $this->partialStub('Please implement this method.'); } /** * Removes configuration data with given message data array from global * configuration. For content of $messageData see method comment above. * * @param $messageData An array with all message data * @return void * @todo 0% done */ protected function removeMessageConfigurationData (array $messageData) { $this->partialStub('Please implement this method.'); } } // [EOF] ?>