Documentation

MessageProcessor

Implementations of this interface provide message parsing capabilities.

Services of this type are used by the MqttClient to implement multiple protocol versions.

Table of Contents

buildConnectMessage()  : string
Builds a connect message from the given connection settings, taking the protocol specifics into account.
buildDisconnectMessage()  : string
Builds a disconnect message.
buildPingRequestMessage()  : string
Builds a ping request message.
buildPingResponseMessage()  : string
Builds a ping response message.
buildPublishAcknowledgementMessage()  : string
Builds a publish acknowledgement for the given message identifier.
buildPublishCompleteMessage()  : string
Builds a publish complete message for the given message identifier.
buildPublishMessage()  : string
Builds a publish message based on the given parameters.
buildPublishReceivedMessage()  : string
Builds a publish received message for the given message identifier.
buildPublishReleaseMessage()  : string
Builds a publish release message for the given message identifier.
buildSubscribeMessage()  : string
Builds a subscribe message from the given parameters.
buildUnsubscribeMessage()  : string
Builds an unsubscribe message from the given parameters.
handleConnectAcknowledgement()  : void
Handles the connect acknowledgement received from the broker. Exits normally if the connection could be established successfully according to the response. Throws an exception if the broker responded with an error.
parseAndValidateMessage()  : Message|null
Parses and validates the given message based on its message type and contents.
tryFindMessageInBuffer()  : bool
Try to parse a message from the incoming buffer. If a message could be parsed successfully, the given message parameter is set to the parsed message and the result is true.

Methods

buildConnectMessage()

Builds a connect message from the given connection settings, taking the protocol specifics into account.

public buildConnectMessage(ConnectionSettings $connectionSettings[, bool $useCleanSession = false ]) : string
Parameters
$connectionSettings : ConnectionSettings
$useCleanSession : bool = false
Return values
string

buildDisconnectMessage()

Builds a disconnect message.

public buildDisconnectMessage() : string
Return values
string

buildPingRequestMessage()

Builds a ping request message.

public buildPingRequestMessage() : string
Return values
string

buildPingResponseMessage()

Builds a ping response message.

public buildPingResponseMessage() : string
Return values
string

buildPublishAcknowledgementMessage()

Builds a publish acknowledgement for the given message identifier.

public buildPublishAcknowledgementMessage(int $messageId) : string
Parameters
$messageId : int
Return values
string

buildPublishCompleteMessage()

Builds a publish complete message for the given message identifier.

public buildPublishCompleteMessage(int $messageId) : string
Parameters
$messageId : int
Return values
string

buildPublishMessage()

Builds a publish message based on the given parameters.

public buildPublishMessage(string $topic, string $message, int $qualityOfService, bool $retain[, int|null $messageId = null ][, bool $isDuplicate = false ]) : string
Parameters
$topic : string
$message : string
$qualityOfService : int
$retain : bool
$messageId : int|null = null
$isDuplicate : bool = false
Return values
string

buildPublishReceivedMessage()

Builds a publish received message for the given message identifier.

public buildPublishReceivedMessage(int $messageId) : string
Parameters
$messageId : int
Return values
string

buildPublishReleaseMessage()

Builds a publish release message for the given message identifier.

public buildPublishReleaseMessage(int $messageId) : string
Parameters
$messageId : int
Return values
string

buildSubscribeMessage()

Builds a subscribe message from the given parameters.

public buildSubscribeMessage(int $messageId, array<string|int, Subscription$subscriptions[, bool $isDuplicate = false ]) : string
Parameters
$messageId : int
$subscriptions : array<string|int, Subscription>
$isDuplicate : bool = false
Return values
string

buildUnsubscribeMessage()

Builds an unsubscribe message from the given parameters.

public buildUnsubscribeMessage(int $messageId, array<string|int, string> $topics[, bool $isDuplicate = false ]) : string
Parameters
$messageId : int
$topics : array<string|int, string>
$isDuplicate : bool = false
Return values
string

handleConnectAcknowledgement()

Handles the connect acknowledgement received from the broker. Exits normally if the connection could be established successfully according to the response. Throws an exception if the broker responded with an error.

public handleConnectAcknowledgement(string $message) : void
Parameters
$message : string
Tags
throws
ConnectingToBrokerFailedException
Return values
void

tryFindMessageInBuffer()

Try to parse a message from the incoming buffer. If a message could be parsed successfully, the given message parameter is set to the parsed message and the result is true.

public tryFindMessageInBuffer(string $buffer, int $bufferLength[, string|null &$message = null ][, int &$requiredBytes = -1 ]) : bool

If no message could be parsed, the result is false and the required bytes parameter indicates how many bytes are missing for the message to be complete. If this parameter is set to -1, it means we have no (or not yet) knowledge about the required bytes.

Parameters
$buffer : string
$bufferLength : int
$message : string|null = null
$requiredBytes : int = -1
Return values
bool

Search results