Created
June 7, 2015 06:00
-
-
Save darui00kara/6639e3745d41002d9b53 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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