]> git.mxchange.org Git - hub.git/commitdiff
The packageData array should be used for handling package data
authorRoland Häder <roland@mxchange.org>
Sat, 22 May 2010 17:07:42 +0000 (17:07 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 22 May 2010 17:07:42 +0000 (17:07 +0000)
application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php
application/hub/main/resolver/state/network/class_NetworkStateResolver.php

index 7e1033f126a7d4058fce3f5449e0aa290480769a..6e8cef5a16b69ecae2ba515cc5f4d42badbe675c 100644 (file)
@@ -91,8 +91,11 @@ class TcpNetworkPackageHandler extends BaseNetworkPackageHandler implements Netw
                        $this->setErrorCode(self::PACKAGE_LEVEL_CHECK_OKAY);
                }
 
+               // Prepare the package data
+               $packageData = explode(NetworkPackage::PACKAGE_DATA_SEPERATOR, $rawData);
+
                // Get a state from the resolver for this package
-               $stateInstance = $this->getResolverInstance()->resolveStateByPackage($this, $rawData);
+               $stateInstance = $this->getResolverInstance()->resolveStateByPackage($this, $packageData);
                die('UNFINISHED:'.$stateInstance->__toString());
        }
 }
index 925a37a052ccb7f9bc8c93e02656e30fe6edf8b4..60ef2ec3b36b7fc633c586f51992ad18c15fc3cf 100644 (file)
@@ -62,11 +62,14 @@ class NetworkStateResolver extends BaseStateResolver implements StateResolver {
         * Returns an state instance for a given package class
         *
         * @param       $packageInstance        An instance of a package class
-        * @param       $rawData                        The raw data
+        * @param       $packageData            Raw package data
         * @return      $stateInstance          An instance of the resolved state
         * @todo        ~30% done
         */
-       public function resolveStateByPackage (Networkable $packageInstance, $rawData) {
+       public function resolveStateByPackage (Networkable $packageInstance, array $packageData) {
+               // Init state instance
+               $stateInstance = null;
+
                // Get error code
                $errorCode = $packageInstance->getErrorCode();
 
@@ -85,7 +88,10 @@ class NetworkStateResolver extends BaseStateResolver implements StateResolver {
 
                // @TODO We need to somehow detect the state/status of the remote peer and still maintain good speed.
                // @TODO So maybe some pre-instancing of classes might help here to speedup this I/O intensive process.
-               $this->partialStub('errorCode=' . $errorCode . ',rawData[] = ' . gettype($rawData) . '(' . strlen($rawData) . ')');
+               $this->partialStub('errorCode=' . $errorCode . ',rawData[] = ' . gettype($rawData) . '(' . count($rawData) . ')');
+
+               // Return the prepared instance
+               return $stateInstance;
        }
 }