]> git.mxchange.org Git - hub.git/commitdiff
Added constants for easier usage
authorRoland Häder <roland@mxchange.org>
Sat, 22 May 2010 17:51:18 +0000 (17:51 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 22 May 2010 17:51:18 +0000 (17:51 +0000)
application/hub/main/handler/network/class_BaseNetworkPackageHandler.php
application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php
application/hub/main/package/class_NetworkPackage.php

index 723fb7ff156d4c3868a7f5eba8949d7f46f11bd5..ef0946f5cb95adeed9bc9887a0e71ed7fc4ad786 100644 (file)
@@ -61,7 +61,7 @@ class BaseNetworkPackageHandler extends BaseHandler {
                $ownAddress = Registry::getRegistry()->getInstance('node')->getAddressPort($this);
 
                // Does it match?
-               $matches = ($ownAddress === $packageData[1]);
+               $matches = ($ownAddress === $packageData[NetworkPackage::INDEX_PACKAGE_RECIPIENT]);
 
                // Return result
                return $matches;
index e24fbeb5541165d43fc1b8f49dbd896cda7dbcab..33b4d2a62a85ccbe1cffcf8aac1504173f93b884 100644 (file)
@@ -71,7 +71,7 @@ class TcpNetworkPackageHandler extends BaseNetworkPackageHandler implements Netw
                if (count($packageData) < 3) {
                        // Not enougth fields in $packageData!
                        $this->setErrorCode(self::PACKAGE_ERROR_INCOMPLETE_DATA);
-               } elseif (count(explode(NetworkPackage::PACKAGE_MASK_SEPERATOR, $packageData[2])) < 2) {
+               } elseif (count(explode(NetworkPackage::PACKAGE_MASK_SEPERATOR, $packageData[NetworkPackage::INDEX_PACKAGE_CONTENT])) < 2) {
                        // Not entougth fields in content
                        $this->setErrorCode(self::PACKAGE_ERROR_INVALID_CONTENT);
                } elseif (!$this->ifRecipientMatchesOwnAddress($packageData)) {
index 52b2c3ec985abefd9fe447f17a78967c509399d6..838f4bf4c9ef9b5d9863f0c5e18275dcb8b8f449 100644 (file)
@@ -57,6 +57,13 @@ class NetworkPackage extends BaseFrameworkSystem implements Deliverable, Registe
        const INDEX_TAGS                 = 2;
        const INDEX_CHECKSUM             = 3;
 
+       /**
+        * Array indexes for raw package array
+        */
+       const INDEX_PACKAGE_SENDER    = 0;
+       const INDEX_PACKAGE_RECIPIENT = 1;
+       const INDEX_PACKAGE_CONTENT   = 2;
+
        /**
         * Tags seperator
         */