Skip to content

Commit

Permalink
check for frame
Browse files Browse the repository at this point in the history
  • Loading branch information
joedixon committed Nov 27, 2023
1 parent 41055fb commit a1c15ca
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 28 deletions.
6 changes: 4 additions & 2 deletions src/WebSockets/WsConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
7 changes: 0 additions & 7 deletions tests/Feature/Reverb/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
18 changes: 0 additions & 18 deletions tests/ReverbTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Empty file.
1 change: 0 additions & 1 deletion tests/Specification/spec-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
})
Expand Down

0 comments on commit a1c15ca

Please sign in to comment.