Renamed connect event to connection

This commit is contained in:
Chris 2024-02-21 21:38:57 +01:00
parent 332c3076c0
commit 98324121f1
2 changed files with 4 additions and 21 deletions

View File

@ -57,7 +57,7 @@ $http->listen($socket);
### Server Events
#### connect
#### connection
This event is emitted when a new WebSocket request has been accepted. The `WebSocketConnection` is passed as the first argument.

View File

@ -14,6 +14,8 @@ use SplObjectStorage;
class WebSocketMiddleware implements EventEmitterInterface
{
const EVENT_CONNECTION = 'connection';
const MAGIC = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';
use EventEmitterTrait;
@ -55,7 +57,7 @@ class WebSocketMiddleware implements EventEmitterInterface
});
Loop::futureTick(function () use ($websocket) {
$this->emit('connect', [ $websocket ]);
$this->emit(self::EVENT_CONNECTION, [ $websocket ]);
});
return new Response(
@ -69,23 +71,4 @@ class WebSocketMiddleware implements EventEmitterInterface
);
}
// private function hexdump($data): void
// {
// printf("%4d .\n", strlen($data));
// $rows = str_split($data, 16);
// $offs = 0;
// foreach ($rows as $row) {
// $h = []; $a = [];
// for ($n = 0; $n < 16; $n++) {
// if ($n < strlen($row)) {
// $h[] = sprintf("%02x%s", ord($row[$n]), ($n==7)?" ":" ");
// $a[] = sprintf("%s%s", (ctype_print($row[$n])?$row[$n]:"."), ($n==7)?" ":"");
// } else {
// $h[] = (($n==7)?" ":" ");
// $a[] = (($n==7)?" ":" ");
// }
// }
// printf("%04x | %s | %s\n", 16 * $offs++, join("", $h), join("", $a));
// }
// }
}