如何从Phoenix Controller向频道广播消息? [英] How to broadcast a message from a Phoenix Controller to a Channel?
本文介绍了如何从Phoenix Controller向频道广播消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以从该频道外部向该频道广播消息?
Is there a way to broadcast a message to a channel from outside that channel?
也许像Channel.broadcast topic, event, data
一样?
我在此处看到了类似的内容,但是Phoenix.Channel.broadcast/3
的最终版本(截至今天)表示频道和主题的套接字.
I saw something like this here but the final version of Phoenix.Channel.broadcast/3
(as of today) takes a socket which implies the channel and topic.
推荐答案
您可以使用MyApp.Endpoint.broadcast(topic, event, msg)
.
检查 http://hexdocs.pm/phoenix/Phoenix.Endpoint.html
这篇关于如何从Phoenix Controller向频道广播消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文