Also forgot XyChannel

parent 61a10162
......@@ -3,7 +3,7 @@ defmodule Grains.Mixfile do
def project do
[app: :grains,
version: "0.0.89",
version: "0.0.90",
elixir: "~> 1.2",
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
......
defmodule Grains.XyChannel do
use Grains.Web, :channel
require Logger
alias Grains.StatefulMap
alias Grains.ValueView
def join("xy:" <> _xy_id, _params, socket) do
Logger.info("joined xy")
uuid = socket.assigns.user_uuid
nr = StatefulMap.get(uuid)
resp = %{dot_id: nr}
{:ok, resp, socket}
end
def handle_in("xy", params, socket) do
Logger.info("xy #{inspect(params)}")
IO.puts inspect(params)
uuid = socket.assigns.user_uuid
x = params["x"]
y = params["y"]
Grengine.Performance.set_values(uuid, %{
x: x,
y: y,
}
)
Grains.Endpoint.broadcast "visuals:data", "velocity", %{user: uuid, dx: x, dy: y}
{:reply, :ok, socket}
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment