221V 3 лет назад
Родитель
Сommit
2576eeaad3
4 измененных файлов с 29 добавлено и 21 удалено
  1. 1 1
      ebin/n4u.app
  2. 1 1
      src/endpoints/n2o_proto.erl
  3. 0 19
      src/protocols/n2o_client.erl
  4. 27 0
      src/protocols/n4u_client.erl

+ 1 - 1
ebin/n4u.app

@@ -2,7 +2,7 @@
   {description, "N4U WebSocket Application Server"},
   {vsn, "4.4.20"},
   {applications, [kernel, stdlib, asn1, public_key, ssl, crypto, ranch, cowboy, fs, active, sh, gproc, nitro]},
-  {modules, [n2o, n4u_app, n4u_sup, n4u_async, n2o_xhr, n2o_cx, n2o_cowboy, n2o_multipart, n2o_static, n2o_stream, n2o_document, n2o_proto, n2o_relay, n2o_error, n2o_io, n2o_log, n2o_mq, n2o_pickle, n2o_query, n2o_secret, n2o_session, n2o_syn, n2o_client, n2o_file, n2o_heart, n2o_http, n2o_nitrogen, n2o_text, wf, wf_convert, wf_utils]},
+  {modules, [n2o, n4u_app, n4u_sup, n4u_async, n2o_xhr, n2o_cx, n2o_cowboy, n2o_multipart, n2o_static, n2o_stream, n2o_document, n2o_proto, n2o_relay, n2o_error, n2o_io, n2o_log, n2o_mq, n2o_pickle, n2o_query, n2o_secret, n2o_session, n2o_syn, n4u_client, n2o_file, n2o_heart, n2o_http, n2o_nitrogen, n2o_text, wf, wf_convert, wf_utils]},
   {registered, [n4u_sup]},
   {mod, {n4u_app, []}},
   {env, []}

+ 1 - 1
src/endpoints/n2o_proto.erl

@@ -8,7 +8,7 @@ upack(D)    -> binary_to_term(D,[safe]).
 protocols() -> wf:config(n2o,protocols,[ n2o_heart,
                                          n2o_nitrogen,
                                          n2o_file,
-                                         n2o_client,
+                                         n4u_client,
                                          n2o_http ]).
 
 terminate(_,#cx{module=Module}) -> catch Module:event(terminate).

+ 0 - 19
src/protocols/n2o_client.erl

@@ -1,19 +0,0 @@
--module(n2o_client).
--include_lib("n4u/include/n4u.hrl").
--compile([export_all, nowarn_export_all]).
-
-info({client,Message}, Req, State) ->
-    wf:info(?MODULE,"Client Message: ~p",[Message]),
-    Module = State#cx.module,
-    Reply = try Module:event({client,Message})
-          catch E:R -> Error = wf:stack(E,R), wf:error(?MODULE,"Catch: ~p:~p~n~p",Error), Error end,
-    {reply,wf:format({io,n2o_nitrogen:render_actions(wf:actions()),Reply}),Req,State};
-
-info({server,Message}, Req, State) ->
-    wf:info(?MODULE,"Server Message: ~p",[Message]),
-    Module = State#cx.module,
-    Reply  = try Module:event({server,Message})
-           catch E:R -> Error = wf:stack(E,R), wf:error(?MODULE,"Catch: ~p:~p~n~p",Error), Error end,
-    {reply,wf:format({io,n2o_nitrogen:render_actions(wf:actions()),Reply}),Req,State};
-
-info(Message, Req, State) -> {unknown,Message, Req, State}.

+ 27 - 0
src/protocols/n4u_client.erl

@@ -0,0 +1,27 @@
+-module(n4u_client).
+-include_lib("n4u/include/n4u.hrl").
+
+-export([info/3]).
+
+info({client, Message}, Req, State) ->
+  wf:info(?MODULE, "Client Message: ~p", [Message]),
+  Module = State#cx.module,
+  Reply = try Module:event({client, Message})
+  catch E:R:Stk ->
+    wf:error(?MODULE, "Catch: ~p:~p~n~p", [E, R, Stk]),
+    [E, R, Stk]
+  end,
+  {reply, wf:format({io, n2o_nitrogen:render_actions(erlang:get(actions)), Reply}), Req, State};
+
+info({server, Message}, Req, State) ->
+  wf:info(?MODULE, "Server Message: ~p", [Message]),
+  Module = State#cx.module,
+  Reply = try Module:event({server, Message})
+  catch E:R:Stk ->
+    wf:error(?MODULE, "Catch: ~p:~p~n~p", [E, R, Stk]),
+    [E, R, Stk]
+  end,
+  {reply, wf:format({io, n2o_nitrogen:render_actions(erlang:get(actions)), Reply}), Req, State};
+
+info(Message, Req, State) -> {unknown, Message, Req, State}.
+