Эх сурвалжийг харах

Text Protocol support udp

wangguoqing 6 жил өмнө
parent
commit
24165c7385
1 өөрчлөгдсөн 5 нэмэгдсэн , 5 устгасан
  1. 5 5
      Protocols/Text.php

+ 5 - 5
Protocols/Text.php

@@ -13,7 +13,7 @@
  */
 namespace Workerman\Protocols;
 
-use Workerman\Connection\TcpConnection;
+use Workerman\Connection\ConnectionInterface;
 
 /**
  * Text Protocol.
@@ -24,13 +24,13 @@ class Text
      * Check the integrity of the package.
      *
      * @param string        $buffer
-     * @param TcpConnection $connection
+     * @param ConnectionInterface $connection
      * @return int
      */
-    public static function input($buffer, TcpConnection $connection)
+    public static function input($buffer, ConnectionInterface $connection)
     {
         // Judge whether the package length exceeds the limit.
-        if (\strlen($buffer) >= $connection->maxPackageSize) {
+        if (isset($connection->maxPackageSize) && \strlen($buffer) >= $connection->maxPackageSize) {
             $connection->close();
             return 0;
         }
@@ -67,4 +67,4 @@ class Text
         // Remove "\n"
         return \rtrim($buffer, "\r\n");
     }
-}
+}