Skip to content

Commit e6d398e

Browse files
author
prophet777
committed
Update docs
1 parent f855298 commit e6d398e

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

Resources/docs/Pusher.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,31 @@ $pusher->push(['my_data' => 'data'], 'user_notification', ['username' => 'user1'
107107

108108
**NOTE :** Websocket Pusher is not the most faster and powerfull because he have a lot of overhead.
109109

110+
## Rely push to your topic
111+
112+
Implement `PushableTopicInterface` interface to your topic
113+
```php
114+
use Gos\Bundle\WebSocketBundle\Router\WampRequest;
115+
use Gos\Bundle\WebSocketBundle\Topic\PushableTopicInterface;
116+
use Gos\Bundle\WebSocketBundle\Topic\TopicInterface;
117+
use Ratchet\ConnectionInterface;
118+
use Ratchet\Wamp\Topic;
119+
120+
class AcmeTopic implements TopicInterface, PushableTopicInterface
121+
{
122+
/**
123+
* @param Topic $topic
124+
* @param WampRequest $request
125+
* @param array|string $data
126+
* @param string $provider The name of pusher who push the data
127+
*/
128+
public function onPush(Topic $topic, WampRequest $request, $data, $provider)
129+
{
130+
$topic->broadcast($data);
131+
}
132+
}
133+
```
134+
110135
# Pusher event
111136

112137
When pusher send message or fail to send it, we dispatch event to allow you to plug your own logic.
@@ -144,5 +169,3 @@ $pusher->push($message, 'user_notification', ['username' => 'user1']);
144169
$pusher = $this->container->get('gos_web_socket.zmq.pusher');
145170
$pusher->push($message, 'user_notification', ['username' => 'user1']);
146171
```
147-
148-

0 commit comments

Comments
 (0)