Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
619 views
in Technique[技术] by (71.8m points)

elixir - How to broadcast a message from a Phoenix Controller to a Channel?

Is there a way to broadcast a message to a channel from outside that channel?

Maybe something like Channel.broadcast topic, event, data?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use MyApp.Endpoint.broadcast(topic, event, msg) for that.

Check http://hexdocs.pm/phoenix/Phoenix.Endpoint.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...