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.
Phoenix Channels can build bi-directional communication between message senders and receivers using channels. They are ideal for real-time applications. Sending and receiving messages is the basic concept of channels. Senders send out messages on a variety of themes.
Phoenix Channels are the perfect fit for real-time features. Channels allow us to establish bi-directional communication between message senders and receivers. Channels are based on a simple idea - sending and receiving messages. Senders broadcast messages about topics.
Phoenix comes with two default transports: websocket and longpoll. You can configure them directly via the socket declaration.
You can use MyApp.Endpoint.broadcast(topic, event, msg)
for that.
Check http://hexdocs.pm/phoenix/Phoenix.Endpoint.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With