Browse Source

check parameters for send

walkor 9 năm trước cách đây
mục cha
commit
6231989373
1 tập tin đã thay đổi với 3 bổ sung0 xóa
  1. 3 0
      Protocols/Websocket.php

+ 3 - 0
Protocols/Websocket.php

@@ -215,6 +215,9 @@ class Websocket implements \Workerman\Protocols\ProtocolInterface
      */
     public static function encode($buffer, ConnectionInterface $connection)
     {
+        if (!is_scalar($buffer)) {
+            throw new \Exception("You can't send(" . gettype($buffer) . ") to client, you need to convert it to a string. ");
+        }
         $len = strlen($buffer);
         if (empty($connection->websocketType)) {
             $connection->websocketType = self::BINARY_TYPE_BLOB;