向发件人以外的所有用户发布消息

时间:2019-05-27 06:29:07

标签: php websocket broadcast symfony-3.4 phpwebsocket

我正在使用GosWebSocketBundle(https://github.com/GeniusesOfSymfony/WebSocketBundle)发送通知/消息。我已经将文档转至公共频道的所有订户并处理了广播消息。但是我不希望发件人收到它自己的消息。请帮助我。

public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
{
//this will broadcast the message to ALL subscribers of this topic.
$topic->broadcast(['msg' => $connection->resourceId . " has joined " . $topic->getId()]);
}

public function onPublish(ConnectionInterface $connection, Topic $topic, WampRequest $request, $event, array $exclude, array $eligible)
{
$topic->broadcast(['msg' => $event]);
}

0 个答案:

没有答案