*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 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.shipsimu.org
*
return $discoveryInstance;
}
+ /**
+ * Determines the protoctol name
+ *
+ * @param $packageData Valid package data
+ * @return $protocolInstance An instance of a HandleableProtocol class
+ */
+ public static final function determineProtocolByPackageData (array $packageData) {
+ // First we need a tags instance
+ $tagsInstance = PackageTagsFactory::createPackageTagsInstance();
+
+ /*
+ * We need to decide here which socket (TCP or UDP) should be used for
+ * the actual data transmission. In this process we will find out if
+ * the recipient of this package has already a known (registered) socket
+ * and if so we can re-use it. If there is no socket registered, we try
+ * to make a new connection to the given Universal Node Locator.
+ */
+ $protocolInstance = $tagsInstance->chooseProtocolFromPackageData($packageData);
+
+ // Return it
+ return $protocolInstance;
+ }
+
/**
* "Discovers" the protocol type from given raw package data. This is done
* by looking at the 'recipient' field and extract the first part from it.
* @param $packageData Raw package data
* @return $protocolType Type of protocol, e.g. 'tcp' for TCP/IPv4 connections
*/
- public function discoverProtocolByPackageData (array $packageData) {
+ public static final function discoverProtocolByPackageData (array $packageData) {
//* DEBUG: */ die(__METHOD__ . ':packageData=' . print_r($packageData, TRUE));
/*