okay
1 Like
I have a Notifier acting like a gateway between the chat system and Phoenix.
Whenever a user receive a message, it will be notified like thisβ¦
defmodule AppApiWeb.Notifier do
require Logger
alias AppApiWeb.Endpoint
def notify(%{payload: %{from: from, to: to}, type: :ping}) do
Endpoint.broadcast!("user:#{to}", "ping", %{from: from})
end
def notify(message) do
Logger.debug(fn -> "Unknown notification #{inspect(message)}" end)
end
end
Only the user of the channel can receive the message.
Here it is just a ping, but You can add a message if You want.
okay bro
I am following the pattern of 1 channel for each user. I am using MyAppWeb.Endpoint.Broadcast to send messages to the other topic.
How do I test the other topic has received the message & forwarded it to the client?
Thanks
1 Like