Read config, handle lastEventId in topicmanager

This commit is contained in:
2024-03-11 22:12:01 +01:00
parent 8cbd12ee61
commit 99b5710c59
8 changed files with 71 additions and 13 deletions

View File

@ -9,6 +9,8 @@ class TopicManager
/** @var array<string,Topic> */
private array $topics = [];
private ?string $lastEventId = null;
private SplObjectStorage $subscribers;
public function __construct()
@ -26,6 +28,7 @@ class TopicManager
public function publish(Message $message): void
{
$this->lastEventId = $message->id;
foreach ($message->topic as $topic) {
$this->getTopic($topic)->publish($message);
}
@ -66,7 +69,7 @@ class TopicManager
'topic' => $topic->getTopic(),
'subscriber' => $sub->getId(),
'active' => true,
'payload' => null,
'payload' => null, // TODO populate from mercure.payload in JWT
];
}
}
@ -74,6 +77,11 @@ class TopicManager
return $all;
}
public function getLastEventId(): ?string
{
return ($this->lastEventId !== null)?("urn:uuid:".$this->lastEventId):null;
}
public function getTopicCount(): int
{
return count($this->topics);