sdlan/src/quic/sdlan_quic_channel.erl
2026-05-25 22:35:49 +08:00

49 lines
2.0 KiB
Erlang

%%%-------------------------------------------------------------------
%%% @author anlicheng
%%% @copyright (C) 2026, <COMPANY>
%%% @doc
%%% Compatibility facade for the QUIC channel API.
%%% @end
%%%-------------------------------------------------------------------
-module(sdlan_quic_channel).
-author("anlicheng").
%% API
-export([start_link/2]).
-export([accept_stream/1, send_event/2, command/4, stop/2, debug_info/1]).
-export([test_rules/2]).
%%%===================================================================
%%% API
%%%===================================================================
%% 测试规则函数
-spec test_rules(SrcIdentityId :: integer(), DstIdentityId :: integer()) -> binary().
test_rules(SrcIdentityId, DstIdentityId) when is_integer(SrcIdentityId), is_integer(DstIdentityId) ->
sdlan_session:test_rules(SrcIdentityId, DstIdentityId).
-spec send_event(Pid :: pid(), Event :: binary()) -> ok.
send_event(Pid, ProtobufEvent) when is_pid(Pid), is_binary(ProtobufEvent) ->
sdlan_quic_transport:send_event(Pid, ProtobufEvent).
-spec command(Pid :: pid(), Ref :: reference(), ReceiverPid :: pid(), {Tag :: atom(), SubCommand :: any()}) -> ok.
command(Pid, Ref, ReceiverPid, SubCommand) when is_pid(Pid), is_pid(ReceiverPid) ->
sdlan_quic_transport:command(Pid, Ref, ReceiverPid, SubCommand).
-spec accept_stream(Pid :: pid()) -> ok.
accept_stream(Pid) when is_pid(Pid) ->
sdlan_quic_transport:accept_stream(Pid).
-spec stop(Pid :: pid(), Reason :: term()) -> ok.
stop(Pid, Reason) when is_pid(Pid) ->
sdlan_quic_transport:stop(Pid, Reason).
-spec debug_info(Pid :: pid()) -> map().
debug_info(Pid) when is_pid(Pid) ->
sdlan_quic_transport:debug_info(Pid).
%% @doc Creates a transport process. Kept for existing supervisor specs.
-spec start_link(Conn :: quicer:connection_handle(), Limits :: proplists:proplist()) -> gen_statem:start_ret().
start_link(Conn, Limits) when is_list(Limits) ->
sdlan_quic_transport:start_link(Conn, Limits).