feat(quic): adapt to quicer 0.0.8

This commit is contained in:
William Yang 2021-08-25 09:27:19 +02:00
parent abd58bb235
commit 2ef2acc850
2 changed files with 21 additions and 6 deletions

View File

@ -34,10 +34,16 @@ init(ConnOpts) when is_map(ConnOpts) ->
-spec new_conn(quicer:connection_handler(), cb_state()) -> {ok, cb_state()} | {error, any()}. -spec new_conn(quicer:connection_handler(), cb_state()) -> {ok, cb_state()} | {error, any()}.
new_conn(Conn, S) -> new_conn(Conn, S) ->
case emqx_connection:start_link(emqx_quic_stream, Conn, S) of process_flag(trap_exit, true),
{ok, _Pid} -> case emqx_connection:start_link(emqx_quic_stream, {self(), Conn}, S) of
{ok, Pid} ->
receive
{Pid, stream_acceptor_ready} ->
ok = quicer:async_handshake(Conn), ok = quicer:async_handshake(Conn),
{ok, S}; {ok, S};
{'EXIT', Pid, _Reason} ->
{error, stream_accept_error}
end;
Other -> Other ->
{error, Other} {error, Other}
end. end.

View File

@ -31,8 +31,16 @@
, peercert/1 , peercert/1
]). ]).
wait(Conn) -> wait({ConnOwner, Conn}) ->
quicer:accept_stream(Conn, []). {ok, Conn} = quicer:async_accept_stream(Conn, []),
ConnOwner ! {self(), stream_acceptor_ready},
receive
%% from msquic
{quic, new_stream, Stream} ->
{ok, Stream};
{'EXIT', ConnOwner, _Reason} ->
{error, enotconn}
end.
type(_) -> type(_) ->
quic. quic.
@ -44,6 +52,7 @@ sockname(S) ->
quicer:sockname(S). quicer:sockname(S).
peercert(_S) -> peercert(_S) ->
%% @todo but unsupported by msquic
nossl. nossl.
getstat(Socket, Stats) -> getstat(Socket, Stats) ->