Read config, handle lastEventId in topicmanager
This commit is contained in:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user