* @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 BaseHubSystem extends BaseFrameworkSystem { // Exception codes const EXCEPTION_CHUNK_ALREADY_ASSEMBLED = 0x900; const EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED = 0x901; const EXCEPTION_INVALID_CONNECTION_TYPE = 0x902; const EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED = 0x903; const EXCEPTION_BASE64_ENCODING_NOT_MODULO_4 = 0x904; const EXCEPTION_NODE_SESSION_ID_NOT_VERIFYING = 0x905; const EXCEPTION_REQUEST_NOT_ACCEPTED = 0x906; const EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED = 0x907; const EXCEPTION_MULTIPLE_MESSAGE_SENT = 0x908; const EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED = 0x909; const EXCEPTION_INVALID_UNL = 0x90a; const EXCEPTION_INVALID_PRIVATE_KEY_HASH = 0x90b; // Message status codes const MESSAGE_STATUS_CODE_OKAY = 'OKAY'; /** * Separator for all bootstrap node entries */ const BOOTSTRAP_NODES_SEPARATOR = ';'; /** * An instance of a node */ private $nodeInstance = NULL; /** * A network package handler instance */ private $packageInstance = NULL; /** * A Receivable instance */ private $receiverInstance = NULL; /** * Listener pool instance */ private $listenerPoolInstance = NULL; /** * Fragmenter instance */ private $fragmenterInstance = NULL; /** * Assembler instance */ private $assemblerInstance = NULL; /** * Info instance */ private $infoInstance = NULL; /** * Protected constructor * * @param $className Name of the class * @return void */ protected function __construct ($className) { // Call parent constructor parent::__construct($className); } /** * Setter for network package handler instance * * @param $packageInstance The network package instance we shall set * @return void */ protected final function setPackageInstance (Deliverable $packageInstance) { $this->packageInstance = $packageInstance; } /** * Getter for network package handler instance * * @return $packageInstance The network package handler instance we shall set */ protected final function getPackageInstance () { return $this->packageInstance; } /** * Setter for receiver instance * * @param $receiverInstance A Receivable instance we shall set * @return void */ protected final function setReceiverInstance (Receivable $receiverInstance) { $this->receiverInstance = $receiverInstance; } /** * Getter for receiver instance * * @return $receiverInstance A Receivable instance we shall get */ protected final function getReceiverInstance () { return $this->receiverInstance; } /** * Setter for listener pool instance * * @param $listenerPoolInstance The new listener pool instance * @return void */ protected final function setListenerPoolInstance (PoolableListener $listenerPoolInstance) { $this->listenerPoolInstance = $listenerPoolInstance; } /** * Getter for listener pool instance * * @return $listenerPoolInstance Our current listener pool instance */ public final function getListenerPoolInstance () { return $this->listenerPoolInstance; } /** * Setter for fragmenter instance * * @param $fragmenterInstance A Fragmentable instance * @return void */ protected final function setFragmenterInstance (Fragmentable $fragmenterInstance) { $this->fragmenterInstance = $fragmenterInstance; } /** * Getter for fragmenter instance * * @return $fragmenterInstance A Fragmentable instance */ protected final function getFragmenterInstance () { return $this->fragmenterInstance; } /** * Setter for assembler instance * * @param $assemblerInstance An instance of an Assembler class * @return void */ protected final function setAssemblerInstance (Assembler $assemblerInstance) { $this->assemblerInstance = $assemblerInstance; } /** * Getter for assembler instance * * @return $assemblerInstance An instance of an Assembler class */ protected final function getAssemblerInstance () { return $this->assemblerInstance; } /** * Setter for info instance * * @param $infoInstance A ShareableInfo instance * @return void */ protected final function setInfoInstance (ShareableInfo $infoInstance) { $this->infoInstance = $infoInstance; } /** * Getter for info instance * * @return $infoInstance An instance of a ShareableInfo class */ public final function getInfoInstance () { return $this->infoInstance; } /** * Setter for node id * * @param $nodeId The new node id * @return void */ protected final function setNodeId ($nodeId) { // Set it config now $this->getConfigInstance()->setConfigEntry('node_id', (string) $nodeId); } /** * Getter for node id * * @return $nodeId Current node id */ public final function getNodeId () { // Get it from config return $this->getConfigInstance()->getConfigEntry('node_id'); } /** * Setter for private key * * @param $privateKey The new private key * @return void */ protected final function setPrivateKey ($privateKey) { // Set it config now $this->getConfigInstance()->setConfigEntry('private_key', (string) $privateKey); } /** * Getter for private key * * @return $privateKey Current private key */ public final function getPrivateKey () { // Get it from config return $this->getConfigInstance()->getConfigEntry('private_key'); } /** * Setter for private key hash * * @param $privateKeyHash The new private key hash * @return void */ protected final function setPrivateKeyHash ($privateKeyHash) { // Set it config now $this->getConfigInstance()->setConfigEntry('private_key_hash', (string) $privateKeyHash); } /** * Getter for private key hash * * @return $privateKeyHash Current private key hash */ public final function getPrivateKeyHash () { // Get it from config return $this->getConfigInstance()->getConfigEntry('private_key_hash'); } /** * Setter for session id * * @param $sessionId The new session id * @return void */ protected final function setSessionId ($sessionId) { $this->getConfigInstance()->setConfigEntry('session_id', (string) $sessionId); } /** * Getter for session id * * @return $sessionId Current session id */ public final function getSessionId () { return $this->getConfigInstance()->getConfigEntry('session_id'); } } // [EOF] ?>