Skip to content

Commit

Permalink
Move acceptor before clientHandler arg
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Sep 9, 2023
1 parent 7667826 commit fe925cf
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/broadcast-server/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function handleClient(WebsocketClient $client, Request $request, Response
}
};

$websocket = new Websocket($server, $logger, $clientHandler, $acceptor);
$websocket = new Websocket($server, $logger, $acceptor, $clientHandler);

$router = new Router($server, new NullLogger(), $errorHandler);
$router->addRoute('GET', '/broadcast', $websocket);
Expand Down
2 changes: 1 addition & 1 deletion examples/stackexchange-questions/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public function handleClient(WebsocketClient $client, Request $request, Response
$websocket = new Websocket(
httpServer: $server,
logger: $logger,
clientHandler: $clientHandler,
acceptor: $acceptor,
clientHandler: $clientHandler,
);

$router = new Router($server, new NullLogger(), $errorHandler);
Expand Down
2 changes: 1 addition & 1 deletion src/Websocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ final class Websocket implements RequestHandler
public function __construct(
HttpServer $httpServer,
private readonly PsrLogger $logger,
private readonly WebsocketClientHandler $clientHandler,
private readonly RequestHandler $acceptor,
private readonly WebsocketClientHandler $clientHandler,
private readonly WebsocketClientFactory $clientFactory = new Rfc6455ClientFactory(),
private readonly ?WebsocketCompressionContextFactory $compressionContextFactory = null,
) {
Expand Down
2 changes: 1 addition & 1 deletion test-autobahn/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
$websocket = new Websocket(
httpServer: $server,
logger: $logger,
acceptor: new Rfc6455Acceptor(),
clientHandler: new class implements WebsocketClientHandler {
public function handleClient(WebsocketClient $client, Request $request, Response $response): void
{
Expand All @@ -36,7 +37,6 @@ public function handleClient(WebsocketClient $client, Request $request, Response
}
}
},
acceptor: new Rfc6455Acceptor(),
clientFactory: new Rfc6455ClientFactory(
heartbeatQueue: null,
rateLimit: null,
Expand Down
2 changes: 1 addition & 1 deletion test/WebsocketIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ protected function createWebsocketServer(\Closure $clientHandler): SocketHttpSer
$websocket = new Websocket(
httpServer: $httpServer,
logger: $this->logger,
acceptor: new Rfc6455Acceptor(),
clientHandler: new class($clientHandler, $gateway) implements WebsocketClientHandler {
public function __construct(
private readonly \Closure $clientHandler,
Expand All @@ -62,7 +63,6 @@ public function handleClient(WebsocketClient $client, Request $request, Response
($this->clientHandler)($this->gateway, $client);
}
},
acceptor: new Rfc6455Acceptor(),
);

$httpServer->expose(new Socket\InternetAddress('127.0.0.1', 0));
Expand Down
4 changes: 2 additions & 2 deletions test/WebsocketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ protected function createWebsocketServer(
$websocket = new Websocket(
httpServer: $httpServer,
logger: $logger,
acceptor: new Rfc6455Acceptor(),
clientHandler: new class($clientHandler, $gateway) implements WebsocketClientHandler {
public function __construct(
private readonly \Closure $clientHandler,
Expand All @@ -90,7 +91,6 @@ public function handleClient(WebsocketClient $client, Request $request, Response
($this->clientHandler)($this->gateway, $client);
}
},
acceptor: new Rfc6455Acceptor(),
clientFactory: $factory,
);

Expand Down Expand Up @@ -123,8 +123,8 @@ public function testHandshake(Request $request, int $status, array $expectedHead
$websocket = new Websocket(
httpServer: $server,
logger: $logger,
clientHandler: $this->createMock(WebsocketClientHandler::class),
acceptor: $upgradeHandler,
clientHandler: $this->createMock(WebsocketClientHandler::class),
);
$server->start($websocket, $this->createMock(ErrorHandler::class));

Expand Down

0 comments on commit fe925cf

Please sign in to comment.