Philip Claren
Philip Claren

Reputation: 2896

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.

Upvotes: 31

Views: 11757

Answers (1)

manukall
manukall

Reputation: 1462

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

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

Upvotes: 68

Related Questions