fix client

This commit is contained in:
anlicheng 2025-05-20 15:46:33 +08:00
parent e7d8f3a5eb
commit 6386bc3dbf

View File

@ -210,7 +210,7 @@ handle_cast(_Info, State = #state{}) ->
{noreply, NewState :: #state{}, timeout() | hibernate} |
{stop, Reason :: term(), NewState :: #state{}}).
%%
%% , client主动向efka发送的异步请求的响应
handle_info({tcp, Socket, <<?PACKET_RESPONSE, Packet/binary>>}, State = #state{socket = Socket, inflight = Inflight}) ->
case jiffy:decode(Packet, [return_maps]) of
#{<<"id">> := Id, <<"result">> := Result} ->
@ -254,8 +254,8 @@ handle_info({tcp, Socket, <<?PACKET_PUSH, Packet/binary>>}, State = #state{socke
{push_config_reply, Ref, {error, Reason}} when is_binary(Reason) ->
#{<<"id">> => Id, <<"error">> => #{<<"code">> => -1, <<"message">> => Reason}}
end,
Packet = jiffy:encode(Reply, [force_utf8]),
ok = gen_tcp:send(Socket, Packet),
JsonReply = jiffy:encode(Reply, [force_utf8]),
ok = gen_tcp:send(Socket, <<?PACKET_RESPONSE:8, JsonReply/binary>>),
{noreply, State};
#{<<"id">> := Id, <<"method">> := <<"invoke">>, <<"params">> := #{<<"payload">> := Payload}} ->
@ -268,8 +268,8 @@ handle_info({tcp, Socket, <<?PACKET_PUSH, Packet/binary>>}, State = #state{socke
{invoke_reply, Ref, {error, Reason}} when is_binary(Reason) ->
#{<<"id">> => Id, <<"error">> => #{<<"code">> => -1, <<"message">> => Reason}}
end,
Packet = jiffy:encode(Reply, [force_utf8]),
ok = gen_tcp:send(Socket, Packet),
JsonReply = jiffy:encode(Reply, [force_utf8]),
ok = gen_tcp:send(Socket, <<?PACKET_RESPONSE:8, JsonReply/binary>>),
{noreply, State}
end;