acceleration_channel.ex 636 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
defmodule Grains.AccelerationChannel do
  use Grains.Web, :channel

  require Logger

  def join("acceleration:" <> _orientation_id, _params, socket) do
    Logger.info("joined orientation")

    resp = %{values: []}
    {:ok, resp, socket}
  end

  def handle_in("acceleration", params, socket) do
    Logger.info("acceleration #{inspect(params)}")

    uuid = socket.assigns.user_uuid
    z = params["z"]

    Grengine.Performance.set_values(uuid, %{
          z: z
                                    } )

23
    Grains.Endpoint.broadcast "visuals:data", "acceleration", %{user: uuid, force: z}
24
25
26
27
28
29
30
31

    {:reply, :ok, socket}

  end



end