PHP Class Wrench\Payload\Payload

Represents a WebSocket protocol payload, which may be made up of multiple frames.
Afficher le fichier Open project: varspool/Wrench Class Usage Examples

Protected Properties

Свойство Type Description
$buffer String representation of the payload contents
$frames Wrench\Frame\Frame[] A payload may consist of one or more frames

Méthodes publiques

Méthode Description
__toString ( ) : string
encode ( string $data, integer $type = Protocol::TYPE_TEXT, boolean $masked = false ) : Payload Encodes a payload
getPayload ( ) : string
getRemainingData ( ) : number | null Gets the number of remaining bytes before this payload will be complete
getType ( ) : integer Gets the type of the payload
isComplete ( ) : boolean Whether the payload is complete
isWaitingForData ( ) : boolean Whether this payload is waiting for more data
receiveData ( string $data ) : void Receive raw data into the payload
sendToSocket ( Socket $socket ) : boolean

Méthodes protégées

Méthode Description
getCurrentFrame ( ) : mixed Gets the current frame for the payload
getFrame ( ) : Wrench\Frame\Frame Get a frame object
getReceivingFrame ( ) : Wrench\Frame\Frame Gets the frame into which data should be receieved

Method Details

__toString() public méthode

public __toString ( ) : string
Résultat string

encode() public méthode

Encodes a payload
public encode ( string $data, integer $type = Protocol::TYPE_TEXT, boolean $masked = false ) : Payload
$data string
$type integer
$masked boolean
Résultat Payload

getCurrentFrame() protected méthode

Gets the current frame for the payload
protected getCurrentFrame ( ) : mixed
Résultat mixed

getFrame() abstract protected méthode

Get a frame object
abstract protected getFrame ( ) : Wrench\Frame\Frame
Résultat Wrench\Frame\Frame

getPayload() public méthode

public getPayload ( ) : string
Résultat string

getReceivingFrame() protected méthode

Gets the frame into which data should be receieved
protected getReceivingFrame ( ) : Wrench\Frame\Frame
Résultat Wrench\Frame\Frame

getRemainingData() public méthode

May return 0 (no more bytes required) or null (unknown number of bytes required).
public getRemainingData ( ) : number | null
Résultat number | null

getType() public méthode

The type of a payload is taken from its first frame
public getType ( ) : integer
Résultat integer

isComplete() public méthode

Whether the payload is complete
public isComplete ( ) : boolean
Résultat boolean

isWaitingForData() public méthode

Whether this payload is waiting for more data
public isWaitingForData ( ) : boolean
Résultat boolean

receiveData() public méthode

Receive raw data into the payload
public receiveData ( string $data ) : void
$data string
Résultat void

sendToSocket() public méthode

public sendToSocket ( Socket $socket ) : boolean
$socket Wrench\Socket\Socket
Résultat boolean

Property Details

$buffer protected_oe property

String representation of the payload contents
protected $buffer

$frames protected_oe property

A payload may consist of one or more frames
protected Frame[],Wrench\Frame $frames
Résultat Wrench\Frame\Frame[]