Implemented subscription logic
This commit is contained in:
24
src/Broker/SseSubscriber.php
Normal file
24
src/Broker/SseSubscriber.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace NoccyLabs\Mercureact\Broker;
|
||||
|
||||
use React\Stream\WritableStreamInterface;
|
||||
|
||||
class SseSubscriber implements SubscriberInterface
|
||||
{
|
||||
public function __construct(
|
||||
private WritableStreamInterface $stream
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
public function deliver(Message $message): void
|
||||
{
|
||||
$this->stream->write($message->toString());
|
||||
}
|
||||
|
||||
public function isAuthorized(string $topics): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user