initial commit

This commit is contained in:
crazywhalecc
2022-12-26 19:10:28 +08:00
commit 1f4427b5b7
27 changed files with 2326 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace Choir\WebSocket;
class FrameFactory
{
public static function createPingFrame(): Frame
{
return new Frame(null, Opcode::PING, true, true);
}
public static function createPongFrame(): Frame
{
return new Frame(null, Opcode::PONG, true, true);
}
public static function createTextFrame(string $payload): Frame
{
return new Frame($payload, Opcode::TEXT, true, true);
}
public static function createBinaryFrame(string $payload): Frame
{
return new Frame($payload, Opcode::BINARY, true, true);
}
public static function createCloseFrame(int $code = null, string $reason = null): Frame
{
return new CloseFrame($code, $reason);
}
}