Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/topics.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ To implement an example fulfilling a scenario of "every 5 minutes all subscriber

You will need to add these two methods to your Topic:

- `public function registerPeriodicTimer(Topic $topic): void`
- `public function registerPeriodicTimer(Topic $topic, WampRequest $request): void`
- `public function setPeriodicTimer(TopicPeriodicTimer $periodicTimer): void`

The `Gos\Bundle\WebSocketBundle\Topic\TopicPeriodicTimerTrait` is available to help implement the interface.
Expand All @@ -215,6 +215,7 @@ The `Gos\Bundle\WebSocketBundle\Topic\TopicPeriodicTimerTrait` is available to h

namespace App\Websocket\Topic;

use Gos\Bundle\WebSocketBundle\Router\WampRequest;
use Gos\Bundle\WebSocketBundle\Topic\TopicPeriodicTimerInterface;
use Gos\Bundle\WebSocketBundle\Topic\TopicPeriodicTimerTrait;
use Ratchet\Wamp\Topic;
Expand All @@ -223,7 +224,7 @@ class AcmePeriodicTopic extends AcmeTopic implements TopicPeriodicTimerInterface
{
use TopicPeriodicTimerTrait;

public function registerPeriodicTimer(Topic $topic): void
public function registerPeriodicTimer(Topic $topic, WampRequest $request): void
{
// Adds the periodic timer the first time a client connects to the topic
$this->periodicTimer->addPeriodicTimer(
Expand Down
2 changes: 1 addition & 1 deletion src/Server/App/Dispatcher/TopicDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function dispatch(

if (!$this->topicPeriodicTimer->isRegistered($appTopic) && 0 !== \count($topic)) {
try {
$appTopic->registerPeriodicTimer($topic);
$appTopic->registerPeriodicTimer($topic, $request);
} catch (\Throwable $e) {
if (null !== $this->logger) {
$this->logger->error(
Expand Down
3 changes: 2 additions & 1 deletion src/Topic/TopicPeriodicTimerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Gos\Bundle\WebSocketBundle\Topic;

use Gos\Bundle\WebSocketBundle\Router\WampRequest;
use Ratchet\Wamp\Topic;

interface TopicPeriodicTimerInterface
{
public function registerPeriodicTimer(Topic $topic): void;
public function registerPeriodicTimer(Topic $topic, WampRequest $request): void;

public function setPeriodicTimer(TopicPeriodicTimer $periodicTimer): void;
}
2 changes: 1 addition & 1 deletion tests/Server/App/Dispatcher/TopicDispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public function getName(): string
return 'topic.handler';
}

public function registerPeriodicTimer(Topic $topic): void
public function registerPeriodicTimer(Topic $topic, WampRequest $request): void
{
$this->registered = true;
}
Expand Down