Refactor code

This commit is contained in:
linjun 2019-02-27 13:54:24 +08:00
parent 760ac9f2f9
commit 7af6051e25
3 changed files with 6 additions and 6 deletions

View File

@ -131,11 +131,11 @@ init([Transport, RawSocket, Options]) ->
EnableStats = emqx_zone:get_env(Zone, enable_stats, true),
IdleTimout = emqx_zone:get_env(Zone, idle_timeout, 30000),
SendFun = send_fun(Transport, Socket),
SockType = Transport:type(Socket),
ProtoState = emqx_protocol:init(#{peername => Peername,
sockname => Sockname,
peercert => Peercert,
sendfun => SendFun,
socktype => Transport:type(Socket)}, Options),
sendfun => SendFun}, [Options ++ [{socktype, SockType}]]),
ParserState = emqx_protocol:parser(ProtoState),
GcPolicy = emqx_zone:get_env(Zone, force_gc_policy, false),
GcState = emqx_gc:init(GcPolicy),

View File

@ -83,8 +83,9 @@
%%------------------------------------------------------------------------------
-spec(init(map(), list()) -> state()).
init(#{peername := Peername, peercert := Peercert, sendfun := SendFun, socktype := SockType}, Options) ->
init(#{peername := Peername, peercert := Peercert, sendfun := SendFun}, Options) ->
Zone = proplists:get_value(zone, Options),
SockType = proplists:get_value(socktype, Options, tcp),
#pstate{zone = Zone,
sendfun = SendFun,
peername = Peername,

View File

@ -126,8 +126,7 @@ websocket_init(#state{request = Req, options = Options}) ->
ProtoState = emqx_protocol:init(#{peername => Peername,
sockname => Sockname,
peercert => Peercert,
sendfun => send_fun(self()),
socktype => websocket}, Options),
sendfun => send_fun(self())}, [Options ++ [{socktype, websocket}]]),
ParserState = emqx_protocol:parser(ProtoState),
Zone = proplists:get_value(zone, Options),
EnableStats = emqx_zone:get_env(Zone, enable_stats, true),