Elixir processes/agents and channels

Hi,
is there any way to subscribe processes/agents to phoenix channels ?
I receive data via websockex communication .
When I receive package I want to send data to channel and resend to subscribers of this channel .
I don’t want to after receiving data send it directly to certain process/agent , because number of “living” processes is changing very dynamically . And I would have to create some kind of registry where to send data .
So I want to use channel communication .
Thanks in advance for any suggestion .

Hello,
Your channel has some topic, you can broadcast a message to the channel from whatever place just using this topic.
https://hexdocs.pm/phoenix/Phoenix.Channel.html#module-broadcasting-to-an-external-topic

1 Like

Hi, thanks for tip.
But i can’t figure it out how to channel knows where to send message (to which process) .
I’ve got agent and I want to catch message from channel .
How to subscribe certain processs/agent (pid) to the right topic ? Or how the process is listen to messages ?
I think I don’t understand conception .
Regards

It is a publish/subscribe system… If You want your agents to listen to messages, just make them subscribe to the channel topic.

1 Like