Skip to content

Commit

Permalink
Update Websocket.php
Browse files Browse the repository at this point in the history
  • Loading branch information
localzet committed Aug 21, 2024
1 parent 26f5591 commit 1bb56fe
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/Server/Protocols/Websocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,27 @@ class Websocket
*/
public const BINARY_TYPE_ARRAYBUFFER = "\x82";

/**
* Имя класса Request.
*
* @var string
*/
protected static string $requestClass = Request::class;

/**
* Получить или установить имя класса Request для рукопожатия.
*
* @param string|null $className
* @return string
*/
public static function requestClass(string $className = null): string
{
if ($className !== null) {
static::$requestClass = $className;
}
return static::$requestClass;
}

/**
* Проверка целостности пакета.
*
Expand Down Expand Up @@ -330,7 +351,8 @@ public static function dealHandshake(string $buffer, TcpConnection $connection):
$onWebSocketConnect = $connection->onWebSocketConnect ?? $connection->server->onWebSocketConnect ?? false;
if ($onWebSocketConnect) {
try {
$request = new Request($buffer);
/** @var Request $request */
$request = new static::$requestClass($buffer);
$request->connection = $connection;
$connection->request = $request;
$onWebSocketConnect($connection, $request);
Expand Down

0 comments on commit 1bb56fe

Please sign in to comment.