]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php
Renamed FooNetworkPackageHandler to FooRawDataHandler, because it handles raw data...
[hub.git] / application / hub / main / handler / network / tcp / class_TcpNetworkPackageHandler.php
index f11045886f99b030fa6435da1045d739b7592069..f551ef47b7591c74e7b59193e56a1fa6505a87ab 100644 (file)
@@ -1,106 +1,3 @@
 <?php
-/**
- * A TCP network package handler
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class TcpNetworkPackageHandler extends BaseNetworkPackageHandler implements Networkable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set handler name
-               $this->setHandlerName('tcp');
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $handlerInstance        An instance of a Networkable class
-        */
-       public static final function createTcpNetworkPackageHandler () {
-               // Get new instance
-               $handlerInstance = new TcpNetworkPackageHandler();
-
-               // Return the prepared instance
-               return $handlerInstance;
-       }
-
-       /**
-        * Processes raw data from given resource. This is mostly useful for TCP
-        * package handling and is implemented in the TcpListener class
-        *
-        * @param       $resource       A valid resource identifier
-        * @return      void
-        */
-       public function processRawDataFromResource ($resource) {
-               // Check the resource
-               if (!is_resource($resource)) {
-                       // Throw an exception
-                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
-               } // END - if
-
-               // Reset error code to unhandled
-               $this->setErrorCode(self::SOCKET_ERROR_UNHANDLED);
-
-               // Init variables
-               $decodedData = false;
-
-               // Debug message
-               //* NOISY-DEBUG: */ $this->debugOutput('HANDLER: Handling TCP package from peer ' . $resource);
-
-               /*
-                * Read the raw data from socket. If you change PHP_BINARY_READ to
-                * PHP_NORMAL_READ, this line will endless block. We only have
-                * simultanous threads and no real threads.
-                */
-               $rawData = socket_read($resource, $this->getConfigInstance()->getConfigEntry('tcp_buffer_length'), PHP_BINARY_READ);
-
-               // Debug output of read data length
-               //* NOISY-DEBUG: */ $this->debugOutput('LISTENER: rawData[]=' . strlen($rawData));
-
-               // Is it valid?
-               if (($rawData === false) || (socket_last_error($resource) > 0)) {
-                       // Network error or connection lost
-                       $this->setErrorCode(socket_last_error($resource));
-               } elseif (empty($rawData)) {
-                       // The peer did send nothing to us
-                       $this->setErrorCode(self::SOCKET_ERROR_EMPTY_DATA);
-               } else {
-                       /*
-                        * Low-level checks of the raw data went all fine, we can now
-                        * decode the raw data. This may still fail because of invalid
-                        * encoded data.
-                        */
-                       $decodedData = $this->getInputStreamInstance()->streamData($rawData);
-               }
-
-               // Add the (maybe above decoded) data to the stacker
-               $this->addDecodedDataToStacker($decodedData);
-       }
-}
-
-// [EOF]
+// @DEPRECATED
 ?>