MemoryRepository
in package
implements
Repository
Provides an in-memory implementation which manages message ids, subscriptions and pending messages.
Instances of this type do not persist any data and are only meant for simple uses cases.
Interfaces, Classes, Traits and Enums
- Repository
- Implementations of this interface provide storage capabilities to an MQTT client.
Table of Contents
- $nextMessageId : int
- $pendingIncomingMessages : array<string|int, mixed>
- $pendingOutgoingMessages : array<string|int, mixed>
- $subscriptions : array<string|int, mixed>
- addPendingIncomingMessage() : void
- Adds a pending outgoing message to the repository.
- addPendingOutgoingMessage() : void
- Adds a pending outgoing message to the repository.
- addSubscription() : void
- Adds a subscription to the repository.
- countPendingIncomingMessages() : int
- Returns the number of pending incoming messages.
- countPendingOutgoingMessages() : int
- Returns the number of pending outgoing messages.
- countSubscriptions() : int
- Returns the number of registered subscriptions.
- getPendingIncomingMessage() : PendingMessage|null
- Gets a pending incoming message with the given message identifier, if found.
- getPendingOutgoingMessage() : PendingMessage|null
- Gets a pending outgoing message with the given message identifier, if found.
- getPendingOutgoingMessagesLastSentBefore() : array<string|int, PendingMessage>
- Gets a list of pending outgoing messages last sent before the given date time.
- getSubscriptionsMatchingTopic() : array<string|int, Subscription>
- Gets all subscriptions matching the given topic.
- markPendingOutgoingPublishedMessageAsReceived() : bool
- Marks an existing pending outgoing published message as received in the repository.
- newMessageId() : int
- Returns a new message id. The message id might have been used before, but it is currently not being used (i.e. in a resend queue).
- removePendingIncomingMessage() : bool
- Removes a pending incoming message from the repository.
- removePendingOutgoingMessage() : bool
- Removes a pending outgoing message from the repository.
- removeSubscription() : bool
- Removes the subscription with the given topic filter from the repository.
- reset() : bool
- Re-initializes the repository by deleting all persisted data and restoring the original state, which was given when the repository was first created. This is used when a clean session is requested by a client during connection.
Properties
$nextMessageId
private
int
$nextMessageId
= 1
$pendingIncomingMessages
private
array<string|int, mixed>
$pendingIncomingMessages
= []
$pendingOutgoingMessages
private
array<string|int, mixed>
$pendingOutgoingMessages
= []
$subscriptions
private
array<string|int, mixed>
$subscriptions
= []
Methods
addPendingIncomingMessage()
Adds a pending outgoing message to the repository.
public
addPendingIncomingMessage(PendingMessage $message) : void
Parameters
- $message : PendingMessage
Return values
void —addPendingOutgoingMessage()
Adds a pending outgoing message to the repository.
public
addPendingOutgoingMessage(PendingMessage $message) : void
Parameters
- $message : PendingMessage
Return values
void —addSubscription()
Adds a subscription to the repository.
public
addSubscription(Subscription $subscription) : void
Parameters
- $subscription : Subscription
Return values
void —countPendingIncomingMessages()
Returns the number of pending incoming messages.
public
countPendingIncomingMessages() : int
Return values
int —countPendingOutgoingMessages()
Returns the number of pending outgoing messages.
public
countPendingOutgoingMessages() : int
Return values
int —countSubscriptions()
Returns the number of registered subscriptions.
public
countSubscriptions() : int
Return values
int —getPendingIncomingMessage()
Gets a pending incoming message with the given message identifier, if found.
public
getPendingIncomingMessage(int $messageId) : PendingMessage|null
Parameters
- $messageId : int
Return values
PendingMessage|null —getPendingOutgoingMessage()
Gets a pending outgoing message with the given message identifier, if found.
public
getPendingOutgoingMessage(int $messageId) : PendingMessage|null
Parameters
- $messageId : int
Return values
PendingMessage|null —getPendingOutgoingMessagesLastSentBefore()
Gets a list of pending outgoing messages last sent before the given date time.
public
getPendingOutgoingMessagesLastSentBefore([DateTime $dateTime = null ]) : array<string|int, PendingMessage>
Parameters
- $dateTime : DateTime = null
Return values
array<string|int, PendingMessage> —getSubscriptionsMatchingTopic()
Gets all subscriptions matching the given topic.
public
getSubscriptionsMatchingTopic(string $topicName) : array<string|int, Subscription>
Parameters
- $topicName : string
Return values
array<string|int, Subscription> —markPendingOutgoingPublishedMessageAsReceived()
Marks an existing pending outgoing published message as received in the repository.
public
markPendingOutgoingPublishedMessageAsReceived(int $messageId) : bool
Parameters
- $messageId : int
Return values
bool —newMessageId()
Returns a new message id. The message id might have been used before, but it is currently not being used (i.e. in a resend queue).
public
newMessageId() : int
Return values
int —removePendingIncomingMessage()
Removes a pending incoming message from the repository.
public
removePendingIncomingMessage(int $messageId) : bool
Parameters
- $messageId : int
Return values
bool —removePendingOutgoingMessage()
Removes a pending outgoing message from the repository.
public
removePendingOutgoingMessage(int $messageId) : bool
Parameters
- $messageId : int
Return values
bool —removeSubscription()
Removes the subscription with the given topic filter from the repository.
public
removeSubscription(string $topicFilter) : bool
Parameters
- $topicFilter : string
Return values
bool —reset()
Re-initializes the repository by deleting all persisted data and restoring the original state, which was given when the repository was first created. This is used when a clean session is requested by a client during connection.
public
reset() : bool