fix
This commit is contained in:
parent
3b4da2e10b
commit
71babf4f46
@ -34,8 +34,8 @@
|
|||||||
-define(PACKET_COMMAND, 16#04).
|
-define(PACKET_COMMAND, 16#04).
|
||||||
|
|
||||||
%% 服务器端推送消息
|
%% 服务器端推送消息
|
||||||
-define(PACKET_PUSH, 16#05).
|
-define(PACKET_ASYNC_CALL, 16#05).
|
||||||
-define(PACKET_PUSH_REPLY, 16#06).
|
-define(PACKET_ASYNC_CALL_REPLY, 16#06).
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
%%%% 二级分类定义
|
%%%% 二级分类定义
|
||||||
|
|||||||
@ -35,9 +35,9 @@
|
|||||||
}).
|
}).
|
||||||
-endif.
|
-endif.
|
||||||
|
|
||||||
-ifndef('PUSH_REPLY_PB_H').
|
-ifndef('ASYNC_CALL_REPLY_PB_H').
|
||||||
-define('PUSH_REPLY_PB_H', true).
|
-define('ASYNC_CALL_REPLY_PB_H', true).
|
||||||
-record(push_reply,
|
-record(async_call_reply,
|
||||||
{code = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
|
{code = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
|
||||||
result = <<>> :: unicode:chardata() | undefined, % = 2, optional
|
result = <<>> :: unicode:chardata() | undefined, % = 2, optional
|
||||||
message = <<>> :: unicode:chardata() | undefined % = 3, optional
|
message = <<>> :: unicode:chardata() | undefined % = 3, optional
|
||||||
|
|||||||
@ -24,7 +24,8 @@
|
|||||||
-export([start_link/2, get_name/1, get_alias_name/1, get_pid/1, handle/2, activate/2]).
|
-export([start_link/2, get_name/1, get_alias_name/1, get_pid/1, handle/2, activate/2]).
|
||||||
-export([get_metric/1, get_status/1]).
|
-export([get_metric/1, get_status/1]).
|
||||||
%% 通讯相关
|
%% 通讯相关
|
||||||
-export([pub/3, async_request/3, attach_channel/2, command/3, push_config/2]).
|
-export([pub/3, attach_channel/2, command/3]).
|
||||||
|
-export([async_deploy/4, async_invoke/4, async_service_config/2, async_task_log/2]).
|
||||||
%% 设备管理
|
%% 设备管理
|
||||||
-export([reload_device/2, delete_device/2, activate_device/3]).
|
-export([reload_device/2, delete_device/2, activate_device/3]).
|
||||||
-export([heartbeat/1]).
|
-export([heartbeat/1]).
|
||||||
@ -88,14 +89,24 @@ get_metric(Pid) when is_pid(Pid) ->
|
|||||||
attach_channel(Pid, ChannelPid) when is_pid(Pid), is_pid(ChannelPid) ->
|
attach_channel(Pid, ChannelPid) when is_pid(Pid), is_pid(ChannelPid) ->
|
||||||
gen_statem:call(Pid, {attach_channel, ChannelPid}).
|
gen_statem:call(Pid, {attach_channel, ChannelPid}).
|
||||||
|
|
||||||
-spec push_config(Pid :: pid(), ConfigJson :: binary()) -> {ok, Ref :: reference()} | {error, Reason :: any()}.
|
-spec async_service_config(Pid :: pid(), ConfigJson :: binary()) -> {ok, Ref :: reference()} | {error, Reason :: any()}.
|
||||||
push_config(Pid, ConfigJson) when is_pid(Pid), is_binary(ConfigJson) ->
|
async_service_config(Pid, ConfigJson) when is_pid(Pid), is_binary(ConfigJson) ->
|
||||||
async_request(Pid, <<"$sys:push_config">>, ConfigJson).
|
gen_statem:call(Pid, {async_call, self(), ?PUSH_SERVICE_CONFIG, ConfigJson}).
|
||||||
|
|
||||||
%% 响应的消息格式为: {async_response, Ref, #async_response{}}
|
-spec async_deploy(Pid :: pid(), TaskId :: integer(), ServiceId :: binary(), TarUrl :: binary()) -> {ok, Ref :: reference()} | {error, Reason :: any()}.
|
||||||
-spec async_request(Pid :: pid(), Method :: binary(), Params :: binary()) -> {ok, Ref :: reference()} | {error, Reason :: any()}.
|
async_deploy(Pid, TaskId, ServiceId, TarUrl) when is_pid(Pid), is_integer(TaskId), is_binary(ServiceId), is_binary(TarUrl) ->
|
||||||
async_request(Pid, Method, Params) when is_pid(Pid), is_binary(Method), is_binary(Params) ->
|
PushBin = message_pb:encode_msg(#deploy{task_id = TaskId, service_id = ServiceId, tar_url = TarUrl}),
|
||||||
gen_statem:call(Pid, {async_request, self(), Method, Params}).
|
gen_statem:call(Pid, {async_call, self(), ?PUSH_DEPLOY, PushBin}).
|
||||||
|
|
||||||
|
-spec async_invoke(Pid :: pid(), ServiceId :: integer(), Payload :: binary(), Timeout :: integer()) -> {ok, Ref :: reference()} | {error, Reason :: any()}.
|
||||||
|
async_invoke(Pid, ServiceId, Payload, Timeout) when is_pid(Pid), is_binary(ServiceId), is_binary(Payload), is_integer(Timeout) ->
|
||||||
|
InvokeBin = message_pb:encode_msg(#invoke{service_id = ServiceId, payload = Payload, timeout = Timeout}),
|
||||||
|
gen_statem:call(Pid, {async_call, self(), ?PUSH_INVOKE, InvokeBin}).
|
||||||
|
|
||||||
|
-spec async_task_log(Pid :: pid(), TaskId :: integer()) -> {ok, Ref :: reference()} | {error, Reason :: any()}.
|
||||||
|
async_task_log(Pid, TaskId) when is_pid(Pid), is_integer(TaskId) ->
|
||||||
|
TaskLogBin = message_pb:encode_msg(#fetch_task_log{task_id = TaskId}),
|
||||||
|
gen_statem:call(Pid, {async_call, self(), ?PUSH_TASK_LOG, TaskLogBin}).
|
||||||
|
|
||||||
-spec pub(Pid :: pid(), Topic :: binary(), Content :: binary()) -> ok | {error, Reason :: any()}.
|
-spec pub(Pid :: pid(), Topic :: binary(), Content :: binary()) -> ok | {error, Reason :: any()}.
|
||||||
pub(Pid, Topic, Content) when is_pid(Pid), is_binary(Topic), is_binary(Content) ->
|
pub(Pid, Topic, Content) when is_pid(Pid), is_binary(Topic), is_binary(Content) ->
|
||||||
@ -196,16 +207,14 @@ handle_event({call, From}, get_status, _, State = #state{channel_pid = ChannelPi
|
|||||||
{keep_state, State, [{reply, From, {ok, Reply}}]};
|
{keep_state, State, [{reply, From, {ok, Reply}}]};
|
||||||
|
|
||||||
%% 只要channel存在,就负责将消息推送到边缘端主机
|
%% 只要channel存在,就负责将消息推送到边缘端主机
|
||||||
handle_event({call, From}, {async_request, ReceiverPid, Method, Params}, _, State = #state{uuid = UUID, channel_pid = ChannelPid, has_session = HasSession}) ->
|
handle_event({call, From}, {async_call, ReceiverPid, PushType, PushBin}, _, State = #state{uuid = UUID, channel_pid = ChannelPid, has_session = HasSession}) ->
|
||||||
case HasSession andalso is_pid(ChannelPid) of
|
case HasSession andalso is_pid(ChannelPid) of
|
||||||
true ->
|
true ->
|
||||||
%% 通过websocket发送请求
|
%% 通过websocket发送请求
|
||||||
lager:debug("[iot_host] host: ~p, will async_request method: ~p, params: ~p", [UUID, Method, Params]),
|
Ref = tcp_channel:async_call(ChannelPid, ReceiverPid, PushType, PushBin),
|
||||||
Ref = tcp_channel:push(ChannelPid, ReceiverPid, Method, Params),
|
|
||||||
|
|
||||||
{keep_state, State, [{reply, From, {ok, Ref}}]};
|
{keep_state, State, [{reply, From, {ok, Ref}}]};
|
||||||
false ->
|
false ->
|
||||||
lager:debug("[iot_host] uuid: ~p, publish_message invalid state: ~p", [UUID, state_map(State)]),
|
lager:debug("[iot_host] uuid: ~p, publish_type: ~p, invalid state: ~p", [UUID, PushType, state_map(State)]),
|
||||||
{keep_state, State, [{reply, From, {error, <<"主机离线,发送请求失败"/utf8>>}}]}
|
{keep_state, State, [{reply, From, {error, <<"主机离线,发送请求失败"/utf8>>}}]}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@ -61,7 +61,7 @@
|
|||||||
|
|
||||||
-type pub() :: #pub{}.
|
-type pub() :: #pub{}.
|
||||||
|
|
||||||
-type push_reply() :: #push_reply{}.
|
-type async_call_reply() :: #async_call_reply{}.
|
||||||
|
|
||||||
-type deploy() :: #deploy{}.
|
-type deploy() :: #deploy{}.
|
||||||
|
|
||||||
@ -79,9 +79,9 @@
|
|||||||
|
|
||||||
-type event() :: #event{}.
|
-type event() :: #event{}.
|
||||||
|
|
||||||
-export_type(['auth_request'/0, 'auth_reply'/0, 'pub'/0, 'push_reply'/0, 'deploy'/0, 'fetch_task_log'/0, 'invoke'/0, 'service_config'/0, 'data'/0, 'ping'/0, 'service_inform'/0, 'event'/0]).
|
-export_type(['auth_request'/0, 'auth_reply'/0, 'pub'/0, 'async_call_reply'/0, 'deploy'/0, 'fetch_task_log'/0, 'invoke'/0, 'service_config'/0, 'data'/0, 'ping'/0, 'service_inform'/0, 'event'/0]).
|
||||||
-type '$msg_name'() :: auth_request | auth_reply | pub | push_reply | deploy | fetch_task_log | invoke | service_config | data | ping | service_inform | event.
|
-type '$msg_name'() :: auth_request | auth_reply | pub | async_call_reply | deploy | fetch_task_log | invoke | service_config | data | ping | service_inform | event.
|
||||||
-type '$msg'() :: auth_request() | auth_reply() | pub() | push_reply() | deploy() | fetch_task_log() | invoke() | service_config() | data() | ping() | service_inform() | event().
|
-type '$msg'() :: auth_request() | auth_reply() | pub() | async_call_reply() | deploy() | fetch_task_log() | invoke() | service_config() | data() | ping() | service_inform() | event().
|
||||||
-export_type(['$msg_name'/0, '$msg'/0]).
|
-export_type(['$msg_name'/0, '$msg'/0]).
|
||||||
|
|
||||||
-if(?OTP_RELEASE >= 24).
|
-if(?OTP_RELEASE >= 24).
|
||||||
@ -111,7 +111,7 @@ encode_msg(Msg, MsgName, Opts) ->
|
|||||||
auth_request -> encode_msg_auth_request(id(Msg, TrUserData), TrUserData);
|
auth_request -> encode_msg_auth_request(id(Msg, TrUserData), TrUserData);
|
||||||
auth_reply -> encode_msg_auth_reply(id(Msg, TrUserData), TrUserData);
|
auth_reply -> encode_msg_auth_reply(id(Msg, TrUserData), TrUserData);
|
||||||
pub -> encode_msg_pub(id(Msg, TrUserData), TrUserData);
|
pub -> encode_msg_pub(id(Msg, TrUserData), TrUserData);
|
||||||
push_reply -> encode_msg_push_reply(id(Msg, TrUserData), TrUserData);
|
async_call_reply -> encode_msg_async_call_reply(id(Msg, TrUserData), TrUserData);
|
||||||
deploy -> encode_msg_deploy(id(Msg, TrUserData), TrUserData);
|
deploy -> encode_msg_deploy(id(Msg, TrUserData), TrUserData);
|
||||||
fetch_task_log -> encode_msg_fetch_task_log(id(Msg, TrUserData), TrUserData);
|
fetch_task_log -> encode_msg_fetch_task_log(id(Msg, TrUserData), TrUserData);
|
||||||
invoke -> encode_msg_invoke(id(Msg, TrUserData), TrUserData);
|
invoke -> encode_msg_invoke(id(Msg, TrUserData), TrUserData);
|
||||||
@ -226,10 +226,10 @@ encode_msg_pub(#pub{topic = F1, content = F2}, Bin, TrUserData) ->
|
|||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
encode_msg_push_reply(Msg, TrUserData) -> encode_msg_push_reply(Msg, <<>>, TrUserData).
|
encode_msg_async_call_reply(Msg, TrUserData) -> encode_msg_async_call_reply(Msg, <<>>, TrUserData).
|
||||||
|
|
||||||
|
|
||||||
encode_msg_push_reply(#push_reply{code = F1, result = F2, message = F3}, Bin, TrUserData) ->
|
encode_msg_async_call_reply(#async_call_reply{code = F1, result = F2, message = F3}, Bin, TrUserData) ->
|
||||||
B1 = if F1 == undefined -> Bin;
|
B1 = if F1 == undefined -> Bin;
|
||||||
true ->
|
true ->
|
||||||
begin
|
begin
|
||||||
@ -778,7 +778,7 @@ decode_msg_1_catch(Bin, MsgName, TrUserData) ->
|
|||||||
decode_msg_2_doit(auth_request, Bin, TrUserData) -> id(decode_msg_auth_request(Bin, TrUserData), TrUserData);
|
decode_msg_2_doit(auth_request, Bin, TrUserData) -> id(decode_msg_auth_request(Bin, TrUserData), TrUserData);
|
||||||
decode_msg_2_doit(auth_reply, Bin, TrUserData) -> id(decode_msg_auth_reply(Bin, TrUserData), TrUserData);
|
decode_msg_2_doit(auth_reply, Bin, TrUserData) -> id(decode_msg_auth_reply(Bin, TrUserData), TrUserData);
|
||||||
decode_msg_2_doit(pub, Bin, TrUserData) -> id(decode_msg_pub(Bin, TrUserData), TrUserData);
|
decode_msg_2_doit(pub, Bin, TrUserData) -> id(decode_msg_pub(Bin, TrUserData), TrUserData);
|
||||||
decode_msg_2_doit(push_reply, Bin, TrUserData) -> id(decode_msg_push_reply(Bin, TrUserData), TrUserData);
|
decode_msg_2_doit(async_call_reply, Bin, TrUserData) -> id(decode_msg_async_call_reply(Bin, TrUserData), TrUserData);
|
||||||
decode_msg_2_doit(deploy, Bin, TrUserData) -> id(decode_msg_deploy(Bin, TrUserData), TrUserData);
|
decode_msg_2_doit(deploy, Bin, TrUserData) -> id(decode_msg_deploy(Bin, TrUserData), TrUserData);
|
||||||
decode_msg_2_doit(fetch_task_log, Bin, TrUserData) -> id(decode_msg_fetch_task_log(Bin, TrUserData), TrUserData);
|
decode_msg_2_doit(fetch_task_log, Bin, TrUserData) -> id(decode_msg_fetch_task_log(Bin, TrUserData), TrUserData);
|
||||||
decode_msg_2_doit(invoke, Bin, TrUserData) -> id(decode_msg_invoke(Bin, TrUserData), TrUserData);
|
decode_msg_2_doit(invoke, Bin, TrUserData) -> id(decode_msg_invoke(Bin, TrUserData), TrUserData);
|
||||||
@ -964,63 +964,63 @@ skip_32_pub(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_rea
|
|||||||
|
|
||||||
skip_64_pub(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_pub(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData).
|
skip_64_pub(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_pub(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData).
|
||||||
|
|
||||||
decode_msg_push_reply(Bin, TrUserData) -> dfp_read_field_def_push_reply(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData).
|
decode_msg_async_call_reply(Bin, TrUserData) -> dfp_read_field_def_async_call_reply(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData).
|
||||||
|
|
||||||
dfp_read_field_def_push_reply(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_push_reply_code(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
|
dfp_read_field_def_async_call_reply(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_async_call_reply_code(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
|
||||||
dfp_read_field_def_push_reply(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_push_reply_result(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
|
dfp_read_field_def_async_call_reply(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_async_call_reply_result(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
|
||||||
dfp_read_field_def_push_reply(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_push_reply_message(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
|
dfp_read_field_def_async_call_reply(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_async_call_reply_message(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
|
||||||
dfp_read_field_def_push_reply(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #push_reply{code = F@_1, result = F@_2, message = F@_3};
|
dfp_read_field_def_async_call_reply(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #async_call_reply{code = F@_1, result = F@_2, message = F@_3};
|
||||||
dfp_read_field_def_push_reply(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_push_reply(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
|
dfp_read_field_def_async_call_reply(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_async_call_reply(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
|
||||||
|
|
||||||
dg_read_field_def_push_reply(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_push_reply(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
dg_read_field_def_async_call_reply(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_async_call_reply(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
||||||
dg_read_field_def_push_reply(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) ->
|
dg_read_field_def_async_call_reply(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) ->
|
||||||
Key = X bsl N + Acc,
|
Key = X bsl N + Acc,
|
||||||
case Key of
|
case Key of
|
||||||
8 -> d_field_push_reply_code(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
|
8 -> d_field_async_call_reply_code(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
|
||||||
18 -> d_field_push_reply_result(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
|
18 -> d_field_async_call_reply_result(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
|
||||||
26 -> d_field_push_reply_message(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
|
26 -> d_field_async_call_reply_message(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
|
||||||
_ ->
|
_ ->
|
||||||
case Key band 7 of
|
case Key band 7 of
|
||||||
0 -> skip_varint_push_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
|
0 -> skip_varint_async_call_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
|
||||||
1 -> skip_64_push_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
|
1 -> skip_64_async_call_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
|
||||||
2 -> skip_length_delimited_push_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
|
2 -> skip_length_delimited_async_call_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
|
||||||
3 -> skip_group_push_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
|
3 -> skip_group_async_call_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
|
||||||
5 -> skip_32_push_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData)
|
5 -> skip_32_async_call_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
dg_read_field_def_push_reply(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #push_reply{code = F@_1, result = F@_2, message = F@_3}.
|
dg_read_field_def_async_call_reply(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #async_call_reply{code = F@_1, result = F@_2, message = F@_3}.
|
||||||
|
|
||||||
d_field_push_reply_code(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_push_reply_code(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
d_field_async_call_reply_code(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_async_call_reply_code(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
||||||
d_field_push_reply_code(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) ->
|
d_field_async_call_reply_code(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) ->
|
||||||
{NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest},
|
{NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest},
|
||||||
dfp_read_field_def_push_reply(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData).
|
dfp_read_field_def_async_call_reply(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData).
|
||||||
|
|
||||||
d_field_push_reply_result(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_push_reply_result(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
d_field_async_call_reply_result(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_async_call_reply_result(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
||||||
d_field_push_reply_result(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) ->
|
d_field_async_call_reply_result(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) ->
|
||||||
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
||||||
dfp_read_field_def_push_reply(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData).
|
dfp_read_field_def_async_call_reply(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData).
|
||||||
|
|
||||||
d_field_push_reply_message(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_push_reply_message(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
d_field_async_call_reply_message(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_async_call_reply_message(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
||||||
d_field_push_reply_message(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) ->
|
d_field_async_call_reply_message(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) ->
|
||||||
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
|
||||||
dfp_read_field_def_push_reply(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData).
|
dfp_read_field_def_async_call_reply(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData).
|
||||||
|
|
||||||
skip_varint_push_reply(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_push_reply(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
|
skip_varint_async_call_reply(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_async_call_reply(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
|
||||||
skip_varint_push_reply(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_push_reply(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
|
skip_varint_async_call_reply(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_async_call_reply(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
|
||||||
|
|
||||||
skip_length_delimited_push_reply(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_push_reply(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
skip_length_delimited_async_call_reply(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_async_call_reply(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
|
||||||
skip_length_delimited_push_reply(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) ->
|
skip_length_delimited_async_call_reply(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) ->
|
||||||
Length = X bsl N + Acc,
|
Length = X bsl N + Acc,
|
||||||
<<_:Length/binary, Rest2/binary>> = Rest,
|
<<_:Length/binary, Rest2/binary>> = Rest,
|
||||||
dfp_read_field_def_push_reply(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData).
|
dfp_read_field_def_async_call_reply(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData).
|
||||||
|
|
||||||
skip_group_push_reply(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) ->
|
skip_group_async_call_reply(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) ->
|
||||||
{_, Rest} = read_group(Bin, FNum),
|
{_, Rest} = read_group(Bin, FNum),
|
||||||
dfp_read_field_def_push_reply(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData).
|
dfp_read_field_def_async_call_reply(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData).
|
||||||
|
|
||||||
skip_32_push_reply(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_push_reply(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
|
skip_32_async_call_reply(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_async_call_reply(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
|
||||||
|
|
||||||
skip_64_push_reply(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_push_reply(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
|
skip_64_async_call_reply(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_async_call_reply(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
|
||||||
|
|
||||||
decode_msg_deploy(Bin, TrUserData) -> dfp_read_field_def_deploy(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData).
|
decode_msg_deploy(Bin, TrUserData) -> dfp_read_field_def_deploy(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData).
|
||||||
|
|
||||||
@ -1710,7 +1710,7 @@ merge_msgs(Prev, New, MsgName, Opts) ->
|
|||||||
auth_request -> merge_msg_auth_request(Prev, New, TrUserData);
|
auth_request -> merge_msg_auth_request(Prev, New, TrUserData);
|
||||||
auth_reply -> merge_msg_auth_reply(Prev, New, TrUserData);
|
auth_reply -> merge_msg_auth_reply(Prev, New, TrUserData);
|
||||||
pub -> merge_msg_pub(Prev, New, TrUserData);
|
pub -> merge_msg_pub(Prev, New, TrUserData);
|
||||||
push_reply -> merge_msg_push_reply(Prev, New, TrUserData);
|
async_call_reply -> merge_msg_async_call_reply(Prev, New, TrUserData);
|
||||||
deploy -> merge_msg_deploy(Prev, New, TrUserData);
|
deploy -> merge_msg_deploy(Prev, New, TrUserData);
|
||||||
fetch_task_log -> merge_msg_fetch_task_log(Prev, New, TrUserData);
|
fetch_task_log -> merge_msg_fetch_task_log(Prev, New, TrUserData);
|
||||||
invoke -> merge_msg_invoke(Prev, New, TrUserData);
|
invoke -> merge_msg_invoke(Prev, New, TrUserData);
|
||||||
@ -1766,9 +1766,9 @@ merge_msg_pub(#pub{topic = PFtopic, content = PFcontent}, #pub{topic = NFtopic,
|
|||||||
true -> NFcontent
|
true -> NFcontent
|
||||||
end}.
|
end}.
|
||||||
|
|
||||||
-compile({nowarn_unused_function,merge_msg_push_reply/3}).
|
-compile({nowarn_unused_function,merge_msg_async_call_reply/3}).
|
||||||
merge_msg_push_reply(#push_reply{code = PFcode, result = PFresult, message = PFmessage}, #push_reply{code = NFcode, result = NFresult, message = NFmessage}, _) ->
|
merge_msg_async_call_reply(#async_call_reply{code = PFcode, result = PFresult, message = PFmessage}, #async_call_reply{code = NFcode, result = NFresult, message = NFmessage}, _) ->
|
||||||
#push_reply{code =
|
#async_call_reply{code =
|
||||||
if NFcode =:= undefined -> PFcode;
|
if NFcode =:= undefined -> PFcode;
|
||||||
true -> NFcode
|
true -> NFcode
|
||||||
end,
|
end,
|
||||||
@ -1958,7 +1958,7 @@ verify_msg(Msg, MsgName, Opts) ->
|
|||||||
auth_request -> v_msg_auth_request(Msg, [MsgName], TrUserData);
|
auth_request -> v_msg_auth_request(Msg, [MsgName], TrUserData);
|
||||||
auth_reply -> v_msg_auth_reply(Msg, [MsgName], TrUserData);
|
auth_reply -> v_msg_auth_reply(Msg, [MsgName], TrUserData);
|
||||||
pub -> v_msg_pub(Msg, [MsgName], TrUserData);
|
pub -> v_msg_pub(Msg, [MsgName], TrUserData);
|
||||||
push_reply -> v_msg_push_reply(Msg, [MsgName], TrUserData);
|
async_call_reply -> v_msg_async_call_reply(Msg, [MsgName], TrUserData);
|
||||||
deploy -> v_msg_deploy(Msg, [MsgName], TrUserData);
|
deploy -> v_msg_deploy(Msg, [MsgName], TrUserData);
|
||||||
fetch_task_log -> v_msg_fetch_task_log(Msg, [MsgName], TrUserData);
|
fetch_task_log -> v_msg_fetch_task_log(Msg, [MsgName], TrUserData);
|
||||||
invoke -> v_msg_invoke(Msg, [MsgName], TrUserData);
|
invoke -> v_msg_invoke(Msg, [MsgName], TrUserData);
|
||||||
@ -2016,9 +2016,9 @@ v_msg_pub(#pub{topic = F1, content = F2}, Path, TrUserData) ->
|
|||||||
ok;
|
ok;
|
||||||
v_msg_pub(X, Path, _TrUserData) -> mk_type_error({expected_msg, pub}, X, Path).
|
v_msg_pub(X, Path, _TrUserData) -> mk_type_error({expected_msg, pub}, X, Path).
|
||||||
|
|
||||||
-compile({nowarn_unused_function,v_msg_push_reply/3}).
|
-compile({nowarn_unused_function,v_msg_async_call_reply/3}).
|
||||||
-dialyzer({nowarn_function,v_msg_push_reply/3}).
|
-dialyzer({nowarn_function,v_msg_async_call_reply/3}).
|
||||||
v_msg_push_reply(#push_reply{code = F1, result = F2, message = F3}, Path, TrUserData) ->
|
v_msg_async_call_reply(#async_call_reply{code = F1, result = F2, message = F3}, Path, TrUserData) ->
|
||||||
if F1 == undefined -> ok;
|
if F1 == undefined -> ok;
|
||||||
true -> v_type_uint32(F1, [code | Path], TrUserData)
|
true -> v_type_uint32(F1, [code | Path], TrUserData)
|
||||||
end,
|
end,
|
||||||
@ -2029,7 +2029,7 @@ v_msg_push_reply(#push_reply{code = F1, result = F2, message = F3}, Path, TrUser
|
|||||||
true -> v_type_string(F3, [message | Path], TrUserData)
|
true -> v_type_string(F3, [message | Path], TrUserData)
|
||||||
end,
|
end,
|
||||||
ok;
|
ok;
|
||||||
v_msg_push_reply(X, Path, _TrUserData) -> mk_type_error({expected_msg, push_reply}, X, Path).
|
v_msg_async_call_reply(X, Path, _TrUserData) -> mk_type_error({expected_msg, async_call_reply}, X, Path).
|
||||||
|
|
||||||
-compile({nowarn_unused_function,v_msg_deploy/3}).
|
-compile({nowarn_unused_function,v_msg_deploy/3}).
|
||||||
-dialyzer({nowarn_function,v_msg_deploy/3}).
|
-dialyzer({nowarn_function,v_msg_deploy/3}).
|
||||||
@ -2262,7 +2262,7 @@ get_msg_defs() ->
|
|||||||
#field{name = timestamp, fnum = 6, rnum = 6, type = uint32, occurrence = optional, opts = []}]},
|
#field{name = timestamp, fnum = 6, rnum = 6, type = uint32, occurrence = optional, opts = []}]},
|
||||||
{{msg, auth_reply}, [#field{name = code, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []}, #field{name = message, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}]},
|
{{msg, auth_reply}, [#field{name = code, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []}, #field{name = message, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}]},
|
||||||
{{msg, pub}, [#field{name = topic, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, #field{name = content, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}]},
|
{{msg, pub}, [#field{name = topic, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, #field{name = content, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}]},
|
||||||
{{msg, push_reply},
|
{{msg, async_call_reply},
|
||||||
[#field{name = code, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []},
|
[#field{name = code, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []},
|
||||||
#field{name = result, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []},
|
#field{name = result, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []},
|
||||||
#field{name = message, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}]},
|
#field{name = message, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}]},
|
||||||
@ -2308,13 +2308,13 @@ get_msg_defs() ->
|
|||||||
#field{name = params, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}]}].
|
#field{name = params, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}]}].
|
||||||
|
|
||||||
|
|
||||||
get_msg_names() -> [auth_request, auth_reply, pub, push_reply, deploy, fetch_task_log, invoke, service_config, data, ping, service_inform, event].
|
get_msg_names() -> [auth_request, auth_reply, pub, async_call_reply, deploy, fetch_task_log, invoke, service_config, data, ping, service_inform, event].
|
||||||
|
|
||||||
|
|
||||||
get_group_names() -> [].
|
get_group_names() -> [].
|
||||||
|
|
||||||
|
|
||||||
get_msg_or_group_names() -> [auth_request, auth_reply, pub, push_reply, deploy, fetch_task_log, invoke, service_config, data, ping, service_inform, event].
|
get_msg_or_group_names() -> [auth_request, auth_reply, pub, async_call_reply, deploy, fetch_task_log, invoke, service_config, data, ping, service_inform, event].
|
||||||
|
|
||||||
|
|
||||||
get_enum_names() -> [].
|
get_enum_names() -> [].
|
||||||
@ -2339,7 +2339,7 @@ find_msg_def(auth_request) ->
|
|||||||
#field{name = timestamp, fnum = 6, rnum = 6, type = uint32, occurrence = optional, opts = []}];
|
#field{name = timestamp, fnum = 6, rnum = 6, type = uint32, occurrence = optional, opts = []}];
|
||||||
find_msg_def(auth_reply) -> [#field{name = code, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []}, #field{name = message, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}];
|
find_msg_def(auth_reply) -> [#field{name = code, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []}, #field{name = message, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}];
|
||||||
find_msg_def(pub) -> [#field{name = topic, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, #field{name = content, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}];
|
find_msg_def(pub) -> [#field{name = topic, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, #field{name = content, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}];
|
||||||
find_msg_def(push_reply) ->
|
find_msg_def(async_call_reply) ->
|
||||||
[#field{name = code, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []},
|
[#field{name = code, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []},
|
||||||
#field{name = result, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []},
|
#field{name = result, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []},
|
||||||
#field{name = message, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}];
|
#field{name = message, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}];
|
||||||
@ -2444,7 +2444,7 @@ service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S
|
|||||||
fqbin_to_msg_name(<<"AuthRequest">>) -> auth_request;
|
fqbin_to_msg_name(<<"AuthRequest">>) -> auth_request;
|
||||||
fqbin_to_msg_name(<<"AuthReply">>) -> auth_reply;
|
fqbin_to_msg_name(<<"AuthReply">>) -> auth_reply;
|
||||||
fqbin_to_msg_name(<<"Pub">>) -> pub;
|
fqbin_to_msg_name(<<"Pub">>) -> pub;
|
||||||
fqbin_to_msg_name(<<"PushReply">>) -> push_reply;
|
fqbin_to_msg_name(<<"AsyncCallReply">>) -> async_call_reply;
|
||||||
fqbin_to_msg_name(<<"Deploy">>) -> deploy;
|
fqbin_to_msg_name(<<"Deploy">>) -> deploy;
|
||||||
fqbin_to_msg_name(<<"FetchTaskLog">>) -> fetch_task_log;
|
fqbin_to_msg_name(<<"FetchTaskLog">>) -> fetch_task_log;
|
||||||
fqbin_to_msg_name(<<"Invoke">>) -> invoke;
|
fqbin_to_msg_name(<<"Invoke">>) -> invoke;
|
||||||
@ -2459,7 +2459,7 @@ fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}).
|
|||||||
msg_name_to_fqbin(auth_request) -> <<"AuthRequest">>;
|
msg_name_to_fqbin(auth_request) -> <<"AuthRequest">>;
|
||||||
msg_name_to_fqbin(auth_reply) -> <<"AuthReply">>;
|
msg_name_to_fqbin(auth_reply) -> <<"AuthReply">>;
|
||||||
msg_name_to_fqbin(pub) -> <<"Pub">>;
|
msg_name_to_fqbin(pub) -> <<"Pub">>;
|
||||||
msg_name_to_fqbin(push_reply) -> <<"PushReply">>;
|
msg_name_to_fqbin(async_call_reply) -> <<"AsyncCallReply">>;
|
||||||
msg_name_to_fqbin(deploy) -> <<"Deploy">>;
|
msg_name_to_fqbin(deploy) -> <<"Deploy">>;
|
||||||
msg_name_to_fqbin(fetch_task_log) -> <<"FetchTaskLog">>;
|
msg_name_to_fqbin(fetch_task_log) -> <<"FetchTaskLog">>;
|
||||||
msg_name_to_fqbin(invoke) -> <<"Invoke">>;
|
msg_name_to_fqbin(invoke) -> <<"Invoke">>;
|
||||||
@ -2506,7 +2506,7 @@ get_all_source_basenames() -> ["message_pb.proto"].
|
|||||||
get_all_proto_names() -> ["message_pb"].
|
get_all_proto_names() -> ["message_pb"].
|
||||||
|
|
||||||
|
|
||||||
get_msg_containment("message_pb") -> [auth_reply, auth_request, data, deploy, event, fetch_task_log, invoke, ping, pub, push_reply, service_config, service_inform];
|
get_msg_containment("message_pb") -> [async_call_reply, auth_reply, auth_request, data, deploy, event, fetch_task_log, invoke, ping, pub, service_config, service_inform];
|
||||||
get_msg_containment(P) -> error({gpb_error, {badproto, P}}).
|
get_msg_containment(P) -> error({gpb_error, {badproto, P}}).
|
||||||
|
|
||||||
|
|
||||||
@ -2534,9 +2534,9 @@ get_proto_by_msg_name_as_fqbin(<<"Invoke">>) -> "message_pb";
|
|||||||
get_proto_by_msg_name_as_fqbin(<<"ServiceConfig">>) -> "message_pb";
|
get_proto_by_msg_name_as_fqbin(<<"ServiceConfig">>) -> "message_pb";
|
||||||
get_proto_by_msg_name_as_fqbin(<<"Ping">>) -> "message_pb";
|
get_proto_by_msg_name_as_fqbin(<<"Ping">>) -> "message_pb";
|
||||||
get_proto_by_msg_name_as_fqbin(<<"FetchTaskLog">>) -> "message_pb";
|
get_proto_by_msg_name_as_fqbin(<<"FetchTaskLog">>) -> "message_pb";
|
||||||
get_proto_by_msg_name_as_fqbin(<<"PushReply">>) -> "message_pb";
|
|
||||||
get_proto_by_msg_name_as_fqbin(<<"Deploy">>) -> "message_pb";
|
get_proto_by_msg_name_as_fqbin(<<"Deploy">>) -> "message_pb";
|
||||||
get_proto_by_msg_name_as_fqbin(<<"AuthReply">>) -> "message_pb";
|
get_proto_by_msg_name_as_fqbin(<<"AuthReply">>) -> "message_pb";
|
||||||
|
get_proto_by_msg_name_as_fqbin(<<"AsyncCallReply">>) -> "message_pb";
|
||||||
get_proto_by_msg_name_as_fqbin(<<"ServiceInform">>) -> "message_pb";
|
get_proto_by_msg_name_as_fqbin(<<"ServiceInform">>) -> "message_pb";
|
||||||
get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}).
|
get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}).
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
%% API
|
%% API
|
||||||
-export([stop/2, send/2]).
|
-export([stop/2, send/2]).
|
||||||
-export([pub/3, push/4, command/3]).
|
-export([pub/3, async_call/4, command/3]).
|
||||||
|
|
||||||
-export([start_link/2]).
|
-export([start_link/2]).
|
||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
@ -44,10 +44,10 @@ command(Pid, CommandType, Command) when is_pid(Pid), is_integer(CommandType), is
|
|||||||
gen_server:cast(Pid, {command, CommandType, Command}).
|
gen_server:cast(Pid, {command, CommandType, Command}).
|
||||||
|
|
||||||
%% 向通道中写入消息
|
%% 向通道中写入消息
|
||||||
-spec push(Pid :: pid(), ReceiverPid :: pid(), Method :: binary(), Params :: binary()) -> Ref :: reference().
|
-spec async_call(Pid :: pid(), ReceiverPid :: pid(), CallType :: integer(), CallBin :: binary()) -> Ref :: reference().
|
||||||
push(Pid, ReceiverPid, PushType, PushBin) when is_pid(Pid), is_integer(PushType), is_binary(PushBin) ->
|
async_call(Pid, ReceiverPid, CallType, CallBin) when is_pid(Pid), is_pid(ReceiverPid), is_integer(CallType), is_binary(CallBin) ->
|
||||||
Ref = make_ref(),
|
Ref = make_ref(),
|
||||||
gen_server:cast(Pid, {push, ReceiverPid, Ref, PushType, PushBin}),
|
gen_server:cast(Pid, {async_call, ReceiverPid, Ref, CallType, CallBin}),
|
||||||
Ref.
|
Ref.
|
||||||
|
|
||||||
%% 关闭方法
|
%% 关闭方法
|
||||||
@ -90,8 +90,8 @@ handle_cast({command, CommandType, Command}, State = #state{transport = Transpor
|
|||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|
||||||
%% 推送消息
|
%% 推送消息
|
||||||
handle_cast({push, ReceiverPid, Ref, PushType, PushBin}, State = #state{transport = Transport, socket = Socket, packet_id = PacketId, inflight = Inflight}) ->
|
handle_cast({async_call, ReceiverPid, Ref, CallType, CallBin}, State = #state{transport = Transport, socket = Socket, packet_id = PacketId, inflight = Inflight}) ->
|
||||||
Transport:send(Socket, <<?PACKET_PUSH, PacketId:32, PushType:8, PushBin/binary>>),
|
Transport:send(Socket, <<?PACKET_ASYNC_CALL, PacketId:32, CallType:8, CallBin/binary>>),
|
||||||
{noreply, State#state{packet_id = PacketId + 1, inflight = maps:put(PacketId, {ReceiverPid, Ref}, Inflight)}}.
|
{noreply, State#state{packet_id = PacketId + 1, inflight = maps:put(PacketId, {ReceiverPid, Ref}, Inflight)}}.
|
||||||
|
|
||||||
%% auth验证
|
%% auth验证
|
||||||
@ -157,19 +157,19 @@ handle_info({tcp, Socket, <<?PACKET_REQUEST, ?METHOD_EVENT:8, EventData/binary>>
|
|||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|
||||||
%% 主机端的消息响应
|
%% 主机端的消息响应
|
||||||
handle_info({tcp, Socket, <<?PACKET_PUSH_REPLY, PacketId:32, ResponseBin/binary>>}, State = #state{socket = Socket, uuid = UUID, inflight = Inflight}) when PacketId > 0 ->
|
handle_info({tcp, Socket, <<?PACKET_ASYNC_CALL_REPLY, PacketId:32, ResponseBin/binary>>}, State = #state{socket = Socket, uuid = UUID, inflight = Inflight}) when PacketId > 0 ->
|
||||||
PushReply = message_pb:decode_msg(ResponseBin, push_reply),
|
AsyncCallReply = message_pb:decode_msg(ResponseBin, async_call_reply),
|
||||||
lager:debug("[ws_channel] uuid: ~p, get push_reply: ~p, packet_id: ~p", [UUID, PushReply, PacketId]),
|
lager:debug("[ws_channel] uuid: ~p, get async_call_reply: ~p, packet_id: ~p", [UUID, AsyncCallReply, PacketId]),
|
||||||
case maps:take(PacketId, Inflight) of
|
case maps:take(PacketId, Inflight) of
|
||||||
error ->
|
error ->
|
||||||
lager:warning("[ws_channel] get unknown async_response message: ~p, packet_id: ~p", [PushReply, PacketId]),
|
lager:warning("[ws_channel] get unknown async_call_reply message: ~p, packet_id: ~p", [AsyncCallReply, PacketId]),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
{{ReceiverPid, Ref}, NInflight} ->
|
{{ReceiverPid, Ref}, NInflight} ->
|
||||||
case is_pid(ReceiverPid) andalso is_process_alive(ReceiverPid) of
|
case is_pid(ReceiverPid) andalso is_process_alive(ReceiverPid) of
|
||||||
true ->
|
true ->
|
||||||
ReceiverPid ! {push_reply, Ref, PushReply};
|
ReceiverPid ! {push_reply, Ref, AsyncCallReply};
|
||||||
false ->
|
false ->
|
||||||
lager:warning("[ws_channel] get async_response message: ~p, packet_id: ~p, but receiver_pid is deaded", [PushReply, PacketId])
|
lager:warning("[ws_channel] get async_call_reply message: ~p, packet_id: ~p, but receiver_pid is deaded", [AsyncCallReply, PacketId])
|
||||||
end,
|
end,
|
||||||
{noreply, State#state{inflight = NInflight}}
|
{noreply, State#state{inflight = NInflight}}
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user