瀏覽代碼

check parameters for send

walkor 9 年之前
父節點
當前提交
6231989373
共有 1 個文件被更改,包括 3 次插入0 次删除
  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;