Created
January 26, 2022 23:22
-
-
Save KevinDaSilvaS/ef27231309a54f7c1da285e67bc3e313 to your computer and use it in GitHub Desktop.
consumer.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defp consume(channel, tag, _redelivered, payload) do | |
socket = Agent.SocketState.get_socket_state() | |
case socket do | |
{:ok, socket} -> | |
Logger.info "Message received: #{inspect(payload)}" | |
{:ok, parsed_payload} = Jason.decode payload | |
topic = "room:" <> parsed_payload["user_id"] | |
{:ok, joined} = SocketClient.join_topic socket, topic | |
SocketClient.push joined, topic, parsed_payload | |
:ok = Basic.ack channel, tag | |
_ -> | |
Logger.error "Notifier is not up yet" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment