Documentation

Frame
in package
implements FrameInterface

Table of Contents

Interfaces

FrameInterface

Constants

CLOSE_ABNORMAL  = 1006
CLOSE_BAD_DATA  = 1003
CLOSE_BAD_PAYLOAD  = 1007
CLOSE_GOING_AWAY  = 1001
CLOSE_MAND_EXT  = 1010
CLOSE_NO_STATUS  = 1005
CLOSE_NORMAL  = 1000
CLOSE_POLICY  = 1008
CLOSE_PROTOCOL  = 1002
CLOSE_SRV_ERR  = 1011
CLOSE_TLS  = 1015
CLOSE_TOO_BIG  = 1009
MASK_LENGTH  = 4
OP_BINARY  = 2
OP_CLOSE  = 8
OP_CONTINUE  = 0
OP_PING  = 9
OP_PONG  = 10
OP_TEXT  = 1

Properties

$bytesRecvd  : int
Number of bytes received from the frame
$data  : string
The contents of the frame
$defPayLen  : int
Number of bytes in the payload (as per framing protocol)
$firstByte  : int
The unpacked first byte of the frame
$secondByte  : int
The unpacked second byte of the frame
$isCoalesced  : bool
If the frame is coalesced this is true This is to prevent doing math every time ::isCoalesced is called
$ufeg  : callable

Methods

