fix client
This commit is contained in:
parent
e7d8f3a5eb
commit
6386bc3dbf
@ -210,7 +210,7 @@ handle_cast(_Info, State = #state{}) ->
|
|||||||
{noreply, NewState :: #state{}, timeout() | hibernate} |
|
{noreply, NewState :: #state{}, timeout() | hibernate} |
|
||||||
{stop, Reason :: term(), NewState :: #state{}}).
|
{stop, Reason :: term(), NewState :: #state{}}).
|
||||||
|
|
||||||
%% 收到请求的响应
|
%% 收到请求的响应, client主动向efka发送的异步请求的响应
|
||||||
handle_info({tcp, Socket, <<?PACKET_RESPONSE, Packet/binary>>}, State = #state{socket = Socket, inflight = Inflight}) ->
|
handle_info({tcp, Socket, <<?PACKET_RESPONSE, Packet/binary>>}, State = #state{socket = Socket, inflight = Inflight}) ->
|
||||||
case jiffy:decode(Packet, [return_maps]) of
|
case jiffy:decode(Packet, [return_maps]) of
|
||||||
#{<<"id">> := Id, <<"result">> := Result} ->
|
#{<<"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) ->
|
{push_config_reply, Ref, {error, Reason}} when is_binary(Reason) ->
|
||||||
#{<<"id">> => Id, <<"error">> => #{<<"code">> => -1, <<"message">> => Reason}}
|
#{<<"id">> => Id, <<"error">> => #{<<"code">> => -1, <<"message">> => Reason}}
|
||||||
end,
|
end,
|
||||||
Packet = jiffy:encode(Reply, [force_utf8]),
|
JsonReply = jiffy:encode(Reply, [force_utf8]),
|
||||||
ok = gen_tcp:send(Socket, Packet),
|
ok = gen_tcp:send(Socket, <<?PACKET_RESPONSE:8, JsonReply/binary>>),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|
||||||
#{<<"id">> := Id, <<"method">> := <<"invoke">>, <<"params">> := #{<<"payload">> := Payload}} ->
|
#{<<"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) ->
|
{invoke_reply, Ref, {error, Reason}} when is_binary(Reason) ->
|
||||||
#{<<"id">> => Id, <<"error">> => #{<<"code">> => -1, <<"message">> => Reason}}
|
#{<<"id">> => Id, <<"error">> => #{<<"code">> => -1, <<"message">> => Reason}}
|
||||||
end,
|
end,
|
||||||
Packet = jiffy:encode(Reply, [force_utf8]),
|
JsonReply = jiffy:encode(Reply, [force_utf8]),
|
||||||
ok = gen_tcp:send(Socket, Packet),
|
ok = gen_tcp:send(Socket, <<?PACKET_RESPONSE:8, JsonReply/binary>>),
|
||||||
{noreply, State}
|
{noreply, State}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user