*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* Creates a client object for given protocol. This method uses the
* registry pattern to cache those instances.
*
- * @param $protocol Protocol to create a client object for (e.g. 'http' for a HTTP/1.1 client)
+ * @param $protocolInstance An instance of a HandleableProtocol class to create a client object for (e.g. 'http' for a HTTP/1.1 client)
* @param $socketResource A valid socket resource (optional)
* @return $clientInstance An instance of the requested client
- * @throws EmptyVariableException If a variable is empty unexpectly
*/
- public static final function createClientByProtokol ($protocol, $socketResource = FALSE) {
- // Is the class name valid and is the class there?
- if (empty($protocol)) {
- // Get an instance of this factory
- $factoryInstance = new ClientFactory();
-
- // Throw an exception here
- throw new EmptyVariableException(array($factoryInstance, 'protocol'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } // END - if
-
+ public static final function createClientByProtocolInstance (ProtocolHandler $protocolInstance, $socketResource = FALSE) {
// Default is NULL (to initialize variable)
$clientInstance = NULL;
// Generate registry key
- $registryKey = $protocol . '_client';
+ $registryKey = strtolower($protocolInstance->getProtocolName()) . '_client';
// Is the key already in registry?
if (Registry::getRegistry()->instanceExists($registryKey)) {