3 namespace CoreFramework\Information\Connection;
5 // Import framework stuff
6 use CoreFramework\Information\BaseInfo;
7 use CoreFramework\Information\ShareableInfo;
8 use CoreFramework\Listener\Listenable;
9 use CoreFramework\Registry\Registerable;
12 * A Connection information class
14 * @author Roland Haeder <webmaster@ship-simu.org>
16 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
17 * @license GNU GPL 3.0 or any newer version
18 * @link http://www.ship-simu.org
20 * This program is free software: you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation, either version 3 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program. If not, see <http://www.gnu.org/licenses/>.
33 class ConnectionInfo extends BaseInfo implements ShareableInfo, Registerable {
35 * Protected constructor
39 protected function __construct () {
40 // Call parent constructor
41 parent::__construct(__CLASS__);
45 * Creates an instance of this class
47 * @return $infoInstance An instance of a ShareableInfo class
49 public final static function createConnectionInfo () {
51 $infoInstance = new ConnectionInfo();
53 // Return the prepared instance
58 * Fills the information class with data from a Listenable instance
60 * @param $listenerInstance An instance of a Listenable class
63 public function fillWithListenerInformation (Listenable $listenerInstance) {
65 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $listenerInstance->getProtocolName() . ',listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!');
67 // Fill the generic array with several data from the listener:
68 $this->setProtocolName($listenerInstance->getProtocolName());
69 $this->setGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_ADDRESS , $listenerInstance->getListenAddress());
70 $this->setGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_PORT , $listenerInstance->getListenPort());
73 $this->setListenerInstance($listenerInstance);
76 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
80 * Fills the information class with data from a ConnectionHelper instance
82 * @param $helperInstance An instance of a ConnectionHelper class
85 public function fillWithConnectionHelperInformation (ConnectionHelper $helperInstance) {
87 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $helperInstance->getProtocolName() . ',helperInstance=' . $helperInstance->__toString() . ',socketResource=' . $helperInstance->getSocketResource() . ' - CALLED!');
89 // Fill the generic array with several data from the listener:
90 $this->setProtocolName($helperInstance->getProtocolName());
91 $this->setGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_ADDRESS , $helperInstance->getAddress());
92 $this->setGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_PORT , $helperInstance->getConnectionPort());
95 $this->setHelperInstance($helperInstance);
98 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
104 * @return $address Address from shared information
106 public final function getAddress () {
107 // Return it from generic array
108 return $this->getGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_ADDRESS);
114 * @return $port Port from shared information
116 public final function getPort () {
117 // Return it from generic array
118 return $this->getGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_PORT);