|
|
@ -5,8 +5,10 @@ |
|
|
|
-export([ |
|
|
|
start/0 |
|
|
|
, stop/0 |
|
|
|
, startWSrv/3 |
|
|
|
, stopWSrv/1 |
|
|
|
, openSrv/2 |
|
|
|
, openSrv/3 |
|
|
|
, closeSrv/1 |
|
|
|
, wSrvName/1 |
|
|
|
]). |
|
|
|
|
|
|
|
start() -> |
|
|
@ -15,7 +17,27 @@ start() -> |
|
|
|
stop() -> |
|
|
|
application:stop(eWSrv). |
|
|
|
|
|
|
|
startWSrv(WSrvName, Port, WsOpts) -> |
|
|
|
wSrvName(Port) -> |
|
|
|
binary_to_atom(<<"$WSrv", (integer_to_binary(Port))/bianry>>). |
|
|
|
|
|
|
|
openSrv(Port, WsOpts) -> |
|
|
|
T1WsOpts = lists:keystore(conMod, 1, WsOpts, {conMod, wsHttp}), |
|
|
|
WsMod = ?wsGLV(wsMod, WsOpts, wsEgHer), |
|
|
|
T2WsOpts = lists:keystore(conArgs, 1, T1WsOpts, {conArgs, WsMod}), |
|
|
|
TcpOpts = ?wsGLV(tcpOpts, T2WsOpts, []), |
|
|
|
NewTcpOpts = wsUtil:mergeOpts(?DefWsOpts, TcpOpts), |
|
|
|
LWsOpts = lists:keystore(tcpOpts, 1, T2WsOpts, {tcpOpts, NewTcpOpts}), |
|
|
|
|
|
|
|
WSrvName = wSvNrame(Port), |
|
|
|
|
|
|
|
case ?wsGLV(sslOpts, WsOpts, false) of |
|
|
|
false -> |
|
|
|
{ok, _} = eNet:openTcp(WSrvName, Port, LWsOpts); |
|
|
|
_ -> |
|
|
|
{ok, _} = eNet:openSsl(WSrvName, Port, LWsOpts) |
|
|
|
end. |
|
|
|
|
|
|
|
openSrv(WSrvName, Port, WsOpts) -> |
|
|
|
T1WsOpts = lists:keystore(conMod, 1, WsOpts, {conMod, wsHttp}), |
|
|
|
WsMod = ?wsGLV(wsMod, WsOpts, wsEgHer), |
|
|
|
T2WsOpts = lists:keystore(conArgs, 1, T1WsOpts, {conArgs, WsMod}), |
|
|
@ -30,8 +52,13 @@ startWSrv(WSrvName, Port, WsOpts) -> |
|
|
|
{ok, _} = eNet:openSsl(WSrvName, Port, LWsOpts) |
|
|
|
end. |
|
|
|
|
|
|
|
stopWSrv(WSrvName) -> |
|
|
|
ListenName = wsUtil:lsName(WSrvName), |
|
|
|
eNet:close(ListenName), |
|
|
|
closeSrv(WSrvNameOrPort) -> |
|
|
|
WSrvName = |
|
|
|
case is_integer(WSrvNameOrPort) of |
|
|
|
true -> |
|
|
|
wSvNrame(WSrvNameOrPort); |
|
|
|
_ -> |
|
|
|
WSrvNameOrPort |
|
|
|
end, |
|
|
|
supervisor:terminate_child(eWSrv_sup, WSrvName), |
|
|
|
supervisor:delete_child(eWSrv_sup, WSrvName). |