FrameReader

Description

Reads frames from the peer.

https://tools.ietf.org/html/rfc6455#section-5

TODO: Support unmasked frames.

Protected Properties

string $buffer = ''
 Peer read buffer. More...
 
WebSocketClient $client
 
null array $header
 Frame header buffer. More...
 
int $maxLength = 128 * 1024
 Maximum inbound per-frame payload length (fragment). More...
 
int $rsv = 0
 RSV bit mask claimed by extensions. More...
 
const REGEXP
 https://tools.ietf.org/html/rfc6455#section-5.2 More...
 

Public Methods

 __construct (WebSocketClient $client)
 
Generator Frame[] getFrames ()
 Yields all available frames from the peer. More...
 
int getMaxLength ()
 
int getRsv ()
 
$this setMaxLength (int $bytes)
 
$this setRsv (int $rsv)
 

Protected Methods

null Frame getFrame ()
 Reads and returns a single pending frame from the buffer, or nothing. More...
 
null array getFrame_header ()
 https://tools.ietf.org/html/rfc6455#section-5.2 More...
 
Frame newFrame (string $payload)
 Frame factory. More...
 

Properties

◆ $buffer

string $buffer = ''
protected

Peer read buffer.

◆ $header

null array $header
protected

Frame header buffer.

◆ $maxLength

int $maxLength = 128 * 1024
protected

Maximum inbound per-frame payload length (fragment).

Must be greater than or equal to 125

Defaults to 128 KiB.

https://tools.ietf.org/html/rfc6455#section-5.2

◆ $rsv

int $rsv = 0
protected

RSV bit mask claimed by extensions.

◆ REGEXP

const REGEXP
protected
Initial value:
=
'/^.([\x80-\xfd]|\xfe(?<n>..)|\xff(?<J>.{8}))(?<mask>.{4})/s'

https://tools.ietf.org/html/rfc6455#section-5.2

Constructor

◆ __construct()

__construct ( WebSocketClient  $client)
Parameters
WebSocketClient$client

Methods

◆ getFrame()

null Frame getFrame ( )
protected

Reads and returns a single pending frame from the buffer, or nothing.

Returns
null|Frame
Exceptions
WebSocketError

◆ getFrame_header()

null array getFrame_header ( )
protected

◆ getFrames()

Generator Frame [] getFrames ( )

Yields all available frames from the peer.

Returns
Generator|Frame[]

◆ getMaxLength()

int getMaxLength ( )
Returns
int

◆ getRsv()

int getRsv ( )
Returns
int

◆ newFrame()

Frame newFrame ( string  $payload)
protected

Frame factory.

Parameters
string$payload
Returns
Frame

◆ setMaxLength()

$this setMaxLength ( int  $bytes)
Parameters
int$bytes
Returns
$this

◆ setRsv()

$this setRsv ( int  $rsv)
Parameters
int$rsv
Returns
$this