From 2f3483e746783374abb4d98abbb2e0c83bae3bd8 Mon Sep 17 00:00:00 2001 From: SisMaker <156736github> Date: Sat, 15 Jan 2022 00:45:46 +0800 Subject: [PATCH] =?UTF-8?q?ft:=20=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + include/eWSrv.hrl | 13 ++++--------- src/eWSrv.erl | 8 +++++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 0ad44f1..8a1c036 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .eunit *.o *.beam +*.app *.plt erl_crash.dump .concrete/DEV_MODE diff --git a/include/eWSrv.hrl b/include/eWSrv.hrl index 3ad4782..05a9f4a 100644 --- a/include/eWSrv.hrl +++ b/include/eWSrv.hrl @@ -1,3 +1,5 @@ +-include_lib("eNet/include/eNet.hrl"). + -define(DefWsOpts, [ binary , {packet, 4} @@ -13,15 +15,8 @@ -export_type([wsOpt/0]). -type wsOpt() :: - {aptCnt, non_neg_integer()} | - {tcpOpts, [gen_tcp:listen_option()]} | - {sslOpts, [ssl:ssl_option()]} | - {sslHSTet, timeout()} | - {udpOpts, [gen_udp:option()]} | - {proxyPt, boolean()} | - {proxyPtTet, timeout() | - {wsMod, module()} -}. + listenOpt() | + {wsMod, module()}. -record(req, { method :: elli:http_method(), diff --git a/src/eWSrv.erl b/src/eWSrv.erl index 2446a57..7ab12d8 100644 --- a/src/eWSrv.erl +++ b/src/eWSrv.erl @@ -9,16 +9,18 @@ startWSrv(WSrvName, Port, WsOpts) -> ListenName = wsUtil:lsName(WSrvName), + TWsOpts = lists:keystore(conMod, 1, WsOpts, {conMod, wsHttp}), + LWsOpts = lists:keystore(conArgs, 1, TWsOpts, {conArgs, WSrvName}), case ?wsGLV(sslOpts, WsOpts, false) of false -> - {ok, _} = eNet:openTcp(ListenName, Port, WsOpts); + {ok, _} = eNet:openTcp(ListenName, Port, LWsOpts); _ -> - {ok, _} = eNet:openSsl(ListenName, Port, WsOpts) + {ok, _} = eNet:openSsl(ListenName, Port, LWsOpts) end, ConSupSpec = #{ id => WSrvName, - start => {wsConSup, start_link, [ListenName]}, + start => {wsConSup, start_link, [WSrvName]}, restart => permanent, shutdown => infinity, type => supervisor,