More inline docs
This commit is contained in:
@ -17,6 +17,20 @@ use React\Stream\WritableStreamInterface;
|
||||
class WebSocketCodec
|
||||
{
|
||||
|
||||
/**
|
||||
* Encode a frame. Required keys are opcode and payload. Keys that can be passed are:
|
||||
*
|
||||
* opcode (int) - the opcode
|
||||
* final (bool) - final frame
|
||||
* rsv1-3 (bool) - reserved bits
|
||||
* masked (bool) - if the frame was masked
|
||||
* mask (string) - the mask bytes, if masked
|
||||
* length (int) - length of payload
|
||||
* payload (string) - the payload
|
||||
*
|
||||
* @param array $frame The frame
|
||||
* @return string The encoded frame
|
||||
*/
|
||||
public function encode(array $frame): string
|
||||
{
|
||||
// Encoded frame
|
||||
@ -82,21 +96,24 @@ class WebSocketCodec
|
||||
$encoded .= $frame['payload'];
|
||||
}
|
||||
|
||||
//$this->hexdump($encoded);
|
||||
|
||||
return $encoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a websocket frame and return an array with the keys:
|
||||
*
|
||||
* opcode (int) - the opcode
|
||||
* fin (bool) - final frame
|
||||
* final (bool) - final frame
|
||||
* rsv1-3 (bool) - reserved bits
|
||||
* masked (bool) - if the frame was masked
|
||||
* mask (string) - the mask bytes, if masked
|
||||
* length (int) - length of payload
|
||||
* payload (string) - the payload
|
||||
*
|
||||
* @param string $frame The frame data to decode
|
||||
* @return array The decoded frame
|
||||
*/
|
||||
public function decode($frame): array
|
||||
public function decode(string $frame): array
|
||||
{
|
||||
// Decoded frame
|
||||
$decoded = [];
|
||||
|
Reference in New Issue
Block a user