diff --git a/src/WebSockets/WsConnection.php b/src/WebSockets/WsConnection.php index 20c0d189..9a2cbbca 100644 --- a/src/WebSockets/WsConnection.php +++ b/src/WebSockets/WsConnection.php @@ -97,9 +97,11 @@ public function onClose(callable $callback): void /** * Close the connection. */ - public function close(FrameInterface $frame): void + public function close(FrameInterface $frame = null): void { - $this->send($frame); + if ($frame) { + $this->send($frame); + } $this->connection->close(); } diff --git a/tests/Feature/Reverb/ServerTest.php b/tests/Feature/Reverb/ServerTest.php index 93364eba..17eaf2bc 100644 --- a/tests/Feature/Reverb/ServerTest.php +++ b/tests/Feature/Reverb/ServerTest.php @@ -315,13 +315,6 @@ $this->connect(); }); -it('can receive a pong control frame', function () { - $frame = new Frame('ping', true, Frame::OP_PING); - $response = $this->sendRaw($frame); - - expect($response)->toBe('pong'); -}); - it('clears application state between requests', function () { $this->subscribe('test-channel'); diff --git a/tests/ReverbTestCase.php b/tests/ReverbTestCase.php index e9ae48bc..e92e3c55 100644 --- a/tests/ReverbTestCase.php +++ b/tests/ReverbTestCase.php @@ -182,24 +182,6 @@ public function send(array $message, WebSocket $connection = null): string return await($promise->promise()); } - /** - * Send a message to the connected client. - */ - public function sendRaw(mixed $message, WebSocket $connection = null): string - { - $promise = new Deferred; - - $connection = $connection ?: $this->connect(); - - $connection->on('message', function ($message) use ($promise) { - $promise->resolve((string) $message); - }); - - $connection->send($message); - - return await($promise->promise()); - } - /** * Disconnect the connected client. */ diff --git a/tests/Specification/reports/.gitkeep b/tests/Specification/reports/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/Specification/spec-server.php b/tests/Specification/spec-server.php index 39c0abbe..4be0dbaa 100644 --- a/tests/Specification/spec-server.php +++ b/tests/Specification/spec-server.php @@ -31,7 +31,6 @@ function routes() Route::get('/', function (RequestInterface $request, WsConnection $connection) { $connection->onMessage(function ($message) use ($connection) { $connection->send($message); - $connection->send($message); }); $connection->openBuffer(); })