Subscription enumeration, tweaks

This commit is contained in:
2024-03-11 14:39:58 +01:00
parent 2747b59abc
commit 8cbd12ee61
6 changed files with 76 additions and 23 deletions

View File

@ -5,14 +5,18 @@ namespace NoccyLabs\Mercureact\Broker;
use NoccyLabs\SimpleJWT\JWTToken;
use Psr\Http\Message\ServerRequestInterface;
use React\Stream\WritableStreamInterface;
use Symfony\Component\Uid\Uuid;
class SseSubscriber implements SubscriberInterface
{
private string $id;
public function __construct(
private WritableStreamInterface $stream,
private ServerRequestInterface $request,
)
{
$this->id = (string)Uuid::v7();
}
public function deliver(Message $message): void
@ -24,4 +28,9 @@ class SseSubscriber implements SubscriberInterface
{
return $this->request->getAttribute('authorization') instanceof JWTToken;
}
public function getId(): string
{
return "urn:uuid:".$this->id;
}
}