fix payload handling
This commit is contained in:
parent
24bb90c21e
commit
67c92cd8cc
|
@ -50,7 +50,7 @@ defmodule Chat.Application do
|
||||||
[{:RelativeDistinguishedName, {0, 9, 2342, 19200300, 100, 1, 4}, name}] = attrs
|
[{:RelativeDistinguishedName, {0, 9, 2342, 19200300, 100, 1, 4}, name}] = attrs
|
||||||
{:ok, source_encd} = :FloofProtocol.encode(:RDNSequence, source)
|
{:ok, source_encd} = :FloofProtocol.encode(:RDNSequence, source)
|
||||||
source_encd = Base.url_encode64(source_encd)
|
source_encd = Base.url_encode64(source_encd)
|
||||||
ChatWeb.Endpoint.broadcast!("room:lobby", "shout", %{name: source_encd <> " :: " <> name, message: data})
|
ChatWeb.Endpoint.broadcast!("room:lobby", "shout", %{"name" => source_encd <> " :: " <> name, "message" => data})
|
||||||
end
|
end
|
||||||
x -> Logger.error("unable to handle message #{inspect(x)}")
|
x -> Logger.error("unable to handle message #{inspect(x)}")
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,7 @@ defmodule ChatWeb.RoomChannel do
|
||||||
# broadcast to everyone in the current topic (room:lobby).
|
# broadcast to everyone in the current topic (room:lobby).
|
||||||
@impl true
|
@impl true
|
||||||
def handle_in("shout", payload, socket) do
|
def handle_in("shout", payload, socket) do
|
||||||
Chat.Floof.send_message(payload.name, payload.message)
|
Chat.Floof.send_message(payload["name"], payload["message"])
|
||||||
broadcast(socket, "shout", payload)
|
broadcast(socket, "shout", payload)
|
||||||
{:noreply, socket}
|
{:noreply, socket}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue