Browse Source

ft: 代码修改

master
SisMaker 3 years ago
parent
commit
2f3483e746
3 changed files with 10 additions and 12 deletions
  1. +1
    -0
      .gitignore
  2. +4
    -9
      include/eWSrv.hrl
  3. +5
    -3
      src/eWSrv.erl

+ 1
- 0
.gitignore View File

@ -1,6 +1,7 @@
.eunit .eunit
*.o *.o
*.beam *.beam
*.app
*.plt *.plt
erl_crash.dump erl_crash.dump
.concrete/DEV_MODE .concrete/DEV_MODE

+ 4
- 9
include/eWSrv.hrl View File

@ -1,3 +1,5 @@
-include_lib("eNet/include/eNet.hrl").
-define(DefWsOpts, [ -define(DefWsOpts, [
binary binary
, {packet, 4} , {packet, 4}
@ -13,15 +15,8 @@
-export_type([wsOpt/0]). -export_type([wsOpt/0]).
-type wsOpt() :: -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, { -record(req, {
method :: elli:http_method(), method :: elli:http_method(),

+ 5
- 3
src/eWSrv.erl View File

@ -9,16 +9,18 @@
startWSrv(WSrvName, Port, WsOpts) -> startWSrv(WSrvName, Port, WsOpts) ->
ListenName = wsUtil:lsName(WSrvName), 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 case ?wsGLV(sslOpts, WsOpts, false) of
false -> 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, end,
ConSupSpec = #{ ConSupSpec = #{
id => WSrvName, id => WSrvName,
start => {wsConSup, start_link, [ListenName]},
start => {wsConSup, start_link, [WSrvName]},
restart => permanent, restart => permanent,
shutdown => infinity, shutdown => infinity,
type => supervisor, type => supervisor,

Loading…
Cancel
Save