Django频道 - 可能“仅写”频道组?
希望这是有道理的。我正在使用Django渠道构建一个应用程序,该应用程序有点像测验 - 有一个主机和多个玩家。当房子的玩家一侧出现问题时,我希望特定的玩家消费者向主机组发送消息 - 这很容易。不幸的是,由于所有玩家消费者都需要附加到主机组以发送消息,因此他们也会接收这些消息并将其发送给其连接的客户。因此,如果播放器1的消费者发生问题,当我要做的就是提醒主机时,它最终会被广播给玩家2,播放器3等。
我已经考虑过在这样的消息中使用“无手”标志来执行此操作,但是是否有一种更干净的方法可以做我想要的事情?
Hopefully this is gonna make sense. I am building an app using django-channels that works a little bit like a quiz - there is a host, and multiple players. When something goes wrong in the player side of the house I want the specific player consumer to send a message to the host group - which is easy enough. Unfortunately, because all player consumers need to be attached to the host group to send messages, they also receive those and send them to their connected clients. Thus if an issue occurs with player 1's consumer, it ultimately gets broadcast to player 2, player 3, etc, when all I want to do is alert the host.
I've thought about doing this with a 'no-handle' flag in such messages, but is there a cleaner method of doing what I want?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,这比我预期的要简单得多。
group_add()
订阅消息,但是如果没有该步骤,仍然可以group_send()
到组 - 因此可以将异常处理播放器1发送到主机组没有任何玩家在该组中收到消息。Turns out this was a lot simpler than I expected.
group_add()
subscribes to messages, but without that step it is still possible togroup_send()
to a group - so an exception processing player 1 can be sent to the host group without any players receiving messages in that group.