Skip to content

Instantly share code, notes, and snippets.

@darui00kara
Created June 7, 2015 06:00
Show Gist options
  • Save darui00kara/6639e3745d41002d9b53 to your computer and use it in GitHub Desktop.
Save darui00kara/6639e3745d41002d9b53 to your computer and use it in GitHub Desktop.
defmodule PhoenixChannels.RoomChannel do
use Phoenix.Channel
def join("rooms:lobby", auth_msg, socket) do
{:ok, socket}
end
def join("rooms:" <> _private_room_id, _auth_msg, socket) do
{:error, %{reason: "unauthorized"}}
end
def handle_in("new_msg", %{"body" => body}, socket) do
broadcast! socket, "new_msg", %{body: body}
{:noreply, socket}
end
def handle_out("new_msg", payload, socket) do
push socket, "new_msg", payload
{:noreply, socket}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment