So your saying I can declare a set of handle_info functions inside the channel which will match the information being broadcast from Redis?
From what I’ve trie using the Phoenix_PubSub_Redis adapter provides the following functions:
def handle_info({:redix_pubsub, redix_pid, :subscribed, _}, %{redix_pid: redix_pid} = state) do
{:noreply, state}
end
def handle_info({:redix_pubsub, redix_pid, :message, %{payload: bin_msg}}, %{redix_pid: redix_pid} = state) do
{_vsn, remote_node_ref, fastlane, pool_size, from_pid, topic, msg} = :erlang.binary_to_term(bin_msg)
if remote_node_ref == state.node_ref do
Local.broadcast(fastlane, state.server_name, pool_size, from_pid, topic, msg)
else
Local.broadcast(fastlane, state.server_name, pool_size, :none, topic, msg)
end
{:noreply, state}
end
These will catch any information flowing over the selected channel. In this case its phx:Elixir.TpPhoenix.PubSub
. However this doesn’t allow me to choose the channel to listen to based on the key the user sent in.
Similarly Redix_PubSub uses the recieve do
to match the message format in Redis.