Documentation

TranscodesData

Provides common methods to encode data before sending it to a broker and to decode data received from a broker.

Table of Contents

buildLengthPrefixedString()  : string
Creates a string which is prefixed with its own length as bytes.
decodeMessageId()  : int
Converts the given string to a number, assuming it is an MSB encoded message id.
encodeMessageId()  : string
Encodes the given message identifier as string.
encodeMessageLength()  : string
Encodes the length of a message as string, so it can be transmitted over the wire.

Methods

buildLengthPrefixedString()

Creates a string which is prefixed with its own length as bytes.

protected buildLengthPrefixedString(string $data) : string

This means a string like 'hello world' will become

\x00\x0bhello world

where \x00\0x0b is the hex representation of 00000000 00001011 = 11

Parameters
$data : string
Return values
string

decodeMessageId()

Converts the given string to a number, assuming it is an MSB encoded message id.

protected decodeMessageId(string $encodedMessageId) : int

MSB means preceding characters have higher value.

Parameters
$encodedMessageId : string
Return values
int

encodeMessageId()

Encodes the given message identifier as string.

protected encodeMessageId(int $messageId) : string
Parameters
$messageId : int
Return values
string

encodeMessageLength()

Encodes the length of a message as string, so it can be transmitted over the wire.

protected encodeMessageLength(int $length) : string
Parameters
$length : int
Return values
string

Search results