Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable collaborative tetris #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/tetris.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ defmodule Tetris do
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Tetris.Supervisor]
start_game
Supervisor.start_link(children, opts)
end

Expand Down
6 changes: 4 additions & 2 deletions web/channels/game.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ defmodule Tetris.GameChannel do

def handle_in("event", %{"event" => event_name}, socket) do
# NOTE: Don't use String.to_atom like this folks
Tetris.Game.handle_input(:game, String.to_atom(event_name))
Tetris.Game.handle_input(socket.assigns[:game], String.to_atom(event_name))
{:noreply, socket}
end

def handle_info(:after_join, socket) do
spawn(fn() -> Tetris.Websocket.run(:game, socket) end)
{:ok, game} = Tetris.Game.start
spawn(fn() -> Tetris.Websocket.run(game, socket) end)
socket = assign(socket, :game, game)
{:noreply, socket}
end
end