__construct()  : mixed
__toString()  : string
Should return the unmasked payload received from peer
addBuffer()  : mixed
Add incoming data to the frame from peer
applyMask()  : string
Apply a mask to a string or the payload of the instance
extractOverflow()  : string
Sometimes clients will concatenate more than one frame over the wire This method will take the extra bytes off the end and return them
generateMaskingKey()  : string
Create a 4 byte masking key
getContents()  : string
Get the raw contents of the frame
getMaskingKey()  : string
32-big string
getOpcode()  : int
getPayload()  : string
Get the payload (message) sent from peer
getPayloadLength()  : int
Get the number of bytes the payload is set to be
getPayloadStartingByte()  : mixed
{@inheritdoc}
getRsv1()  : bool
getRsv2()  : bool
getRsv3()  : bool
isCoalesced()  : bool
Determine if the message is complete or still fragmented
isFinal()  : bool
Is this the final frame in a fragmented message?
isMasked()  : bool
Is the payload masked?
maskPayload()  : Frame
Apply a mask to the payload
setRsv1()  : mixed
unMaskPayload()  : Frame
Remove a mask from the payload
getFirstPayloadVal()  : int
Gets the decimal value of bits 9 (10th) through 15 inclusive
getNumPayloadBits()  : int
getNumPayloadBytes()  : mixed
This just returns the number of bytes used in the frame to describe the payload length (as opposed to # of bits)

Constants

CLOSE_ABNORMAL

public mixed CLOSE_ABNORMAL = 1006

CLOSE_BAD_DATA

public mixed CLOSE_BAD_DATA = 1003

CLOSE_BAD_PAYLOAD

public mixed CLOSE_BAD_PAYLOAD = 1007

CLOSE_GOING_AWAY

public mixed CLOSE_GOING_AWAY = 1001

CLOSE_MAND_EXT

public mixed CLOSE_MAND_EXT = 1010

CLOSE_NO_STATUS

public mixed CLOSE_NO_STATUS = 1005

CLOSE_NORMAL

public mixed CLOSE_NORMAL = 1000

CLOSE_POLICY

public mixed CLOSE_POLICY = 1008

CLOSE_PROTOCOL

public mixed CLOSE_PROTOCOL = 1002

CLOSE_SRV_ERR

public mixed CLOSE_SRV_ERR = 1011

CLOSE_TLS

public mixed CLOSE_TLS = 1015

CLOSE_TOO_BIG

public mixed CLOSE_TOO_BIG = 1009

MASK_LENGTH

public mixed MASK_LENGTH = 4

OP_BINARY

public mixed OP_BINARY = 2

OP_CLOSE

public mixed OP_CLOSE = 8

OP_CONTINUE

public mixed OP_CONTINUE = 0

OP_PING

public mixed OP_PING = 9

OP_PONG

public mixed OP_PONG = 10

OP_TEXT

public mixed OP_TEXT = 1

Properties

$bytesRecvd

Number of bytes received from the frame

public int $bytesRecvd = 0

$data

The contents of the frame

protected string $data = ''

$defPayLen

Number of bytes in the payload (as per framing protocol)

protected int $defPayLen = -1

$firstByte

The unpacked first byte of the frame

protected int $firstByte = -1

$secondByte

The unpacked second byte of the frame

protected int $secondByte = -1

$isCoalesced

If the frame is coalesced this is true This is to prevent doing math every time ::isCoalesced is called

private bool $isCoalesced = false

$ufeg

private callable $ufeg
Tags
returns

\UnderflowException

Methods

__construct()

public __construct([string|null $payload = null ][, bool $final = true ][, int $opcode = 1 ][, callable $ufExceptionFactory = null ]) : mixed
Parameters
$payload : string|null = null
$final : bool = true
$opcode : int = 1
$ufExceptionFactory : callable = null

__toString()

Should return the unmasked payload received from peer

public __toString() : string
Return values
string

addBuffer()

Add incoming data to the frame from peer

public addBuffer(mixed $buf) : mixed
Parameters
$buf : mixed

applyMask()

Apply a mask to a string or the payload of the instance

public applyMask(string $maskingKey[, string|null $payload = null ]) : string
Parameters
$maskingKey : string

The 4 character masking key to be applied

$payload : string|null = null

A string to mask or null to use the payload

Tags
throws
UnderflowException

If using the payload but enough hasn't been buffered

Return values
string

The masked string

extractOverflow()

Sometimes clients will concatenate more than one frame over the wire This method will take the extra bytes off the end and return them

public extractOverflow() : string
Return values
string

generateMaskingKey()

Create a 4 byte masking key

public generateMaskingKey() : string
Return values
string

getContents()

Get the raw contents of the frame

public getContents() : string
Tags
todo

This is untested, make sure the substr is right - trying to return the frame w/o the overflow

Return values
string

getMaskingKey()

32-big string

public getMaskingKey() : string
Return values
string

getOpcode()

public getOpcode() : int
Return values
int

getPayload()

Get the payload (message) sent from peer

public getPayload() : string
Tags
todo

Consider not checking mask, always returning the payload, masked or not

Return values
string

getPayloadLength()

Get the number of bytes the payload is set to be

public getPayloadLength() : int
Return values
int

getPayloadStartingByte()

{@inheritdoc}

public getPayloadStartingByte() : mixed

getRsv1()

public getRsv1() : bool
Tags
throws
UnderflowException
Return values
bool

getRsv2()

public getRsv2() : bool
Tags
throws
UnderflowException
Return values
bool

getRsv3()

public getRsv3() : bool
Tags
throws
UnderflowException
Return values
bool

isCoalesced()

Determine if the message is complete or still fragmented

public isCoalesced() : bool
Return values
bool

isFinal()

Is this the final frame in a fragmented message?

public isFinal() : bool
Return values
bool

isMasked()

Is the payload masked?

public isMasked() : bool
Return values
bool

maskPayload()

Apply a mask to the payload

public maskPayload([mixed $maskingKey = null ]) : Frame
Parameters
$maskingKey : mixed = null
Tags
throws
OutOfBoundsException
throws
InvalidArgumentException

If there is an issue with the given masking key

Return values
Frame

setRsv1()

public setRsv1([mixed $value = true ]) : mixed
Parameters
$value : mixed = true

unMaskPayload()

Remove a mask from the payload

public unMaskPayload() : Frame
Tags
throws
UnderFlowException

If the frame is not coalesced

Return values
Frame

getFirstPayloadVal()

Gets the decimal value of bits 9 (10th) through 15 inclusive

protected getFirstPayloadVal() : int
Tags
throws
UnderflowException

If the buffer doesn't have enough data to determine this

Return values
int

getNumPayloadBits()

protected getNumPayloadBits() : int
Tags
throws
UnderflowException
Return values
int

(7|23|71) Number of bits defined for the payload length in the fame

getNumPayloadBytes()

This just returns the number of bytes used in the frame to describe the payload length (as opposed to # of bits)

protected getNumPayloadBytes() : mixed
Tags
see
getNumPayloadBits

        
On this page

Search results