From 26bddef1885f89a76f120c2909d776d4077ad9ca Mon Sep 17 00:00:00 2001 From: Josh Adams Date: Sat, 25 Apr 2015 21:44:22 -0500 Subject: [PATCH] Disable collaborative tetris We want a game per user to show off simple_one_for_one --- lib/tetris.ex | 1 - web/channels/game.ex | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/tetris.ex b/lib/tetris.ex index 17a706c..698fa65 100644 --- a/lib/tetris.ex +++ b/lib/tetris.ex @@ -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 diff --git a/web/channels/game.ex b/web/channels/game.ex index 7f5fbc1..4d26b64 100644 --- a/web/channels/game.ex +++ b/web/channels/game.ex @@ -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