This commit is contained in:
anlicheng 2025-05-08 11:50:58 +08:00
parent 825ce3ed8c
commit 5174eed7c4
5 changed files with 2 additions and 44 deletions

View File

@ -37,7 +37,6 @@
%%
-define(PACKET_EVENT, 15).
-define(PACKET_AI_EVENT, 16).
%% API
-export([start_link/3]).
@ -188,13 +187,6 @@ handle_cast({send_event, EventType, Params}, State = #state{socket = Socket}) ->
{noreply, State};
%% done
handle_cast({send_ai_event, EventType, Params}, State = #state{socket = Socket}) ->
Packet = <<0:32, ?PACKET_AI_EVENT:8, EventType:16, Params/binary>>,
ok = gen_tcp:send(Socket, Packet),
{noreply, State};
handle_cast(_Info, State = #state{}) ->
{noreply, State}.

View File

@ -16,7 +16,7 @@
%% API
-export([start_link/0]).
-export([metric_data/3, event/3, ai_event/3, ping/13, feedback_phase/3]).
-export([metric_data/3, event/3, ping/13, feedback_phase/3]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
@ -59,10 +59,6 @@ feedback_phase(TaskId, Timestamp, Phase) when is_integer(TaskId), is_integer(Tim
event(ServiceId, EventType, Params) when is_binary(ServiceId), is_integer(EventType), is_binary(Params) ->
gen_server:cast(?SERVER, {event, ServiceId, EventType, Params}).
-spec ai_event(ServiceId :: binary(), EventType :: integer(), Params :: binary()) -> no_return().
ai_event(ServiceId, EventType, Params) when is_binary(ServiceId), is_integer(EventType), is_binary(Params) ->
gen_server:cast(?SERVER, {ai_event, ServiceId, EventType, Params}).
%% @doc Spawns the server and registers the local name (unique)
-spec(start_link() ->
{ok, Pid :: pid()} | ignore | {error, Reason :: term()}).
@ -126,17 +122,6 @@ handle_cast({event, ServiceId, EventType, Params}, State) ->
{noreply, State};
%% AiEvent事件
handle_cast({ai_event, ServiceId, EventType, Params}, State) ->
EventPacket = message_pb:encode_msg(#ai_event{
service_id = ServiceId,
event_type = EventType,
params = Params
}),
safe_send(?METHOD_AI_EVENT, EventPacket, State),
{noreply, State};
handle_cast({feedback_phase, TaskId, Timestamp, Phase}, State) ->
PhasePacket = message_pb:encode_msg(#feedback_phase{
task_id = TaskId,

View File

@ -21,7 +21,7 @@
-export([start_link/2]).
-export([get_name/1, get_pid/1, start_service/1, stop_service/1, attach_channel/2]).
-export([push_config/3, request_config/1]).
-export([metric_data/3, send_event/3, send_ai_event/3]).
-export([metric_data/3, send_event/3]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
@ -79,9 +79,6 @@ metric_data(Pid, DeviceUUID, Data) when is_pid(Pid), is_binary(DeviceUUID), is_b
send_event(Pid, EventType, Params) when is_pid(Pid), is_integer(EventType), is_binary(Params) ->
gen_server:cast(Pid, {send_event, EventType, Params}).
send_ai_event(Pid, EventType, Params) when is_pid(Pid), is_integer(EventType), is_binary(Params) ->
gen_server:cast(Pid, {send_ai_event, EventType, Params}).
-spec attach_channel(pid(), pid()) -> ok | {error, Reason :: binary()}.
attach_channel(Pid, ChannelPid) when is_pid(Pid), is_pid(ChannelPid) ->
gen_server:call(Pid, {attach_channel, ChannelPid}).
@ -216,10 +213,6 @@ handle_cast({send_event, EventType, Params}, State = #state{service_id = Service
efka_agent:event(ServiceId, EventType, Params),
{noreply, State};
handle_cast({send_ai_event, EventType, Params}, State = #state{service_id = ServiceId}) ->
efka_agent:ai_event(ServiceId, EventType, Params),
{noreply, State};
%%
handle_cast({push_config, Ref, ReceiverPid, ConfigJson}, State = #state{running_status = ?STATUS_RUNNING, channel_pid = ChannelPid, inflight = Inflight}) ->
case is_pid(ChannelPid) andalso is_process_alive(ChannelPid) of

View File

@ -37,7 +37,6 @@
%%
-define(PACKET_EVENT, 15).
-define(PACKET_AI_EVENT, 16).
-record(state, {
packet_id = 1,
@ -143,11 +142,6 @@ handle_info({tcp, Socket, <<0:32, ?PACKET_EVENT:8, EventType:16, Params/binary>>
efka_service:send_event(ServicePid, EventType, Params),
{noreply, State};
%% AIEvent事件
handle_info({tcp, Socket, <<0:32, ?PACKET_AI_EVENT:8, EventType:16, Params/binary>>}, State = #state{socket = Socket, service_pid = ServicePid, is_registered = true}) ->
efka_service:send_ai_event(ServicePid, EventType, Params),
{noreply, State};
%%
handle_info({tcp, Socket, <<PacketId:32, ?PACKET_RESPONSE:8, Response/binary>>}, State = #state{socket = Socket, inflight = Inflight}) ->
case maps:take(PacketId, Inflight) of

View File

@ -107,9 +107,3 @@ message Event {
uint32 event_type = 2;
string params = 3;
}
message AIEvent {
string service_id = 1;
uint32 event_type = 2;
string params = 3;
}