221V 3 лет назад
Родитель
Сommit
3315783a7f
4 измененных файлов с 21 добавлено и 10 удалено
  1. 1 1
      ebin/n4u.app
  2. 0 8
      src/handlers/n2o_pickle.erl
  3. 19 0
      src/handlers/n4u_pickle.erl
  4. 1 1
      src/wf.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, n4u_cx, n2o_cowboy, n2o_multipart, n2o_static, n2o_stream, n4u_document, n2o_proto, n2o_relay, n4u_error, n4u_io, n4u_log, n4u_mq, n2o_pickle, n2o_query, n2o_secret, n2o_session, n4u_syn, n4u_client, n4u_file, n4u_heart, n4u_http, n4u_nitrogen, n4u_text, wf, wf_convert, wf_utils]},
+  {modules, [n2o, n4u_app, n4u_sup, n4u_async, n2o_xhr, n4u_cx, n2o_cowboy, n2o_multipart, n2o_static, n2o_stream, n4u_document, n2o_proto, n2o_relay, n4u_error, n4u_io, n4u_log, n4u_mq, n4u_pickle, n2o_query, n2o_secret, n2o_session, n4u_syn, n4u_client, n4u_file, n4u_heart, n4u_http, n4u_nitrogen, n4u_text, wf, wf_convert, wf_utils]},
   {registered, [n4u_sup]},
   {mod, {n4u_app, []}},
   {env, []}

+ 0 - 8
src/handlers/n2o_pickle.erl

@@ -1,8 +0,0 @@
--module(n2o_pickle).
--include_lib("n4u/include/n4u.hrl").
--export([pickle/1, depickle/1]).
-
-pickle(Data) -> base64:encode(term_to_binary({Data, os:timestamp()}, [compressed])).
-depickle(PickledData) ->
-    try {Data, _PickleTime} = binary_to_term(base64:decode(wf:to_binary(PickledData))), Data
-    catch _:_ -> undefined end.

+ 19 - 0
src/handlers/n4u_pickle.erl

@@ -0,0 +1,19 @@
+-module(n4u_pickle).
+
+-export([pickle/1, depickle/1]).
+
+
+% base64 encode/decode
+
+pickle(Data) ->
+  base64:encode(erlang:term_to_binary({Data, os:timestamp()}, [compressed])).
+
+
+depickle(Serialized_Data) ->
+  try
+    {Data, _PickleTime} = erlang:binary_to_term(base64:decode(nitro:to_binary(Serialized_Data))),
+    Data
+  catch _:_ ->
+    undefined
+  end.
+

+ 1 - 1
src/wf.erl

@@ -90,7 +90,7 @@ unreg(Pool) -> ?REGISTRATOR:unreg(Pool).
 % Pickling wf:pickle
 
 -ifndef(PICKLER).
--define(PICKLER, (wf:config(n2o,pickler,n2o_pickle))).
+-define(PICKLER, (wf:config(n4u, pickler, n4u_pickle))).
 -endif.
 
 pickle(Data) -> ?PICKLER:pickle(Data).