首页 > 解决方案 > 向除发件人以外的所有用户发布消息

问题描述

我正在使用 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]);
}

标签: phpwebsocketbroadcastsymfony-3.4phpwebsocket

解决方案


推荐阅读