I am using phoenix framework, so:
I have the follow code at /web/static/js/socket.js
chatInput.on("keypress", event => {
if (event.keyCode === 13) {
channel.push("new_msg", {body: chatInput.val()}); //im want to pass @conn here
chatInput.val("")
}
});
and at /web/channels/room_channel:
use Phoenix.Channel
defmodule fooBar do
def handle_in("new_msg", %{"body" => body}, socket) do #and get conn here
broadcast! socket, "new_msg", %{body: body}
{:noreply, socket}
end
end
I need to get conn at room_channel. How can I pass it at socket.js?
conndo you want? and more importantly what are you trying to do withconnin a channel? (Asking because a Conn is only created for HTTP requests AFAIK.) - Dogbert