Added writeBinary, tests for middleware

This commit is contained in:
2024-02-21 22:26:06 +01:00
parent ea9865c177
commit 418ece5155
3 changed files with 66 additions and 2 deletions

View File

@ -37,6 +37,7 @@ class WebSocketMiddleware implements EventEmitterInterface
public function __invoke(ServerRequestInterface $request, callable $next)
{
if ($request->getHeaderLine('upgrade') !== 'websocket') {
return $next($request);
}
@ -56,9 +57,10 @@ class WebSocketMiddleware implements EventEmitterInterface
$this->websockets->detach($websocket);
});
Loop::futureTick(function () use ($websocket) {
// FIXME how to test with futureTick?
//Loop::futureTick(function () use ($websocket) {
$this->emit(self::EVENT_CONNECTION, [ $websocket ]);
});
//});
return new Response(
Response::STATUS_SWITCHING_PROTOCOLS,