]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/factories/socket/class_SocketFactory.php
Refacturing to pass a ProtocolHandler instance instead of the direct name. This
[hub.git] / application / hub / main / factories / socket / class_SocketFactory.php
index c319eefeab703ecfc536af537d0ffa6b091c836f..8d7fa986678e5bdedf290a607b6c6b70d241bd55 100644 (file)
@@ -37,15 +37,15 @@ class SocketFactory extends ObjectFactory {
         * Creates a valid socket resource from given packae data and protocol
         *
         * @param       $packageData            Raw package data
-        * @param       $protocolName           Protocol name (TCP/UDP)
+        * @param       $protocolInstance       An instance of a ProtocolHandler class
         * @return      $socketResource         Socket resource
         */
-       public static function createSocketFromPackageData (array $packageData, $protocolName) {
+       public static function createSocketFromPackageData (array $packageData, ProtocolHandler $protocolInstance) {
                // Get an instance
                $factoryInstance = new SocketFactory();
 
                // Construct registry key
-               $registryKey = 'socket_' . $protocolName . '_' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT];
+               $registryKey = 'socket_' . $protocolInstance->getProtocolName() . '_' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT];
 
                // Debug message
                //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Trying to find a socket with registryKey=' . $registryKey);
@@ -62,7 +62,7 @@ class SocketFactory extends ObjectFactory {
                        //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Using socket ' . $socketResource . '(' . gettype($socketResource) . ') from registry.');
                } else {
                        // Construct configuration entry for object factory and get it
-                       $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry($protocolName . '_connection_helper_class');
+                       $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry($protocolInstance->getProtocolName() . '_connection_helper_class');
 
                        // Debug message
                        //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Going to use class ' . $className . ' for creating a socket resource ...');