From 2f7a8b00500ad0347921b1be2d2fa87503c77cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= Date: Thu, 14 Nov 2019 13:33:24 +0800 Subject: [PATCH] Fixed WebSocketClient::push TypeError, expects integer, but boolean given. (#940) --- CHANGELOG.md | 1 + src/websocket-client/src/Client.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cffe884e3..e0a229408 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - [#909](https://github.com/hyperf/hyperf/pull/909) Fixed a issue that causes staled parallel execution. - [#925](https://github.com/hyperf/hyperf/pull/925) Fixed the dead cycle caused by socket closed. - [#932](https://github.com/hyperf/hyperf/pull/932) Fixed `Translator::setLocale` does not works in coroutine evnironment. +- [#940](https://github.com/hyperf/hyperf/pull/940) Fixed WebSocketClient::push TypeError, expects integer, but boolean given. ## Optimized diff --git a/src/websocket-client/src/Client.php b/src/websocket-client/src/Client.php index 6072bf023..5c05ce88a 100644 --- a/src/websocket-client/src/Client.php +++ b/src/websocket-client/src/Client.php @@ -67,9 +67,15 @@ class Client return $ret; } - public function push(string $data, int $opcode = WEBSOCKET_OPCODE_TEXT, bool $finish = true): bool + /** + * @param bool|int $finish TODO: When swoole version >= 4.4.12, `finish` is SWOOLE_WEBSOCKET_FLAG_FIN or SWOOLE_WEBSOCKET_FLAG_COMPRESS + */ + public function push(string $data, int $opcode = WEBSOCKET_OPCODE_TEXT, $finish = null): bool { - return $this->client->push($data, $opcode, $finish); + if (isset($finish)) { + return $this->client->push($data, $opcode, $finish); + } + return $this->client->push($data, $opcode); } public function close(): bool