Skip to content

Instantly share code, notes, and snippets.

@bnhansn
Created October 22, 2016 12:21
Show Gist options
  • Save bnhansn/d445a32e46a22bd49873c32ffd97b813 to your computer and use it in GitHub Desktop.
Save bnhansn/d445a32e46a22bd49873c32ffd97b813 to your computer and use it in GitHub Desktop.
defmodule Sling.RoomChannel do
use Sling.Web, :channel
def join("rooms:" <> room_id, _params, socket) do
room = Repo.get!(Sling.Room, room_id)
response = %{
room: Phoenix.View.render_one(room, Sling.RoomView, "room.json"),
}
{:ok, response, assign(socket, :room, room)}
end
def terminate(_reason, socket) do
{:ok, socket}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment