diff --git a/lib/login.ex b/lib/login.ex index 45af81e..2ac31c4 100644 --- a/lib/login.ex +++ b/lib/login.ex @@ -4,11 +4,13 @@ defmodule Sample.Login do require Logger def event(:init) do - login_button = NITRO.button(id: :loginButton, body: "HELO", postback: :login2, source: [:user, :room]) + :io.format 'LOGIN INIT' + login_button = NITRO.button(id: :loginButton, body: "HELO", postback: :login, source: [:user, :room]) :nitro.update(:loginButton, login_button) end - def event(:login2) do + def event(:login) do + :io.format 'LOGIN PRESSED' user = :nitro.to_list(:nitro.q(:user)) room = :nitro.to_binary(:nitro.q(:room)) :n2o.user(user) diff --git a/lib/ws.ex b/lib/ws.ex index f6acef0..1bf461a 100644 --- a/lib/ws.ex +++ b/lib/ws.ex @@ -14,7 +14,12 @@ defmodule Sample.WS do def init(args), do: {:ok, N2O.cx(module: Keyword.get(args, :module)) } def handle_in({"N2O," <> _ = message, _}, state), do: response(:n2o_proto.stream({:text,message},[],state)) def handle_in({"PING", _}, state), do: {:reply, :ok, {:text, "PONG"}, state} - def handle_in({message, _}, state), do: response(:n2o_proto.stream(message,[],state)) + def handle_in({message, _}, state) do + :io.format 'Message: ~p~n', [:erlang.binary_to_term(message)] + x = :n2o_proto.stream(message,[],state) + :io.format 'X: ~p~n', [x] + response(x) + end def response({:reply,{:binary,rep},_,s}), do: {:reply,:ok,{:binary,rep},s} def response({:reply,{:text,rep},_,s}), do: {:reply,:ok,{:text,rep},s}