phasync\Util\Protocols\LengthPrefixedFraming
class
Documentation
This class provides a fast and simple binary protocol for length prefixed chunked streaming with the StringBuffer class. Given a StringBuffer that contains a binary protocol of length prefixed unsigned longs (32 bit big endian order/network byte order) this protocol will generate and parse a binary stream.
To parse a StringBuffer stream:
$frame = LengthPrefixedFraming::parse($stringBuffer);
if ($frame !== null) {
$data = $frame->getPayload(); // Gets the binary payload
}
To write a binary chunk:
$frame->setPayload("Some binary data");
$chunk = $frame->toString(); // Binary prefixed chunk as a string
Inheritance
Implements:
phasync\Internal\ObjectPoolInterface
Uses Traits:
phasync\Internal\ObjectPoolTrait
Properties (3)
string $payload
Contains the full binary data.
array $pool
int $instanceCount
Methods (7)
Return this instance back to the object pool so that it can
Documentation missing
Sets the framed payload.
Get the payload body without length.
Documentation missing
Documentation missing
Documentation missing