Browse Source

Merge branch 'master' of https://github.com/kakaranet/games

Roman Dayneko 11 years ago
parent
commit
1db0b2c568
3 changed files with 7 additions and 7 deletions
  1. 2 1
      apps/face/priv/templates/index.html
  2. 1 0
      apps/face/rebar.config
  3. 4 6
      apps/face/src/n2o_game.erl

+ 2 - 1
apps/face/priv/templates/index.html

@@ -5,7 +5,8 @@
 </head>
 <body>
 {{body}}
-<script>var transition = {pid: '', port:'8000'}</script>
+<script>var transition = {pid: '', port:'8000'};</script>
+<script>function handle_web_socket(body) { console.log(body); } </script>
 <script src='/static/nitrogen/jquery.js' type='text/javascript' charset='utf-8'></script>
 <script src='/static/nitrogen/bullet.js' type='text/javascript' charset='utf-8'></script>
 <script src='/static/nitrogen/n2o.js' type='text/javascript' charset='utf-8'></script>

+ 1 - 0
apps/face/rebar.config

@@ -1,6 +1,7 @@
 {deps, [
     {erlydtl,".*",{git,"git://github.com/evanmiller/erlydtl.git",{tag,"0.8.0"}}},
     {shen,          ".*", {git, "git://github.com/5HT/shen",                "HEAD"}},
+    {rest,           ".*", {git, "git://github.com/synrc/rest",                "HEAD"}},
     {n2o,           ".*", {git, "git://github.com/5HT/n2o",                "HEAD"}}
 ]}.
 {erlydtl_opts, [

+ 4 - 6
apps/face/src/n2o_game.erl

@@ -44,7 +44,7 @@ html_events(Pro, State) ->
     GenActions = get(actions),
     RenderGenActions = wf:render(GenActions),
     wf_context:clear_actions(),
-    [Render,RenderGenActions].
+    [<<"EVAL">>,Render,RenderGenActions].
 
 stream(<<"ping">>, Req, State) ->
     wf:info("ping received~n"),
@@ -75,14 +75,12 @@ info({client,Message}, Req, State) ->
     game_session:process_request(GamePid, Message), 
     Module = State#context.module,
     catch Module:event({client,Message}),
-    {reply,[],Req,State};
+    {reply,<<"DATA">>,Req,State};
 
 info({send_message,Message}, Req, State) ->
     Module = State#context.module,
     catch Module:event({server,Message}),
-    Ret = io_lib:format("~p",[Message]),
-    T = wf:js_escape(Ret),
-    {reply,io_lib:format("console.log('~s')",[T]),Req,State};
+    {reply,[<<"DATA">>,io_lib:format("~p",[Message])],Req,State};
 
 info(Pro, Req, State) ->
     Render = 
@@ -126,7 +124,7 @@ info(Pro, Req, State) ->
     wf_context:clear_actions(),
     RenderGenActions = wf:render(GenActions),
     wf_context:clear_actions(),
-    {reply, [Render,RenderGenActions], Req, State}.
+    {reply, [<<"EVAL">>,Render,RenderGenActions], Req, State}.
 
 terminate(_Req, _State=#context{module=Module}) ->
     % wf:info("Bullet Terminated~n"),