mirror of
https://github.com/crazywhalecc/choir-psr-http.git
synced 2026-07-20 23:25:38 +08:00
initial commit
This commit is contained in:
33
src/Choir/WebSocket/FrameFactory.php
Normal file
33
src/Choir/WebSocket/FrameFactory.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user