初始化

This commit is contained in:
2026-01-06 13:37:07 +08:00
parent c3435595fe
commit 00d7a381aa
70 changed files with 3913 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace think\worker\protocols;
use think\worker\websocket\Frame;
use Workerman\Connection\TcpConnection;
use Workerman\Protocols\Http;
use Workerman\Protocols\Websocket;
class FlexHttp
{
public static function input(string $buffer, TcpConnection $connection)
{
if (empty($connection->context->websocketHandshake)) {
return Http::input($buffer, $connection);
} else {
return Websocket::input($buffer, $connection);
}
}
public static function decode(string $buffer, TcpConnection $connection)
{
if (empty($connection->context->websocketHandshake)) {
return Http::decode($buffer, $connection);
} else {
$data = Websocket::decode($buffer, $connection);
return new Frame($connection->id, $data);
}
}
public static function encode(mixed $response, TcpConnection $connection): string
{
if (empty($connection->context->websocketHandshake)) {
return Http::encode($response, $connection);
} else {
return Websocket::encode($response, $connection);
}
}
}