add sdlan_transport
This commit is contained in:
parent
94f0476dee
commit
bed29d89da
@ -11,6 +11,7 @@
|
||||
-include("sdlan_pb.hrl").
|
||||
|
||||
-behaviour(gen_statem).
|
||||
-behaviour(sdlan_transport).
|
||||
|
||||
%% 心跳包监测机制
|
||||
-define(STREAM_ACTIVE_N, 100).
|
||||
|
||||
@ -118,7 +118,7 @@ command(Pid, ReceiverPid, ClientId, SubCommand) when is_pid(Pid), is_pid(Receive
|
||||
-spec wait_command_ack(Ref :: reference(), Timeout :: integer()) -> {error, timeout} | {ok, CommandAck :: #'SDLCommandAck'{}}.
|
||||
wait_command_ack(Ref, Timeout) when is_reference(Ref), is_integer(Timeout) ->
|
||||
receive
|
||||
{quic_command_ack, Ref, CommandAck} ->
|
||||
{command_ack, Ref, CommandAck} ->
|
||||
{ok, CommandAck}
|
||||
after Timeout ->
|
||||
{error, timeout}
|
||||
|
||||
@ -287,7 +287,7 @@ handle_frame(<<?PACKET_COMMAND_ACK, Body/binary>>, Session = #session{status = r
|
||||
{{Ref, ReceiverPid}, RestPendingCommands} ?= maps:take(PktId, PendingCommands),
|
||||
case is_process_alive(ReceiverPid) of
|
||||
true ->
|
||||
ReceiverPid ! {quic_command_ack, Ref, CommandAck};
|
||||
ReceiverPid ! {command_ack, Ref, CommandAck};
|
||||
false ->
|
||||
ok
|
||||
end,
|
||||
|
||||
10
src/sdlan_transport.erl
Normal file
10
src/sdlan_transport.erl
Normal file
@ -0,0 +1,10 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @doc Behaviour for client transport modules.
|
||||
%%% @end
|
||||
%%%-------------------------------------------------------------------
|
||||
-module(sdlan_transport).
|
||||
|
||||
-callback send_event(Pid :: pid(), Event :: binary()) -> ok.
|
||||
-callback command(Pid :: pid(), Ref :: reference(), ReceiverPid :: pid(), SubCommand :: {Tag :: atom(), SubCommand :: any()}) -> ok.
|
||||
-callback stop(Pid :: pid(), Reason :: term()) -> ok.
|
||||
-callback debug_info(Pid :: pid()) -> map().
|
||||
@ -12,6 +12,7 @@
|
||||
|
||||
-behaviour(gen_statem).
|
||||
-behaviour(ranch_protocol).
|
||||
-behaviour(sdlan_transport).
|
||||
|
||||
%% Ranch protocol callback
|
||||
-export([start_link/4]).
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user