Prechádzať zdrojové kódy

Merge pull request #345 from DTFreeman/master

使用static::$maxPackageSize 以更方便通过继承TcpConnection来设置不同服务接收的包大小
walkor 7 rokov pred
rodič
commit
74efa9cd23

+ 1 - 1
Connection/TcpConnection.php

@@ -610,7 +610,7 @@ class TcpConnection extends ConnectionInterface
                     // The packet length is unknown.
                     if ($this->_currentPackageLength === 0) {
                         break;
-                    } elseif ($this->_currentPackageLength > 0 && $this->_currentPackageLength <= self::$maxPackageSize) {
+                    } elseif ($this->_currentPackageLength > 0 && $this->_currentPackageLength <= static::$maxPackageSize) {
                         // Data is not enough for a package.
                         if ($this->_currentPackageLength > strlen($this->_recvBuffer)) {
                             break;

+ 1 - 1
Protocols/Http.php

@@ -38,7 +38,7 @@ class Http
     {
         if (!strpos($recv_buffer, "\r\n\r\n")) {
             // Judge whether the package length exceeds the limit.
-            if (strlen($recv_buffer) >= TcpConnection::$maxPackageSize) {
+            if (strlen($recv_buffer) >= $connection::$maxPackageSize) {
                 $connection->close();
                 return 0;
             }

+ 1 - 1
Protocols/Text.php

@@ -30,7 +30,7 @@ class Text
     public static function input($buffer, TcpConnection $connection)
     {
         // Judge whether the package length exceeds the limit.
-        if (strlen($buffer) >= TcpConnection::$maxPackageSize) {
+        if (strlen($buffer) >= $connection::$maxPackageSize) {
             $connection->close();
             return 0;
         }

+ 1 - 1
Protocols/Websocket.php

@@ -140,7 +140,7 @@ class Websocket implements \Workerman\Protocols\ProtocolInterface
             $current_frame_length = $head_len + $data_len;
 
             $total_package_size = strlen($connection->websocketDataBuffer) + $current_frame_length;
-            if ($total_package_size > TcpConnection::$maxPackageSize) {
+            if ($total_package_size > $connection::$maxPackageSize) {
                 Worker::safeEcho("error package. package_length=$total_package_size\n");
                 $connection->close();
                 return 0;

+ 1 - 1
Protocols/Ws.php

@@ -137,7 +137,7 @@ class Ws
             }
 
             $total_package_size = strlen($connection->websocketDataBuffer) + $current_frame_length;
-            if ($total_package_size > TcpConnection::$maxPackageSize) {
+            if ($total_package_size > $connection::$maxPackageSize) {
                 Worker::safeEcho("error package. package_length=$total_package_size\n");
                 $connection->close();
                 return 0;