From 3f0de653941d48e1a66153302879c1b6e3f48d37 Mon Sep 17 00:00:00 2001 From: lsxredrain <34489690@qq.com> Date: Mon, 23 Aug 2021 19:36:50 +0800 Subject: [PATCH] add dgiot_grpc --- apps/dgiot_api/src/rest/dgiot_rest.erl | 2 +- apps/dgiot_grpc/README.md | 0 .../exhook-svr-python/exhook_server.py | 2 +- apps/dgiot_grpc/priv/protos/exhook.proto | 407 - apps/dgiot_grpc/src/dgiot_exhook_handler.erl | 324 - apps/dgiot_grpc/src/dgiot_exhook_server.erl | 325 - .../dgiot_exhook_v_1_hook_provider_bhvr.erl | 93 - .../dgiot_exhook_v_1_hook_provider_client.erl | 445 - apps/dgiot_grpc/src/dgiot_grpc.erl | 45 - apps/dgiot_grpc/src/dgiot_grpc_channel.erl | 96 +- apps/dgiot_grpc/src/dgiot_grpc_client.erl | 111 + .../{exhook_svr.erl => dgiot_grpc_server.erl} | 184 +- apps/dgiot_grpc/src/exhook_pb.erl | 15765 ---------------- apps/emqx_exhook/src/emqx_exhook_app.erl | 27 +- data/loaded_plugins.tmpl | 1 + rebar.config.erl | 2 + 16 files changed, 295 insertions(+), 17534 deletions(-) delete mode 100644 apps/dgiot_grpc/README.md delete mode 100644 apps/dgiot_grpc/priv/protos/exhook.proto delete mode 100644 apps/dgiot_grpc/src/dgiot_exhook_handler.erl delete mode 100644 apps/dgiot_grpc/src/dgiot_exhook_server.erl delete mode 100644 apps/dgiot_grpc/src/dgiot_exhook_v_1_hook_provider_bhvr.erl delete mode 100644 apps/dgiot_grpc/src/dgiot_exhook_v_1_hook_provider_client.erl delete mode 100644 apps/dgiot_grpc/src/dgiot_grpc.erl create mode 100644 apps/dgiot_grpc/src/dgiot_grpc_client.erl rename apps/dgiot_grpc/src/{exhook_svr.erl => dgiot_grpc_server.erl} (57%) delete mode 100644 apps/dgiot_grpc/src/exhook_pb.erl diff --git a/apps/dgiot_api/src/rest/dgiot_rest.erl b/apps/dgiot_api/src/rest/dgiot_rest.erl index 2754c53a..a4d377be 100644 --- a/apps/dgiot_api/src/rest/dgiot_rest.erl +++ b/apps/dgiot_api/src/rest/dgiot_rest.erl @@ -297,7 +297,7 @@ do_request(Populated, Req0, State = #state{ context = Context }) -> Args = [OperationID, Populated, Context, Req0], - ?LOG(info,"~p ~p",[OperationID,dgiot_data:get(?DGIOT_SWAGGER,OperationID)]), + ?LOG(debug,"~p ~p",[OperationID,dgiot_data:get(?DGIOT_SWAGGER,OperationID)]), Result = case IsMock of true -> diff --git a/apps/dgiot_grpc/README.md b/apps/dgiot_grpc/README.md deleted file mode 100644 index e69de29b..00000000 diff --git a/apps/dgiot_grpc/priv/example/python3/exhook-svr-python/exhook_server.py b/apps/dgiot_grpc/priv/example/python3/exhook-svr-python/exhook_server.py index 75bdf9e3..372ef09c 100644 --- a/apps/dgiot_grpc/priv/example/python3/exhook-svr-python/exhook_server.py +++ b/apps/dgiot_grpc/priv/example/python3/exhook-svr-python/exhook_server.py @@ -102,7 +102,7 @@ class HookProvider(exhook_pb2_grpc.HookProviderServicer): def OnMessagePublish(self, request, context): nmsg = request.message nmsg.payload = b"hardcode payload by exhook-svr-python111 :)" - + print(nmsg.payload) reply = exhook_pb2.ValuedResponse(type="STOP_AND_RETURN", message=nmsg) return reply diff --git a/apps/dgiot_grpc/priv/protos/exhook.proto b/apps/dgiot_grpc/priv/protos/exhook.proto deleted file mode 100644 index 866c8a1a..00000000 --- a/apps/dgiot_grpc/priv/protos/exhook.proto +++ /dev/null @@ -1,407 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2020-2021 EMQ Technologies Co., Ltd. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -//------------------------------------------------------------------------------ - -syntax = "proto3"; - -option csharp_namespace = "dgiot.Exhook.V1"; -option go_package = "dgiot.io/grpc/exhook"; -option java_multiple_files = true; -option java_package = "io.dgiot.exhook"; -option java_outer_classname = "DgiotExHookProto"; - -package dgiot.exhook.v1; - -service HookProvider { - - rpc OnProviderLoaded(ProviderLoadedRequest) returns (LoadedResponse) {}; - - rpc OnProviderUnloaded(ProviderUnloadedRequest) returns (EmptySuccess) {}; - - rpc OnClientConnect(ClientConnectRequest) returns (EmptySuccess) {}; - - rpc OnClientConnack(ClientConnackRequest) returns (EmptySuccess) {}; - - rpc OnClientConnected(ClientConnectedRequest) returns (EmptySuccess) {}; - - rpc OnClientDisconnected(ClientDisconnectedRequest) returns (EmptySuccess) {}; - - rpc OnClientAuthenticate(ClientAuthenticateRequest) returns (ValuedResponse) {}; - - rpc OnClientCheckAcl(ClientCheckAclRequest) returns (ValuedResponse) {}; - - rpc OnClientSubscribe(ClientSubscribeRequest) returns (EmptySuccess) {}; - - rpc OnClientUnsubscribe(ClientUnsubscribeRequest) returns (EmptySuccess) {}; - - rpc OnSessionCreated(SessionCreatedRequest) returns (EmptySuccess) {}; - - rpc OnSessionSubscribed(SessionSubscribedRequest) returns (EmptySuccess) {}; - - rpc OnSessionUnsubscribed(SessionUnsubscribedRequest) returns (EmptySuccess) {}; - - rpc OnSessionResumed(SessionResumedRequest) returns (EmptySuccess) {}; - - rpc OnSessionDiscarded(SessionDiscardedRequest) returns (EmptySuccess) {}; - - rpc OnSessionTakeovered(SessionTakeoveredRequest) returns (EmptySuccess) {}; - - rpc OnSessionTerminated(SessionTerminatedRequest) returns (EmptySuccess) {}; - - rpc OnMessagePublish(MessagePublishRequest) returns (ValuedResponse) {}; - - rpc OnMessageDelivered(MessageDeliveredRequest) returns (EmptySuccess) {}; - - rpc OnMessageDropped(MessageDroppedRequest) returns (EmptySuccess) {}; - - rpc OnMessageAcked(MessageAckedRequest) returns (EmptySuccess) {}; -} - -//------------------------------------------------------------------------------ -// Request & Response -//------------------------------------------------------------------------------ - -message ProviderLoadedRequest { - - BrokerInfo broker = 1; -} - -message LoadedResponse { - - repeated HookSpec hooks = 1; -} - -message ProviderUnloadedRequest { } - -message ClientConnectRequest { - - ConnInfo conninfo = 1; - - // MQTT CONNECT packet's properties (MQTT v5.0) - // - // It should be empty on MQTT v3.1.1/v3.1 or others protocol - repeated Property props = 2; -} - -message ClientConnackRequest { - - ConnInfo conninfo = 1; - - string result_code = 2; - - repeated Property props = 3; -} - -message ClientConnectedRequest { - - ClientInfo clientinfo = 1; -} - -message ClientDisconnectedRequest { - - ClientInfo clientinfo = 1; - - string reason = 2; -} - -message ClientAuthenticateRequest { - - ClientInfo clientinfo = 1; - - bool result = 2; -} - -message ClientCheckAclRequest { - - ClientInfo clientinfo = 1; - - enum AclReqType { - - PUBLISH = 0; - - SUBSCRIBE = 1; - } - - AclReqType type = 2; - - string topic = 3; - - bool result = 4; -} - -message ClientSubscribeRequest { - - ClientInfo clientinfo = 1; - - repeated Property props = 2; - - repeated TopicFilter topic_filters = 3; -} - -message ClientUnsubscribeRequest { - - ClientInfo clientinfo = 1; - - repeated Property props = 2; - - repeated TopicFilter topic_filters = 3; -} - -message SessionCreatedRequest { - - ClientInfo clientinfo = 1; -} - -message SessionSubscribedRequest { - - ClientInfo clientinfo = 1; - - string topic = 2; - - SubOpts subopts = 3; -} - -message SessionUnsubscribedRequest { - - ClientInfo clientinfo = 1; - - string topic = 2; -} - -message SessionResumedRequest { - - ClientInfo clientinfo = 1; -} - -message SessionDiscardedRequest { - - ClientInfo clientinfo = 1; -} - -message SessionTakeoveredRequest { - - ClientInfo clientinfo = 1; -} - -message SessionTerminatedRequest { - - ClientInfo clientinfo = 1; - - string reason = 2; -} - -message MessagePublishRequest { - - Message message = 1; -} - -message MessageDeliveredRequest { - - ClientInfo clientinfo = 1; - - Message message = 2; -} - -message MessageDroppedRequest { - - Message message = 1; - - string reason = 2; -} - -message MessageAckedRequest { - - ClientInfo clientinfo = 1; - - Message message = 2; -} - -//------------------------------------------------------------------------------ -// Basic data types -//------------------------------------------------------------------------------ - -message EmptySuccess { } - -message ValuedResponse { - - // The responsed value type - // - contiune: Use the responsed value and execute the next hook - // - ignore: Ignore the responsed value - // - stop_and_return: Use the responsed value and stop the chain executing - enum ResponsedType { - - CONTINUE = 0; - - IGNORE = 1; - - STOP_AND_RETURN = 2; - } - - ResponsedType type = 1; - - oneof value { - - // Boolean result, used on the 'client.authenticate', 'client.check_acl' hooks - bool bool_result = 3; - - // Message result, used on the 'message.*' hooks - Message message = 4; - } -} - -message BrokerInfo { - - string version = 1; - - string sysdescr = 2; - - string uptime = 3; - - string datetime = 4; -} - -message HookSpec { - - // The registered hooks name - // - // Available value: - // "client.connect", "client.connack" - // "client.connected", "client.disconnected" - // "client.authenticate", "client.check_acl" - // "client.subscribe", "client.unsubscribe" - // - // "session.created", "session.subscribed" - // "session.unsubscribed", "session.resumed" - // "session.discarded", "session.takeovered" - // "session.terminated" - // - // "message.publish", "message.delivered" - // "message.acked", "message.dropped" - string name = 1; - - // The topic filters for message hooks - repeated string topics = 2; -} - -message ConnInfo { - - string node = 1; - - string clientid = 2; - - string username = 3; - - string peerhost = 4; - - uint32 sockport = 5; - - string proto_name = 6; - - string proto_ver = 7; - - uint32 keepalive = 8; -} - -message ClientInfo { - - string node = 1; - - string clientid = 2; - - string username = 3; - - string password = 4; - - string peerhost = 5; - - uint32 sockport = 6; - - string protocol = 7; - - string mountpoint = 8; - - bool is_superuser = 9; - - bool anonymous = 10; - - // common name of client TLS cert - string cn = 11; - - // subject of client TLS cert - string dn = 12; -} - -message Message { - - string node = 1; - - string id = 2; - - uint32 qos = 3; - - string from = 4; - - string topic = 5; - - bytes payload = 6; - - uint64 timestamp = 7; -} - -message Property { - - string name = 1; - - string value = 2; -} - -message TopicFilter { - - string name = 1; - - uint32 qos = 2; -} - -message SubOpts { - - // The QoS level - uint32 qos = 1; - - // The group name for shared subscription - string share = 2; - - // The Retain Handling option (MQTT v5.0) - // - // 0 = Send retained messages at the time of the subscribe - // 1 = Send retained messages at subscribe only if the subscription does - // not currently exist - // 2 = Do not send retained messages at the time of the subscribe - uint32 rh = 3; - - // The Retain as Published option (MQTT v5.0) - // - // If 1, Application Messages forwarded using this subscription keep the - // RETAIN flag they were published with. - // If 0, Application Messages forwarded using this subscription have the - // RETAIN flag set to 0. - // Retained messages sent when the subscription is established have the RETAIN flag set to 1. - uint32 rap = 4; - - // The No Local option (MQTT v5.0) - // - // If the value is 1, Application Messages MUST NOT be forwarded to a - // connection with a ClientID equal to the ClientID of the publishing - uint32 nl = 5; -} diff --git a/apps/dgiot_grpc/src/dgiot_exhook_handler.erl b/apps/dgiot_grpc/src/dgiot_exhook_handler.erl deleted file mode 100644 index 2dc8597b..00000000 --- a/apps/dgiot_grpc/src/dgiot_exhook_handler.erl +++ /dev/null @@ -1,324 +0,0 @@ -%%-------------------------------------------------------------------- -%% Copyright (c) 2020 DGIOT Technologies Co., Ltd. All Rights Reserved. -%% -%% Licensed under the Apache License, Version 2.0 (the "License"); -%% you may not use this file except in compliance with the License. -%% You may obtain a copy of the License at -%% -%% http://www.apache.org/licenses/LICENSE-2.0 -%% -%% Unless required by applicable law or agreed to in writing, software -%% distributed under the License is distributed on an "AS IS" BASIS, -%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -%% See the License for the specific language governing permissions and -%% limitations under the License. -%%-------------------------------------------------------------------- - --module(dgiot_exhook_handler). - --include("dgiot_grpc.hrl"). --include_lib("dgiot/include/logger.hrl"). --include_lib("emqx/include/emqx.hrl"). - --export([ on_client_connect/2 - , on_client_connack/3 - , on_client_connected/2 - , on_client_disconnected/3 - , on_client_authenticate/2 - , on_client_check_acl/4 - , on_client_subscribe/3 - , on_client_unsubscribe/3 - ]). - -%% Session Lifecircle Hooks --export([ on_session_created/2 - , on_session_subscribed/3 - , on_session_unsubscribed/3 - , on_session_resumed/2 - , on_session_discarded/2 - , on_session_takeovered/2 - , on_session_terminated/3 - ]). - --export([ on_message_publish/1 - , on_message_dropped/3 - , on_message_delivered/2 - , on_message_acked/2 - ]). - -%% Utils --export([ message/1 - , stringfy/1 - , merge_responsed_bool/2 - , merge_responsed_message/2 - , assign_to_message/2 - , clientinfo/1 - ]). - --import(emqx_exhook, - [ cast/2 - , call_fold/3 - ]). - -%%-------------------------------------------------------------------- -%% Clients -%%-------------------------------------------------------------------- - -on_client_connect(ConnInfo, Props) -> - Req = #{conninfo => conninfo(ConnInfo), - props => properties(Props) - }, - cast('client.connect', Req). - -on_client_connack(ConnInfo, Rc, Props) -> - Req = #{conninfo => conninfo(ConnInfo), - result_code => stringfy(Rc), - props => properties(Props)}, - cast('client.connack', Req). - -on_client_connected(ClientInfo, _ConnInfo) -> - Req = #{clientinfo => clientinfo(ClientInfo)}, - cast('client.connected', Req). - -on_client_disconnected(ClientInfo, Reason, _ConnInfo) -> - Req = #{clientinfo => clientinfo(ClientInfo), - reason => stringfy(Reason) - }, - cast('client.disconnected', Req). - -on_client_authenticate(ClientInfo, AuthResult) -> - %% XXX: Bool is missing more information about the atom of the result - %% So, the `Req` has missed detailed info too. - %% - %% The return value of `call_fold` just a bool, that has missed - %% detailed info too. - %% - Bool = maps:get(auth_result, AuthResult, undefined) == success, - Req = #{clientinfo => clientinfo(ClientInfo), - result => Bool - }, - - case call_fold('client.authenticate', Req, - fun merge_responsed_bool/2) of - {StopOrOk, #{result := Result0}} when is_boolean(Result0) -> - Result = case Result0 of true -> success; _ -> not_authorized end, - {StopOrOk, AuthResult#{auth_result => Result, anonymous => false}}; - _ -> - {ok, AuthResult} - end. - -on_client_check_acl(ClientInfo, PubSub, Topic, Result) -> - Bool = Result == allow, - Type = case PubSub of - publish -> 'PUBLISH'; - subscribe -> 'SUBSCRIBE' - end, - Req = #{clientinfo => clientinfo(ClientInfo), - type => Type, - topic => Topic, - result => Bool - }, - case call_fold('client.check_acl', Req, - fun merge_responsed_bool/2) of - {StopOrOk, #{result := Result0}} when is_boolean(Result0) -> - NResult = case Result0 of true -> allow; _ -> deny end, - {StopOrOk, NResult}; - _ -> {ok, Result} - end. - -on_client_subscribe(ClientInfo, Props, TopicFilters) -> - Req = #{clientinfo => clientinfo(ClientInfo), - props => properties(Props), - topic_filters => topicfilters(TopicFilters) - }, - cast('client.subscribe', Req). - -on_client_unsubscribe(ClientInfo, Props, TopicFilters) -> - Req = #{clientinfo => clientinfo(ClientInfo), - props => properties(Props), - topic_filters => topicfilters(TopicFilters) - }, - cast('client.unsubscribe', Req). - -%%-------------------------------------------------------------------- -%% Session -%%-------------------------------------------------------------------- - -on_session_created(ClientInfo, _SessInfo) -> - Req = #{clientinfo => clientinfo(ClientInfo)}, - cast('session.created', Req). - -on_session_subscribed(ClientInfo, Topic, SubOpts) -> - Req = #{clientinfo => clientinfo(ClientInfo), - topic => Topic, - subopts => maps:with([qos, share, rh, rap, nl], SubOpts) - }, - cast('session.subscribed', Req). - -on_session_unsubscribed(ClientInfo, Topic, _SubOpts) -> - Req = #{clientinfo => clientinfo(ClientInfo), - topic => Topic - }, - cast('session.unsubscribed', Req). - -on_session_resumed(ClientInfo, _SessInfo) -> - Req = #{clientinfo => clientinfo(ClientInfo)}, - cast('session.resumed', Req). - -on_session_discarded(ClientInfo, _SessInfo) -> - Req = #{clientinfo => clientinfo(ClientInfo)}, - cast('session.discarded', Req). - -on_session_takeovered(ClientInfo, _SessInfo) -> - Req = #{clientinfo => clientinfo(ClientInfo)}, - cast('session.takeovered', Req). - -on_session_terminated(ClientInfo, Reason, _SessInfo) -> - Req = #{clientinfo => clientinfo(ClientInfo), - reason => stringfy(Reason)}, - cast('session.terminated', Req). - -%%-------------------------------------------------------------------- -%% Message -%%-------------------------------------------------------------------- - -on_message_publish(#message{topic = <<"$SYS/", _/binary>>}) -> - ok; -on_message_publish(Message) -> - Req = #{message => message(Message)}, - case call_fold('message.publish', Req, - fun emqx_exhook_handler:merge_responsed_message/2) of - {StopOrOk, #{message := NMessage}} -> - {StopOrOk, assign_to_message(NMessage, Message)}; - _ -> - {ok, Message} - end. - -on_message_dropped(#message{topic = <<"$SYS/", _/binary>>}, _By, _Reason) -> - ok; -on_message_dropped(Message, _By, Reason) -> - Req = #{message => message(Message), - reason => stringfy(Reason) - }, - cast('message.dropped', Req). - -on_message_delivered(_ClientInfo, #message{topic = <<"$SYS/", _/binary>>}) -> - ok; -on_message_delivered(ClientInfo, Message) -> - Req = #{clientinfo => clientinfo(ClientInfo), - message => message(Message) - }, - cast('message.delivered', Req). - -on_message_acked(_ClientInfo, #message{topic = <<"$SYS/", _/binary>>}) -> - ok; -on_message_acked(ClientInfo, Message) -> - Req = #{clientinfo => clientinfo(ClientInfo), - message => message(Message) - }, - cast('message.acked', Req). - -%%-------------------------------------------------------------------- -%% Types - -properties(undefined) -> []; -properties(M) when is_map(M) -> - maps:fold(fun(K, V, Acc) -> - [#{name => stringfy(K), - value => stringfy(V)} | Acc] - end, [], M). - -conninfo(_ConnInfo = - #{clientid := ClientId, username := Username, peername := {Peerhost, _}, - sockname := {_, SockPort}, proto_name := ProtoName, proto_ver := ProtoVer, - keepalive := Keepalive}) -> - #{node => stringfy(node()), - clientid => ClientId, - username => maybe(Username), - peerhost => ntoa(Peerhost), - sockport => SockPort, - proto_name => ProtoName, - proto_ver => stringfy(ProtoVer), - keepalive => Keepalive}. - -clientinfo(ClientInfo = - #{clientid := ClientId, username := Username, peerhost := PeerHost, - sockport := SockPort, protocol := Protocol, mountpoint := Mountpoiont}) -> - #{node => stringfy(node()), - clientid => ClientId, - username => maybe(Username), - password => maybe(maps:get(password, ClientInfo, undefined)), - peerhost => ntoa(PeerHost), - sockport => SockPort, - protocol => stringfy(Protocol), - mountpoint => maybe(Mountpoiont), - is_superuser => maps:get(is_superuser, ClientInfo, false), - anonymous => maps:get(anonymous, ClientInfo, true), - cn => maybe(maps:get(cn, ClientInfo, undefined)), - dn => maybe(maps:get(dn, ClientInfo, undefined))}. - -message(#message{id = Id, qos = Qos, from = From, topic = Topic, payload = Payload, timestamp = Ts}) -> - #{node => stringfy(node()), - id => emqx_guid:to_hexstr(Id), - qos => Qos, - from => stringfy(From), - topic => Topic, - payload => Payload, - timestamp => Ts}. - -assign_to_message(#{qos := Qos, topic := Topic, payload := Payload}, Message) -> - Message#message{qos = Qos, topic = Topic, payload = Payload}. - -topicfilters(Tfs) when is_list(Tfs) -> - [#{name => Topic, qos => Qos} || {Topic, #{qos := Qos}} <- Tfs]. - -ntoa({0,0,0,0,0,16#ffff,AB,CD}) -> - list_to_binary(inet_parse:ntoa({AB bsr 8, AB rem 256, CD bsr 8, CD rem 256})); -ntoa(IP) -> - list_to_binary(inet_parse:ntoa(IP)). - -maybe(undefined) -> <<>>; -maybe(B) -> B. - -%% @private -stringfy(Term) when is_binary(Term) -> - Term; -stringfy(Term) when is_integer(Term) -> - integer_to_binary(Term); -stringfy(Term) when is_atom(Term) -> - atom_to_binary(Term, utf8); -stringfy(Term) -> - unicode:characters_to_binary((io_lib:format("~0p", [Term]))). - -%%-------------------------------------------------------------------- -%% Acc funcs - -%% see exhook.proto -merge_responsed_bool(_Req, #{type := 'IGNORE'}) -> - ignore; -merge_responsed_bool(Req, #{type := Type, value := {bool_result, NewBool}}) - when is_boolean(NewBool) -> - NReq = Req#{result => NewBool}, - case Type of - 'CONTINUE' -> {ok, NReq}; - 'STOP_AND_RETURN' -> - ?LOG(error,"NReq ~p",[NReq]), - {stop, NReq} - end; -merge_responsed_bool(_Req, Resp) -> - ?LOG(warning, "Unknown responsed value ~0p to merge to callback chain", [Resp]), - ignore. - -merge_responsed_message(_Req, #{type := 'IGNORE'}) -> - ignore; -merge_responsed_message(Req, #{type := Type, value := {message, NMessage}}) -> - NReq = Req#{message => NMessage}, - case Type of - 'CONTINUE' -> {ok, NReq}; - 'STOP_AND_RETURN' -> - ?LOG(error,"NReq ~p",[NReq]), - {stop, NReq} - end; -merge_responsed_message(_Req, Resp) -> - ?LOG(warning, "Unknown responsed value ~0p to merge to callback chain", [Resp]), - ignore. diff --git a/apps/dgiot_grpc/src/dgiot_exhook_server.erl b/apps/dgiot_grpc/src/dgiot_exhook_server.erl deleted file mode 100644 index 16bc9c70..00000000 --- a/apps/dgiot_grpc/src/dgiot_exhook_server.erl +++ /dev/null @@ -1,325 +0,0 @@ -%%-------------------------------------------------------------------- -%% Copyright (c) 2020 DGIOT Technologies Co., Ltd. All Rights Reserved. -%% -%% Licensed under the Apache License, Version 2.0 (the "License"); -%% you may not use this file except in compliance with the License. -%% You may obtain a copy of the License at -%% -%% http://www.apache.org/licenses/LICENSE-2.0 -%% -%% Unless required by applicable law or agreed to in writing, software -%% distributed under the License is distributed on an "AS IS" BASIS, -%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -%% See the License for the specific language governing permissions and -%% limitations under the License. -%%-------------------------------------------------------------------- - --module(dgiot_exhook_server). - --include("dgiot_grpc.hrl"). --include_lib("dgiot/include/logger.hrl"). - --define(CNTER, emqx_exhook_counter). --define(PB_CLIENT_MOD, dgiot_exhook_v_1_hook_provider_client). - -%% Load/Unload --export([ load/2 - , unload/1 - ]). - -%% APIs --export([call/3]). - -%% Infos --export([ name/1 - , format/1 - ]). - --record(server, { - %% Server name (equal to grpc client channel name) - name :: server_name(), - %% The server started options - options :: list(), - %% gRPC channel pid - channel :: pid(), - %% Registered hook names and options - hookspec :: #{hookpoint() => map()}, - %% Metrcis name prefix - prefix :: list() - }). - --type server_name() :: string(). --type server() :: #server{}. - --type hookpoint() :: 'client.connect' - | 'client.connack' - | 'client.connected' - | 'client.disconnected' - | 'client.authenticate' - | 'client.check_acl' - | 'client.subscribe' - | 'client.unsubscribe' - | 'session.created' - | 'session.subscribed' - | 'session.unsubscribed' - | 'session.resumed' - | 'session.discarded' - | 'session.takeovered' - | 'session.terminated' - | 'message.publish' - | 'message.delivered' - | 'message.acked' - | 'message.dropped'. - --export_type([server/0]). - --dialyzer({nowarn_function, [inc_metrics/2]}). - -%%-------------------------------------------------------------------- -%% Load/Unload APIs -%%-------------------------------------------------------------------- - --spec load(atom(), list()) -> {ok, server()} | {error, term()} . -load(Name0, Opts0) -> - Name = to_list(Name0), - {SvrAddr, ClientOpts} = channel_opts(Opts0), - case emqx_exhook_sup:start_grpc_client_channel( - Name, - SvrAddr, - ClientOpts) of - {ok, _ChannPoolPid} -> - case do_init(Name) of - {ok, HookSpecs} -> - %% Reigster metrics - Prefix = lists:flatten( - io_lib:format("exhook.~s.", [Name])), - ensure_metrics(Prefix, HookSpecs), - %% Ensure hooks - ensure_hooks(HookSpecs), - {ok, #server{name = Name, - options = Opts0, - channel = _ChannPoolPid, - hookspec = HookSpecs, - prefix = Prefix }}; - {error, _} = E -> - emqx_exhook_sup:stop_grpc_client_channel(Name), E - end; - {error, _} = E -> E - end. - -%% @private -to_list(Name) when is_atom(Name) -> - atom_to_list(Name); -to_list(Name) when is_binary(Name) -> - binary_to_list(Name); -to_list(Name) when is_list(Name) -> - Name. - -%% @private -channel_opts(Opts) -> - Scheme = proplists:get_value(scheme, Opts), - Host = proplists:get_value(host, Opts), - Port = proplists:get_value(port, Opts), - SvrAddr = format_http_uri(Scheme, Host, Port), - ClientOpts = case Scheme of - https -> - SslOpts = lists:keydelete(ssl, 1, proplists:get_value(ssl_options, Opts, [])), - #{gun_opts => - #{transport => ssl, - transport_opts => SslOpts}}; - _ -> #{} - end, - {SvrAddr, ClientOpts}. - -format_http_uri(Scheme, Host0, Port) -> - Host = case is_tuple(Host0) of - true -> inet:ntoa(Host0); - _ -> Host0 - end, - lists:flatten(io_lib:format("~s://~s:~w", [Scheme, Host, Port])). - --spec unload(server()) -> ok. -unload(#server{name = Name, hookspec = HookSpecs}) -> - _ = do_deinit(Name), - _ = may_unload_hooks(HookSpecs), - _ = emqx_exhook_sup:stop_grpc_client_channel(Name), - ok. - -do_deinit(Name) -> - _ = do_call(Name, 'on_provider_unloaded', #{}), - ok. - -do_init(ChannName) -> - Req = #{broker => maps:from_list(emqx_sys:info())}, - case do_call(ChannName, 'on_provider_loaded', Req) of - {ok, InitialResp} -> - try - {ok, resovle_hookspec(maps:get(hooks, InitialResp, []))} - catch _:Reason:Stk -> - ?LOG(error, "try to init ~p failed, reason: ~p, stacktrace: ~0p", - [ChannName, Reason, Stk]), - {error, Reason} - end; - {error, Reason} -> - {error, Reason} - end. - -%% @private -resovle_hookspec(HookSpecs) when is_list(HookSpecs) -> - MessageHooks = message_hooks(), - AvailableHooks = available_hooks(), - lists:foldr(fun(HookSpec, Acc) -> - case maps:get(name, HookSpec, undefined) of - undefined -> Acc; - Name0 -> - Name = try binary_to_existing_atom(Name0, utf8) catch T:R:_ -> {T,R} end, - case lists:member(Name, AvailableHooks) of - true -> - case lists:member(Name, MessageHooks) of - true -> - Acc#{Name => #{topics => maps:get(topics, HookSpec, [])}}; - _ -> - Acc#{Name => #{}} - end; - _ -> error({unknown_hookpoint, Name}) - end - end - end, #{}, HookSpecs). - -ensure_metrics(Prefix, HookSpecs) -> - Keys = [list_to_atom(Prefix ++ atom_to_list(Hookpoint)) - || Hookpoint <- maps:keys(HookSpecs)], - lists:foreach(fun emqx_metrics:ensure/1, Keys). - -ensure_hooks(HookSpecs) -> - lists:foreach(fun(Hookpoint) -> - case lists:keyfind(Hookpoint, 1, ?ENABLED_HOOKS) of - false -> - ?LOG(error, "Unknown name ~s to hook, skip it!", [Hookpoint]); - {Hookpoint, {M, F, A}} -> - emqx_hooks:put(Hookpoint, {M, F, A}), - ets:update_counter(?CNTER, Hookpoint, {2, 1}, {Hookpoint, 0}) - end - end, maps:keys(HookSpecs)). - -may_unload_hooks(HookSpecs) -> - lists:foreach(fun(Hookpoint) -> - case ets:update_counter(?CNTER, Hookpoint, {2, -1}, {Hookpoint, 0}) of - Cnt when Cnt =< 0 -> - case lists:keyfind(Hookpoint, 1, ?ENABLED_HOOKS) of - {Hookpoint, {M, F, _A}} -> - emqx_hooks:del(Hookpoint, {M, F}); - _ -> ok - end, - ets:delete(?CNTER, Hookpoint); - _ -> ok - end - end, maps:keys(HookSpecs)). - -format(#server{name = Name, hookspec = Hooks}) -> - io_lib:format("name=~p, hooks=~0p", [Name, Hooks]). - -%%-------------------------------------------------------------------- -%% APIs -%%-------------------------------------------------------------------- - -name(#server{name = Name}) -> - Name. - --spec call(hookpoint(), map(), server()) - -> ignore - | {ok, Resp :: term()} - | {error, term()}. -call(Hookpoint, Req, #server{name = ChannName, hookspec = Hooks, prefix = Prefix}) -> - GrpcFunc = hk2func(Hookpoint), - case maps:get(Hookpoint, Hooks, undefined) of - undefined -> ignore; - Opts -> - NeedCall = case lists:member(Hookpoint, message_hooks()) of - false -> true; - _ -> - #{message := #{topic := Topic}} = Req, - match_topic_filter(Topic, maps:get(topics, Opts, [])) - end, - case NeedCall of - false -> ignore; - _ -> - inc_metrics(Prefix, Hookpoint), - do_call(ChannName, GrpcFunc, Req) - end - end. - -%% @private -inc_metrics(IncFun, Name) when is_function(IncFun) -> - %% BACKW: e4.2.0-e4.2.2 - {env, [Prefix|_]} = erlang:fun_info(IncFun, env), - inc_metrics(Prefix, Name); -inc_metrics(Prefix, Name) when is_list(Prefix) -> - emqx_metrics:inc(list_to_atom(Prefix ++ atom_to_list(Name))). - --compile({inline, [match_topic_filter/2]}). -match_topic_filter(_, []) -> - true; -match_topic_filter(TopicName, TopicFilter) -> - lists:any(fun(F) -> emqx_topic:match(TopicName, F) end, TopicFilter). - --spec do_call(string(), atom(), map()) -> {ok, map()} | {error, term()}. -do_call(ChannName, Fun, Req) -> - Options = #{channel => ChannName}, - ?LOG(debug, "Call ~0p:~0p(~0p, ~0p)", [?PB_CLIENT_MOD, Fun, Req, Options]), - case catch apply(?PB_CLIENT_MOD, Fun, [Req, Options]) of - {ok, Resp, _Metadata} -> - ?LOG(debug, "Response {ok, ~0p, ~0p}", [Resp, _Metadata]), - {ok, Resp}; - {error, {Code, Msg}, _Metadata} -> - ?LOG(error, "CALL ~0p:~0p(~0p, ~0p) response errcode: ~0p, errmsg: ~0p", - [?PB_CLIENT_MOD, Fun, Req, Options, Code, Msg]), - {error, {Code, Msg}}; - {error, Reason} -> - ?LOG(error, "CALL ~0p:~0p(~0p, ~0p) error: ~0p", - [?PB_CLIENT_MOD, Fun, Req, Options, Reason]), - {error, Reason}; - {'EXIT', {Reason, Stk}} -> - ?LOG(error, "CALL ~0p:~0p(~0p, ~0p) throw an exception: ~0p, stacktrace: ~0p", - [?PB_CLIENT_MOD, Fun, Req, Options, Reason, Stk]), - {error, Reason} - end. - -%%-------------------------------------------------------------------- -%% Internal funcs -%%-------------------------------------------------------------------- - --compile({inline, [hk2func/1]}). -hk2func('client.connect') -> 'on_client_connect'; -hk2func('client.connack') -> 'on_client_connack'; -hk2func('client.connected') -> 'on_client_connected'; -hk2func('client.disconnected') -> 'on_client_disconnected'; -hk2func('client.authenticate') -> 'on_client_authenticate'; -hk2func('client.check_acl') -> 'on_client_check_acl'; -hk2func('client.subscribe') -> 'on_client_subscribe'; -hk2func('client.unsubscribe') -> 'on_client_unsubscribe'; -hk2func('session.created') -> 'on_session_created'; -hk2func('session.subscribed') -> 'on_session_subscribed'; -hk2func('session.unsubscribed') -> 'on_session_unsubscribed'; -hk2func('session.resumed') -> 'on_session_resumed'; -hk2func('session.discarded') -> 'on_session_discarded'; -hk2func('session.takeovered') -> 'on_session_takeovered'; -hk2func('session.terminated') -> 'on_session_terminated'; -hk2func('message.publish') -> 'on_message_publish'; -hk2func('message.delivered') ->'on_message_delivered'; -hk2func('message.acked') -> 'on_message_acked'; -hk2func('message.dropped') ->'on_message_dropped'. - --compile({inline, [message_hooks/0]}). -message_hooks() -> - ['message.publish', 'message.delivered', - 'message.acked', 'message.dropped']. - --compile({inline, [available_hooks/0]}). -available_hooks() -> - ['client.connect', 'client.connack', 'client.connected', - 'client.disconnected', 'client.authenticate', 'client.check_acl', - 'client.subscribe', 'client.unsubscribe', - 'session.created', 'session.subscribed', 'session.unsubscribed', - 'session.resumed', 'session.discarded', 'session.takeovered', - 'session.terminated' | message_hooks()]. diff --git a/apps/dgiot_grpc/src/dgiot_exhook_v_1_hook_provider_bhvr.erl b/apps/dgiot_grpc/src/dgiot_exhook_v_1_hook_provider_bhvr.erl deleted file mode 100644 index 39cd46f7..00000000 --- a/apps/dgiot_grpc/src/dgiot_exhook_v_1_hook_provider_bhvr.erl +++ /dev/null @@ -1,93 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Behaviour to implement for grpc service dgiot.exhook.v1.HookProvider. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(dgiot_exhook_v_1_hook_provider_bhvr). - --callback on_provider_loaded(exhook_pb:provider_loaded_request(), grpc:metadata()) - -> {ok, exhook_pb:loaded_response(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_provider_unloaded(exhook_pb:provider_unloaded_request(), grpc:metadata()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_client_connect(exhook_pb:client_connect_request(), grpc:metadata()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_client_connack(exhook_pb:client_connack_request(), grpc:metadata()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_client_connected(exhook_pb:client_connected_request(), grpc:metadata()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_client_disconnected(exhook_pb:client_disconnected_request(), grpc:metadata()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_client_authenticate(exhook_pb:client_authenticate_request(), grpc:metadata()) - -> {ok, exhook_pb:valued_response(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_client_check_acl(exhook_pb:client_check_acl_request(), grpc:metadata()) - -> {ok, exhook_pb:valued_response(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_client_subscribe(exhook_pb:client_subscribe_request(), grpc:metadata()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_client_unsubscribe(exhook_pb:client_unsubscribe_request(), grpc:metadata()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_session_created(exhook_pb:session_created_request(), grpc:metadata()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_session_subscribed(exhook_pb:session_subscribed_request(), grpc:metadata()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_session_unsubscribed(exhook_pb:session_unsubscribed_request(), grpc:metadata()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_session_resumed(exhook_pb:session_resumed_request(), grpc:metadata()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_session_discarded(exhook_pb:session_discarded_request(), grpc:metadata()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_session_takeovered(exhook_pb:session_takeovered_request(), grpc:metadata()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_session_terminated(exhook_pb:session_terminated_request(), grpc:metadata()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_message_publish(exhook_pb:message_publish_request(), grpc:metadata()) - -> {ok, exhook_pb:valued_response(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_message_delivered(exhook_pb:message_delivered_request(), grpc:metadata()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_message_dropped(exhook_pb:message_dropped_request(), grpc:metadata()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - --callback on_message_acked(exhook_pb:message_acked_request(), grpc:metadata()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_stream:error_response()}. - diff --git a/apps/dgiot_grpc/src/dgiot_exhook_v_1_hook_provider_client.erl b/apps/dgiot_grpc/src/dgiot_exhook_v_1_hook_provider_client.erl deleted file mode 100644 index 8cfa125f..00000000 --- a/apps/dgiot_grpc/src/dgiot_exhook_v_1_hook_provider_client.erl +++ /dev/null @@ -1,445 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Client module for grpc service dgiot.exhook.v1.HookProvider. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(dgiot_exhook_v_1_hook_provider_client). - --compile(export_all). --compile(nowarn_export_all). - --include_lib("grpc/include/grpc.hrl"). - --define(SERVICE, 'dgiot.exhook.v1.HookProvider'). --define(PROTO_MODULE, 'exhook_pb'). --define(MARSHAL(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). --define(UNMARSHAL(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). --define(DEF(Path, Req, Resp, MessageType), - #{path => Path, - service =>?SERVICE, - message_type => MessageType, - marshal => ?MARSHAL(Req), - unmarshal => ?UNMARSHAL(Resp)}). - --spec on_provider_loaded(exhook_pb:provider_loaded_request()) - -> {ok, exhook_pb:loaded_response(), grpc:metadata()} - | {error, term()}. -on_provider_loaded(Req) -> - on_provider_loaded(Req, #{}, #{}). - --spec on_provider_loaded(exhook_pb:provider_loaded_request(), grpc:options()) - -> {ok, exhook_pb:loaded_response(), grpc:metadata()} - | {error, term()}. -on_provider_loaded(Req, Options) -> - on_provider_loaded(Req, #{}, Options). - --spec on_provider_loaded(exhook_pb:provider_loaded_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:loaded_response(), grpc:metadata()} - | {error, term()}. -on_provider_loaded(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnProviderLoaded">>, - provider_loaded_request, loaded_response, <<"dgiot.exhook.v1.ProviderLoadedRequest">>), - Req, Metadata, Options). - --spec on_provider_unloaded(exhook_pb:provider_unloaded_request()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_provider_unloaded(Req) -> - on_provider_unloaded(Req, #{}, #{}). - --spec on_provider_unloaded(exhook_pb:provider_unloaded_request(), grpc:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_provider_unloaded(Req, Options) -> - on_provider_unloaded(Req, #{}, Options). - --spec on_provider_unloaded(exhook_pb:provider_unloaded_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_provider_unloaded(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnProviderUnloaded">>, - provider_unloaded_request, empty_success, <<"dgiot.exhook.v1.ProviderUnloadedRequest">>), - Req, Metadata, Options). - --spec on_client_connect(exhook_pb:client_connect_request()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_connect(Req) -> - on_client_connect(Req, #{}, #{}). - --spec on_client_connect(exhook_pb:client_connect_request(), grpc:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_connect(Req, Options) -> - on_client_connect(Req, #{}, Options). - --spec on_client_connect(exhook_pb:client_connect_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_connect(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnClientConnect">>, - client_connect_request, empty_success, <<"dgiot.exhook.v1.ClientConnectRequest">>), - Req, Metadata, Options). - --spec on_client_connack(exhook_pb:client_connack_request()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_connack(Req) -> - on_client_connack(Req, #{}, #{}). - --spec on_client_connack(exhook_pb:client_connack_request(), grpc:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_connack(Req, Options) -> - on_client_connack(Req, #{}, Options). - --spec on_client_connack(exhook_pb:client_connack_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_connack(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnClientConnack">>, - client_connack_request, empty_success, <<"dgiot.exhook.v1.ClientConnackRequest">>), - Req, Metadata, Options). - --spec on_client_connected(exhook_pb:client_connected_request()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_connected(Req) -> - on_client_connected(Req, #{}, #{}). - --spec on_client_connected(exhook_pb:client_connected_request(), grpc:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_connected(Req, Options) -> - on_client_connected(Req, #{}, Options). - --spec on_client_connected(exhook_pb:client_connected_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_connected(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnClientConnected">>, - client_connected_request, empty_success, <<"dgiot.exhook.v1.ClientConnectedRequest">>), - Req, Metadata, Options). - --spec on_client_disconnected(exhook_pb:client_disconnected_request()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_disconnected(Req) -> - on_client_disconnected(Req, #{}, #{}). - --spec on_client_disconnected(exhook_pb:client_disconnected_request(), grpc:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_disconnected(Req, Options) -> - on_client_disconnected(Req, #{}, Options). - --spec on_client_disconnected(exhook_pb:client_disconnected_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_disconnected(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnClientDisconnected">>, - client_disconnected_request, empty_success, <<"dgiot.exhook.v1.ClientDisconnectedRequest">>), - Req, Metadata, Options). - --spec on_client_authenticate(exhook_pb:client_authenticate_request()) - -> {ok, exhook_pb:valued_response(), grpc:metadata()} - | {error, term()}. -on_client_authenticate(Req) -> - on_client_authenticate(Req, #{}, #{}). - --spec on_client_authenticate(exhook_pb:client_authenticate_request(), grpc:options()) - -> {ok, exhook_pb:valued_response(), grpc:metadata()} - | {error, term()}. -on_client_authenticate(Req, Options) -> - on_client_authenticate(Req, #{}, Options). - --spec on_client_authenticate(exhook_pb:client_authenticate_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:valued_response(), grpc:metadata()} - | {error, term()}. -on_client_authenticate(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnClientAuthenticate">>, - client_authenticate_request, valued_response, <<"dgiot.exhook.v1.ClientAuthenticateRequest">>), - Req, Metadata, Options). - --spec on_client_check_acl(exhook_pb:client_check_acl_request()) - -> {ok, exhook_pb:valued_response(), grpc:metadata()} - | {error, term()}. -on_client_check_acl(Req) -> - on_client_check_acl(Req, #{}, #{}). - --spec on_client_check_acl(exhook_pb:client_check_acl_request(), grpc:options()) - -> {ok, exhook_pb:valued_response(), grpc:metadata()} - | {error, term()}. -on_client_check_acl(Req, Options) -> - on_client_check_acl(Req, #{}, Options). - --spec on_client_check_acl(exhook_pb:client_check_acl_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:valued_response(), grpc:metadata()} - | {error, term()}. -on_client_check_acl(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnClientCheckAcl">>, - client_check_acl_request, valued_response, <<"dgiot.exhook.v1.ClientCheckAclRequest">>), - Req, Metadata, Options). - --spec on_client_subscribe(exhook_pb:client_subscribe_request()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_subscribe(Req) -> - on_client_subscribe(Req, #{}, #{}). - --spec on_client_subscribe(exhook_pb:client_subscribe_request(), grpc:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_subscribe(Req, Options) -> - on_client_subscribe(Req, #{}, Options). - --spec on_client_subscribe(exhook_pb:client_subscribe_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_subscribe(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnClientSubscribe">>, - client_subscribe_request, empty_success, <<"dgiot.exhook.v1.ClientSubscribeRequest">>), - Req, Metadata, Options). - --spec on_client_unsubscribe(exhook_pb:client_unsubscribe_request()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_unsubscribe(Req) -> - on_client_unsubscribe(Req, #{}, #{}). - --spec on_client_unsubscribe(exhook_pb:client_unsubscribe_request(), grpc:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_unsubscribe(Req, Options) -> - on_client_unsubscribe(Req, #{}, Options). - --spec on_client_unsubscribe(exhook_pb:client_unsubscribe_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_client_unsubscribe(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnClientUnsubscribe">>, - client_unsubscribe_request, empty_success, <<"dgiot.exhook.v1.ClientUnsubscribeRequest">>), - Req, Metadata, Options). - --spec on_session_created(exhook_pb:session_created_request()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_created(Req) -> - on_session_created(Req, #{}, #{}). - --spec on_session_created(exhook_pb:session_created_request(), grpc:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_created(Req, Options) -> - on_session_created(Req, #{}, Options). - --spec on_session_created(exhook_pb:session_created_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_created(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnSessionCreated">>, - session_created_request, empty_success, <<"dgiot.exhook.v1.SessionCreatedRequest">>), - Req, Metadata, Options). - --spec on_session_subscribed(exhook_pb:session_subscribed_request()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_subscribed(Req) -> - on_session_subscribed(Req, #{}, #{}). - --spec on_session_subscribed(exhook_pb:session_subscribed_request(), grpc:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_subscribed(Req, Options) -> - on_session_subscribed(Req, #{}, Options). - --spec on_session_subscribed(exhook_pb:session_subscribed_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_subscribed(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnSessionSubscribed">>, - session_subscribed_request, empty_success, <<"dgiot.exhook.v1.SessionSubscribedRequest">>), - Req, Metadata, Options). - --spec on_session_unsubscribed(exhook_pb:session_unsubscribed_request()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_unsubscribed(Req) -> - on_session_unsubscribed(Req, #{}, #{}). - --spec on_session_unsubscribed(exhook_pb:session_unsubscribed_request(), grpc:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_unsubscribed(Req, Options) -> - on_session_unsubscribed(Req, #{}, Options). - --spec on_session_unsubscribed(exhook_pb:session_unsubscribed_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_unsubscribed(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnSessionUnsubscribed">>, - session_unsubscribed_request, empty_success, <<"dgiot.exhook.v1.SessionUnsubscribedRequest">>), - Req, Metadata, Options). - --spec on_session_resumed(exhook_pb:session_resumed_request()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_resumed(Req) -> - on_session_resumed(Req, #{}, #{}). - --spec on_session_resumed(exhook_pb:session_resumed_request(), grpc:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_resumed(Req, Options) -> - on_session_resumed(Req, #{}, Options). - --spec on_session_resumed(exhook_pb:session_resumed_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_resumed(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnSessionResumed">>, - session_resumed_request, empty_success, <<"dgiot.exhook.v1.SessionResumedRequest">>), - Req, Metadata, Options). - --spec on_session_discarded(exhook_pb:session_discarded_request()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_discarded(Req) -> - on_session_discarded(Req, #{}, #{}). - --spec on_session_discarded(exhook_pb:session_discarded_request(), grpc:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_discarded(Req, Options) -> - on_session_discarded(Req, #{}, Options). - --spec on_session_discarded(exhook_pb:session_discarded_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_discarded(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnSessionDiscarded">>, - session_discarded_request, empty_success, <<"dgiot.exhook.v1.SessionDiscardedRequest">>), - Req, Metadata, Options). - --spec on_session_takeovered(exhook_pb:session_takeovered_request()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_takeovered(Req) -> - on_session_takeovered(Req, #{}, #{}). - --spec on_session_takeovered(exhook_pb:session_takeovered_request(), grpc:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_takeovered(Req, Options) -> - on_session_takeovered(Req, #{}, Options). - --spec on_session_takeovered(exhook_pb:session_takeovered_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_takeovered(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnSessionTakeovered">>, - session_takeovered_request, empty_success, <<"dgiot.exhook.v1.SessionTakeoveredRequest">>), - Req, Metadata, Options). - --spec on_session_terminated(exhook_pb:session_terminated_request()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_terminated(Req) -> - on_session_terminated(Req, #{}, #{}). - --spec on_session_terminated(exhook_pb:session_terminated_request(), grpc:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_terminated(Req, Options) -> - on_session_terminated(Req, #{}, Options). - --spec on_session_terminated(exhook_pb:session_terminated_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_session_terminated(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnSessionTerminated">>, - session_terminated_request, empty_success, <<"dgiot.exhook.v1.SessionTerminatedRequest">>), - Req, Metadata, Options). - --spec on_message_publish(exhook_pb:message_publish_request()) - -> {ok, exhook_pb:valued_response(), grpc:metadata()} - | {error, term()}. -on_message_publish(Req) -> - on_message_publish(Req, #{}, #{}). - --spec on_message_publish(exhook_pb:message_publish_request(), grpc:options()) - -> {ok, exhook_pb:valued_response(), grpc:metadata()} - | {error, term()}. -on_message_publish(Req, Options) -> - on_message_publish(Req, #{}, Options). - --spec on_message_publish(exhook_pb:message_publish_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:valued_response(), grpc:metadata()} - | {error, term()}. -on_message_publish(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnMessagePublish">>, - message_publish_request, valued_response, <<"dgiot.exhook.v1.MessagePublishRequest">>), - Req, Metadata, Options). - --spec on_message_delivered(exhook_pb:message_delivered_request()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_message_delivered(Req) -> - on_message_delivered(Req, #{}, #{}). - --spec on_message_delivered(exhook_pb:message_delivered_request(), grpc:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_message_delivered(Req, Options) -> - on_message_delivered(Req, #{}, Options). - --spec on_message_delivered(exhook_pb:message_delivered_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_message_delivered(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnMessageDelivered">>, - message_delivered_request, empty_success, <<"dgiot.exhook.v1.MessageDeliveredRequest">>), - Req, Metadata, Options). - --spec on_message_dropped(exhook_pb:message_dropped_request()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_message_dropped(Req) -> - on_message_dropped(Req, #{}, #{}). - --spec on_message_dropped(exhook_pb:message_dropped_request(), grpc:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_message_dropped(Req, Options) -> - on_message_dropped(Req, #{}, Options). - --spec on_message_dropped(exhook_pb:message_dropped_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_message_dropped(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnMessageDropped">>, - message_dropped_request, empty_success, <<"dgiot.exhook.v1.MessageDroppedRequest">>), - Req, Metadata, Options). - --spec on_message_acked(exhook_pb:message_acked_request()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_message_acked(Req) -> - on_message_acked(Req, #{}, #{}). - --spec on_message_acked(exhook_pb:message_acked_request(), grpc:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_message_acked(Req, Options) -> - on_message_acked(Req, #{}, Options). - --spec on_message_acked(exhook_pb:message_acked_request(), grpc:metadata(), grpc_client:options()) - -> {ok, exhook_pb:empty_success(), grpc:metadata()} - | {error, term()}. -on_message_acked(Req, Metadata, Options) -> - grpc_client:unary(?DEF(<<"/dgiot.exhook.v1.HookProvider/OnMessageAcked">>, - message_acked_request, empty_success, <<"dgiot.exhook.v1.MessageAckedRequest">>), - Req, Metadata, Options). - diff --git a/apps/dgiot_grpc/src/dgiot_grpc.erl b/apps/dgiot_grpc/src/dgiot_grpc.erl deleted file mode 100644 index 095b3ddc..00000000 --- a/apps/dgiot_grpc/src/dgiot_grpc.erl +++ /dev/null @@ -1,45 +0,0 @@ -%%-------------------------------------------------------------------- -%% Copyright (c) 2020 DGIOT Technologies Co., Ltd. All Rights Reserved. -%% -%% Licensed under the Apache License, Version 2.0 (the "License"); -%% you may not use this file except in compliance with the License. -%% You may obtain a copy of the License at -%% -%% http://www.apache.org/licenses/LICENSE-2.0 -%% -%% Unless required by applicable law or agreed to in writing, software -%% distributed under the License is distributed on an "AS IS" BASIS, -%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -%% See the License for the specific language governing permissions and -%% limitations under the License. -%%-------------------------------------------------------------------- - -%% @doc dgiot_grpc Protocol --module(dgiot_grpc). --include("dgiot_grpc.hrl"). --include_lib("dgiot/include/logger.hrl"). - --export([ start_grpc_client_channel/3 - , stop_grpc_client_channel/1 -]). - -%%-------------------------------------------------------------------- -%% APIs - --spec start_grpc_client_channel( - string(), - uri_string:uri_string(), - grpc_client:options()) -> {ok, pid()} | {error, term()}. -start_grpc_client_channel(Name, SvrAddr, Options) -> - grpc_client_sup:create_channel_pool(Name, SvrAddr, Options). - --spec stop_grpc_client_channel(string()) -> ok. -stop_grpc_client_channel(Name) -> - %% Avoid crash due to hot-upgrade had unloaded - %% grpc application - try - grpc_client_sup:stop_channel_pool(Name) - catch - _:_:_ -> - ok - end. diff --git a/apps/dgiot_grpc/src/dgiot_grpc_channel.erl b/apps/dgiot_grpc/src/dgiot_grpc_channel.erl index c8127bbd..3012ad68 100644 --- a/apps/dgiot_grpc/src/dgiot_grpc_channel.erl +++ b/apps/dgiot_grpc/src/dgiot_grpc_channel.erl @@ -21,7 +21,7 @@ -include_lib("dgiot/include/dgiot_socket.hrl"). -include_lib("dgiot/include/logger.hrl"). -include("dgiot_grpc.hrl"). --define(TYPE, <<"GRPC">>). +-define(TYPE, <<"GRPC_ClIENT">>). %% API -export([start/2]). @@ -42,16 +42,53 @@ }). %% 注册通道参数 -params(#{ - <<"port">> => #{ + <<"scheme">> => #{ order => 1, - type => integer, + type => string, required => true, - default => 61888, + default => <<"http">>, title => #{ - zh => <<"端口"/utf8>> + zh => <<"通讯协议"/utf8>> }, description => #{ - zh => <<"侦听端口"/utf8>> + zh => <<"通讯协议"/utf8>> + } + }, + <<"host">> => #{ + order => 2, + type => string, + required => true, + default => <<"127.0.0.1">>, + title => #{ + zh => <<"IP"/utf8>> + }, + description => #{ + zh => <<"grpc服务器IP"/utf8>> + } + }, + <<"port">> => #{ + order => 3, + type => integer, + required => true, + default => 7000, + title => #{ + zh => <<"port"/utf8>> + }, + description => #{ + zh => <<"grpc服务器端口"/utf8>> + } + }, + <<"model">> => #{ + order => 2, + type => enum, + required => false, + default => <<"both"/utf8>>, + enum => [<<"both">>, <<"client">>, <<"server">>], + title => #{ + zh => <<"启动模式"/utf8>> + }, + description => #{ + zh => <<"启动模式:both|client|server"/utf8>> } }, <<"ico">> => #{ @@ -75,31 +112,30 @@ start(ChannelId, ChannelArgs) -> dgiot_channelx:add(?TYPE, ChannelId, ?MODULE, ChannelArgs). %% 通道初始化 -init(?TYPE, ChannelId, #{ - <<"port">> := _Port, - <<"product">> := _Products}) -> +init(?TYPE, ChannelId, Env) -> State = #state{ - id = ChannelId + id = ChannelId, + env = Env }, -%% %% grpc server -%% Services = #{protos => [dgiot_exhook_pb], -%% services => #{ -%% 'dgiot.exhook.v1.HookProvider' => exhook_svr -%% } -%% }, -%% Options = [], -%% {ok, Spec} = grpc:start_server(exhook_svr, 9000, Services, Options), -%% io:format("Start service exhook_svr on 9000 successfully!~n", []), -%% %% magic line -%% _ = exhook_svr:module_info(), -%% %% counter -%% ets:new(exhook_stats, [public, named_table, {write_concurrency, true}]), - {ok, State, []}; - -init(?TYPE, _ChannelId, _Args) -> - {ok, #{}, #{}}. + Port = maps:get(<<"port">>, Env), + Scheme = maps:get(<<"scheme">>, Env), + Host = dgiot_utils:to_list(maps:get(<<"host">>, Env)), + Opts0 = [{scheme, dgiot_utils:to_atom(Scheme)}, {host, Host}, {port, Port}], + case maps:get(<<"model">>, Env) of + <<"both">> -> + dgiot_grpc_server:start(ChannelId, Port, []), + application:ensure_all_started(emqx_hooks), + emqx_exhook:enable(ChannelId, Opts0); + <<"client">> -> + application:ensure_all_started(emqx_hooks), + emqx_exhook:enable(ChannelId, Opts0); + <<"server">> -> + dgiot_grpc_server:start(ChannelId, Port, []) + end, + {ok, State, []}. handle_init(State) -> + erlang:send_after(5000, self(), start), {ok, State}. %% 通道消息处理,注意:进程池调用 @@ -120,6 +156,9 @@ handle_event(EventId, Event, State) -> ?LOG(error, "EventId ~p Event ~p", [EventId, Event]), {ok, State}. +handle_message(start, State) -> + {ok, State}; + % SELECT clientid, payload, topic FROM "meter" % SELECT clientid, disconnected_at FROM "$events/client_disconnected" WHERE username = 'dgiot' % SELECT clientid, connected_at FROM "$events/client_connected" WHERE username = 'dgiot' @@ -134,5 +173,6 @@ handle_message({rule, #{clientid := DevAddr, payload := Payload, topic := _Topic handle_message(_Message, State) -> {ok, State}. -stop(_ChannelType, _ChannelId, _State) -> +stop(_ChannelType, ChannelId, _State) -> + emqx_exhook:disable(ChannelId), ok. diff --git a/apps/dgiot_grpc/src/dgiot_grpc_client.erl b/apps/dgiot_grpc/src/dgiot_grpc_client.erl new file mode 100644 index 00000000..3d35b42f --- /dev/null +++ b/apps/dgiot_grpc/src/dgiot_grpc_client.erl @@ -0,0 +1,111 @@ +%%-------------------------------------------------------------------- +%% Copyright (c) 2020 DGIOT Technologies Co., Ltd. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%%-------------------------------------------------------------------- + +%% @doc dgiot_grpc Protocol +-module(dgiot_grpc_client). +-include("dgiot_grpc.hrl"). +-include_lib("dgiot/include/logger.hrl"). +-define(PB_CLIENT_MOD, emqx_exhook_v_1_hook_provider_client). + +-export([ start_client_sup/2 +]). + +%% APIs +-export([ + do_call/3 + , do_init/1 + , do_deinit/1]). + +%%-------------------------------------------------------------------- +%% APIs + +%% for creating a Child spec to hang on another Application supervisor. +start_client_sup(ChannleId, Opts0) -> +%% Opts0 = [{scheme,http},{host,"127.0.0.1"},{port,9000}] + Name = dgiot_utils:to_list(ChannleId), + {URL, ClientOpts} = channel_opts(Opts0), + _ = application:ensure_all_started(gproc), + case uri_string:parse(URL) of + #{scheme := Scheme, host := Host, port := Port} -> + Server = {Scheme, Host, Port}, + #{id => Name, + start => {grpc_client_sup, start_link, [Name, Server, ClientOpts]}, + restart => transient, + shutdown => infinity, + type => supervisor, + modules => [grpc_client_sup]}; + {error, _Reason, _} -> [] + end. + +%% @private +channel_opts( #{ + <<"scheme">> := Scheme, + <<"port">> := Port, + <<"host">> := Host}) -> + NewScheme = dgiot_utils:to_atom(Scheme), + SvrAddr = format_http_uri(NewScheme, Host, Port), + ClientOpts = case NewScheme of + https -> +%% SslOpts = lists:keydelete(ssl, 1, proplists:get_value(ssl_options, Opts, [])), +%% #{gun_opts => +%% #{transport => ssl, +%% transport_opts => SslOpts}}; + #{}; + _ -> #{} + end, + {SvrAddr, ClientOpts}. + +format_http_uri(Scheme, Host0, Port) -> + Host = case is_tuple(Host0) of + true -> inet:ntoa(Host0); + _ -> dgiot_utils:to_list(Host0) + end, + lists:flatten(io_lib:format("~s://~s:~w", [Scheme, Host, Port])). + +do_deinit(Name) -> + _ = do_call(Name, 'on_provider_unloaded', #{}), + ok. + +do_init(ChannName) -> + Req = #{broker => maps:from_list(emqx_sys:info())}, + case do_call(ChannName, 'on_provider_loaded', Req) of + {ok, _InitialResp} -> + ok; + {error, Reason} -> + {error, Reason} + end. + +-spec do_call(string(), atom(), map()) -> {ok, map()} | {error, term()}. +do_call(ChannName, Fun, Req) -> + Options = #{channel => ChannName}, + ?LOG(debug, "Call ~0p:~0p(~0p, ~0p)", [?PB_CLIENT_MOD, Fun, Req, Options]), + case catch apply(?PB_CLIENT_MOD, Fun, [Req, Options]) of + {ok, Resp, _Metadata} -> + ?LOG(debug, "Response {ok, ~0p, ~0p}", [Resp, _Metadata]), + {ok, Resp}; + {error, {Code, Msg}, _Metadata} -> + ?LOG(error, "CALL ~0p:~0p(~0p, ~0p) response errcode: ~0p, errmsg: ~0p", + [?PB_CLIENT_MOD, Fun, Req, Options, Code, Msg]), + {error, {Code, Msg}}; + {error, Reason} -> + ?LOG(error, "CALL ~0p:~0p(~0p, ~0p) error: ~0p", + [?PB_CLIENT_MOD, Fun, Req, Options, Reason]), + {error, Reason}; + {'EXIT', {Reason, Stk}} -> + ?LOG(error, "CALL ~0p:~0p(~0p, ~0p) throw an exception: ~0p, stacktrace: ~0p", + [?PB_CLIENT_MOD, Fun, Req, Options, Reason, Stk]), + {error, Reason} + end. diff --git a/apps/dgiot_grpc/src/exhook_svr.erl b/apps/dgiot_grpc/src/dgiot_grpc_server.erl similarity index 57% rename from apps/dgiot_grpc/src/exhook_svr.erl rename to apps/dgiot_grpc/src/dgiot_grpc_server.erl index 1394115d..cafee8ef 100644 --- a/apps/dgiot_grpc/src/exhook_svr.erl +++ b/apps/dgiot_grpc/src/dgiot_grpc_server.erl @@ -14,201 +14,209 @@ %% limitations under the License. %%-------------------------------------------------------------------- --module(exhook_svr). +-module(dgiot_grpc_server). --behavior(dgiot_exhook_v_1_hook_provider_bhvr). +-behavior(emqx_exhook_v_1_hook_provider_bhvr). +-export([start/3]). %% gRPC server HookProvider callbacks --export([ on_provider_loaded/2 - , on_provider_unloaded/2 - , on_client_connect/2 - , on_client_connack/2 - , on_client_connected/2 - , on_client_disconnected/2 - , on_client_authenticate/2 - , on_client_check_acl/2 - , on_client_subscribe/2 - , on_client_unsubscribe/2 - , on_session_created/2 - , on_session_subscribed/2 - , on_session_unsubscribed/2 - , on_session_resumed/2 - , on_session_discarded/2 - , on_session_takeovered/2 - , on_session_terminated/2 - , on_message_publish/2 - , on_message_delivered/2 - , on_message_dropped/2 - , on_message_acked/2 - ]). +-export([on_provider_loaded/2 + , on_provider_unloaded/2 + , on_client_connect/2 + , on_client_connack/2 + , on_client_connected/2 + , on_client_disconnected/2 + , on_client_authenticate/2 + , on_client_check_acl/2 + , on_client_subscribe/2 + , on_client_unsubscribe/2 + , on_session_created/2 + , on_session_subscribed/2 + , on_session_unsubscribed/2 + , on_session_resumed/2 + , on_session_discarded/2 + , on_session_takeovered/2 + , on_session_terminated/2 + , on_message_publish/2 + , on_message_delivered/2 + , on_message_dropped/2 + , on_message_acked/2 +]). --define(PORT, 9000). --define(NAME, ?MODULE). +start(Name, Port, Options) -> +%% grpc server + Services = #{protos => [emqx_exhook_pb], + services => #{ + 'emqx.exhook.v1.HookProvider' => dgiot_grpc_server + } + }, +%% Options = [], + {ok, _Pid} = grpc:start_server(dgiot_utils:to_atom(Name), Port, Services, Options). -spec on_provider_loaded(dgiot_exhook_pb:provider_loaded_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:loaded_response(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:loaded_response(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_provider_loaded(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{hooks => [ - #{name => <<"client.connect">>}, - #{name => <<"client.connack">>}, - #{name => <<"client.connected">>}, - #{name => <<"client.disconnected">>}, - #{name => <<"client.authenticate">>}, - #{name => <<"client.check_acl">>}, - #{name => <<"client.subscribe">>}, - #{name => <<"client.unsubscribe">>}, - #{name => <<"session.created">>}, - #{name => <<"session.subscribed">>}, - #{name => <<"session.unsubscribed">>}, - #{name => <<"session.resumed">>}, - #{name => <<"session.discarded">>}, - #{name => <<"session.takeovered">>}, - #{name => <<"session.terminated">>}, - #{name => <<"message.publish">>}, - #{name => <<"message.delivered">>}, - #{name => <<"message.acked">>} - %#{name => <<"message.dropped">>} - ]}, Md}. + #{name => <<"client.connect">>}, + #{name => <<"client.connack">>}, + #{name => <<"client.connected">>}, + #{name => <<"client.disconnected">>}, + #{name => <<"client.authenticate">>}, + #{name => <<"client.check_acl">>}, + #{name => <<"client.subscribe">>}, + #{name => <<"client.unsubscribe">>}, + #{name => <<"session.created">>}, + #{name => <<"session.subscribed">>}, + #{name => <<"session.unsubscribed">>}, + #{name => <<"session.resumed">>}, + #{name => <<"session.discarded">>}, + #{name => <<"session.takeovered">>}, + #{name => <<"session.terminated">>}, + #{name => <<"message.publish">>}, + #{name => <<"message.delivered">>}, + #{name => <<"message.acked">>} + %#{name => <<"message.dropped">>} + ]}, Md}. -spec on_provider_unloaded(dgiot_exhook_pb:provider_unloaded_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_provider_unloaded(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{}, Md}. -spec on_client_connect(dgiot_exhook_pb:client_connect_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_client_connect(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{}, Md}. -spec on_client_connack(dgiot_exhook_pb:client_connack_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_client_connack(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{}, Md}. -spec on_client_connected(dgiot_exhook_pb:client_connected_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_client_connected(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{}, Md}. -spec on_client_disconnected(dgiot_exhook_pb:client_disconnected_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_client_disconnected(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{}, Md}. -spec on_client_authenticate(dgiot_exhook_pb:client_authenticate_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:valued_response(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:valued_response(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_client_authenticate(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{type => 'STOP_AND_RETURN', value => {bool_result, true}}, Md}. -spec on_client_check_acl(dgiot_exhook_pb:client_check_acl_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:valued_response(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:valued_response(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_client_check_acl(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{type => 'STOP_AND_RETURN', value => {bool_result, true}}, Md}. -spec on_client_subscribe(dgiot_exhook_pb:client_subscribe_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_client_subscribe(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{}, Md}. -spec on_client_unsubscribe(dgiot_exhook_pb:client_unsubscribe_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_client_unsubscribe(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{}, Md}. -spec on_session_created(dgiot_exhook_pb:session_created_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_session_created(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{}, Md}. -spec on_session_subscribed(dgiot_exhook_pb:session_subscribed_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_session_subscribed(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{}, Md}. -spec on_session_unsubscribed(dgiot_exhook_pb:session_unsubscribed_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_session_unsubscribed(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{}, Md}. -spec on_session_resumed(dgiot_exhook_pb:session_resumed_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_session_resumed(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{}, Md}. -spec on_session_discarded(dgiot_exhook_pb:session_discarded_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_session_discarded(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{}, Md}. -spec on_session_takeovered(dgiot_exhook_pb:session_takeovered_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_session_takeovered(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{}, Md}. -spec on_session_terminated(dgiot_exhook_pb:session_terminated_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_session_terminated(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{}, Md}. -spec on_message_publish(dgiot_exhook_pb:message_publish_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:valued_response(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:valued_response(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_message_publish(_Req = #{message := Msg}, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), NMsg = Msg#{payload => <<"hardcode payload by exhook-svr-erlang :)">>}, {ok, #{type => 'STOP_AND_RETURN', value => {message, NMsg}}, Md}. -spec on_message_delivered(dgiot_exhook_pb:message_delivered_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_message_delivered(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{}, Md}. -spec on_message_dropped(dgiot_exhook_pb:message_dropped_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_message_dropped(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{}, Md}. -spec on_message_acked(dgiot_exhook_pb:message_acked_request(), grpc:metadata()) - -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} - | {error, grpc_cowboy_h:error_response()}. + -> {ok, dgiot_exhook_pb:empty_success(), grpc:metadata()} + | {error, grpc_cowboy_h:error_response()}. on_message_acked(_Req, Md) -> ets:update_counter(exhook_stats, ?FUNCTION_NAME, {2, 1}, {?FUNCTION_NAME, 0}), {ok, #{}, Md}. diff --git a/apps/dgiot_grpc/src/exhook_pb.erl b/apps/dgiot_grpc/src/exhook_pb.erl deleted file mode 100644 index d1f180cd..00000000 --- a/apps/dgiot_grpc/src/exhook_pb.erl +++ /dev/null @@ -1,15765 +0,0 @@ -%% -*- coding: utf-8 -*- -%% @private -%% Automatically generated, do not edit -%% Generated by gpb_compile version 4.11.2 --module(exhook_pb). - --export([encode_msg/2, encode_msg/3]). --export([decode_msg/2, decode_msg/3]). --export([merge_msgs/3, merge_msgs/4]). --export([verify_msg/2, verify_msg/3]). --export([get_msg_defs/0]). --export([get_msg_names/0]). --export([get_group_names/0]). --export([get_msg_or_group_names/0]). --export([get_enum_names/0]). --export([find_msg_def/1, fetch_msg_def/1]). --export([find_enum_def/1, fetch_enum_def/1]). --export([enum_symbol_by_value/2, enum_value_by_symbol/2]). --export(['enum_symbol_by_value_client_check_acl_request.AclReqType'/1, 'enum_value_by_symbol_client_check_acl_request.AclReqType'/1]). --export(['enum_symbol_by_value_valued_response.ResponsedType'/1, 'enum_value_by_symbol_valued_response.ResponsedType'/1]). --export([get_service_names/0]). --export([get_service_def/1]). --export([get_rpc_names/1]). --export([find_rpc_def/2, fetch_rpc_def/2]). --export([fqbin_to_service_name/1]). --export([service_name_to_fqbin/1]). --export([fqbins_to_service_and_rpc_name/2]). --export([service_and_rpc_name_to_fqbins/2]). --export([fqbin_to_msg_name/1]). --export([msg_name_to_fqbin/1]). --export([fqbin_to_enum_name/1]). --export([enum_name_to_fqbin/1]). --export([get_package_name/0]). --export([uses_packages/0]). --export([source_basename/0]). --export([get_all_source_basenames/0]). --export([get_all_proto_names/0]). --export([get_msg_containment/1]). --export([get_pkg_containment/1]). --export([get_service_containment/1]). --export([get_rpc_containment/1]). --export([get_enum_containment/1]). --export([get_proto_by_msg_name_as_fqbin/1]). --export([get_proto_by_service_name_as_fqbin/1]). --export([get_proto_by_enum_name_as_fqbin/1]). --export([get_protos_by_pkg_name_as_fqbin/1]). --export([gpb_version_as_string/0, gpb_version_as_list/0]). - - -%% enumerated types --type 'client_check_acl_request.AclReqType'() :: 'PUBLISH' | 'SUBSCRIBE'. --type 'valued_response.ResponsedType'() :: 'CONTINUE' | 'IGNORE' | 'STOP_AND_RETURN'. --export_type(['client_check_acl_request.AclReqType'/0, 'valued_response.ResponsedType'/0]). - -%% message types --type provider_loaded_request() :: - #{broker => broker_info() % = 1 - }. - --type loaded_response() :: - #{hooks => [hook_spec()] % = 1 - }. - --type provider_unloaded_request() :: - #{ - }. - --type client_connect_request() :: - #{conninfo => conn_info(), % = 1 - props => [property()] % = 2 - }. - --type client_connack_request() :: - #{conninfo => conn_info(), % = 1 - result_code => iodata(), % = 2 - props => [property()] % = 3 - }. - --type client_connected_request() :: - #{clientinfo => client_info() % = 1 - }. - --type client_disconnected_request() :: - #{clientinfo => client_info(), % = 1 - reason => iodata() % = 2 - }. - --type client_authenticate_request() :: - #{clientinfo => client_info(), % = 1 - result => boolean() | 0 | 1 % = 2 - }. - --type client_check_acl_request() :: - #{clientinfo => client_info(), % = 1 - type => 'PUBLISH' | 'SUBSCRIBE' | integer(), % = 2, enum client_check_acl_request.AclReqType - topic => iodata(), % = 3 - result => boolean() | 0 | 1 % = 4 - }. - --type client_subscribe_request() :: - #{clientinfo => client_info(), % = 1 - props => [property()], % = 2 - topic_filters => [topic_filter()] % = 3 - }. - --type client_unsubscribe_request() :: - #{clientinfo => client_info(), % = 1 - props => [property()], % = 2 - topic_filters => [topic_filter()] % = 3 - }. - --type session_created_request() :: - #{clientinfo => client_info() % = 1 - }. - --type session_subscribed_request() :: - #{clientinfo => client_info(), % = 1 - topic => iodata(), % = 2 - subopts => sub_opts() % = 3 - }. - --type session_unsubscribed_request() :: - #{clientinfo => client_info(), % = 1 - topic => iodata() % = 2 - }. - --type session_resumed_request() :: - #{clientinfo => client_info() % = 1 - }. - --type session_discarded_request() :: - #{clientinfo => client_info() % = 1 - }. - --type session_takeovered_request() :: - #{clientinfo => client_info() % = 1 - }. - --type session_terminated_request() :: - #{clientinfo => client_info(), % = 1 - reason => iodata() % = 2 - }. - --type message_publish_request() :: - #{message => message() % = 1 - }. - --type message_delivered_request() :: - #{clientinfo => client_info(), % = 1 - message => message() % = 2 - }. - --type message_dropped_request() :: - #{message => message(), % = 1 - reason => iodata() % = 2 - }. - --type message_acked_request() :: - #{clientinfo => client_info(), % = 1 - message => message() % = 2 - }. - --type empty_success() :: - #{ - }. - --type valued_response() :: - #{type => 'CONTINUE' | 'IGNORE' | 'STOP_AND_RETURN' | integer(), % = 1, enum valued_response.ResponsedType - value => {bool_result, boolean() | 0 | 1} | {message, message()} % oneof - }. - --type broker_info() :: - #{version => iodata(), % = 1 - sysdescr => iodata(), % = 2 - uptime => iodata(), % = 3 - datetime => iodata() % = 4 - }. - --type hook_spec() :: - #{name => iodata(), % = 1 - topics => [iodata()] % = 2 - }. - --type conn_info() :: - #{node => iodata(), % = 1 - clientid => iodata(), % = 2 - username => iodata(), % = 3 - peerhost => iodata(), % = 4 - sockport => non_neg_integer(), % = 5, 32 bits - proto_name => iodata(), % = 6 - proto_ver => iodata(), % = 7 - keepalive => non_neg_integer() % = 8, 32 bits - }. - --type client_info() :: - #{node => iodata(), % = 1 - clientid => iodata(), % = 2 - username => iodata(), % = 3 - password => iodata(), % = 4 - peerhost => iodata(), % = 5 - sockport => non_neg_integer(), % = 6, 32 bits - protocol => iodata(), % = 7 - mountpoint => iodata(), % = 8 - is_superuser => boolean() | 0 | 1, % = 9 - anonymous => boolean() | 0 | 1, % = 10 - cn => iodata(), % = 11 - dn => iodata() % = 12 - }. - --type message() :: - #{node => iodata(), % = 1 - id => iodata(), % = 2 - qos => non_neg_integer(), % = 3, 32 bits - from => iodata(), % = 4 - topic => iodata(), % = 5 - payload => iodata(), % = 6 - timestamp => non_neg_integer() % = 7, 64 bits - }. - --type property() :: - #{name => iodata(), % = 1 - value => iodata() % = 2 - }. - --type topic_filter() :: - #{name => iodata(), % = 1 - qos => non_neg_integer() % = 2, 32 bits - }. - --type sub_opts() :: - #{qos => non_neg_integer(), % = 1, 32 bits - share => iodata(), % = 2 - rh => non_neg_integer(), % = 3, 32 bits - rap => non_neg_integer(), % = 4, 32 bits - nl => non_neg_integer() % = 5, 32 bits - }. - --export_type(['provider_loaded_request'/0, 'loaded_response'/0, 'provider_unloaded_request'/0, 'client_connect_request'/0, 'client_connack_request'/0, 'client_connected_request'/0, 'client_disconnected_request'/0, 'client_authenticate_request'/0, 'client_check_acl_request'/0, 'client_subscribe_request'/0, 'client_unsubscribe_request'/0, 'session_created_request'/0, 'session_subscribed_request'/0, 'session_unsubscribed_request'/0, 'session_resumed_request'/0, 'session_discarded_request'/0, 'session_takeovered_request'/0, 'session_terminated_request'/0, 'message_publish_request'/0, 'message_delivered_request'/0, 'message_dropped_request'/0, 'message_acked_request'/0, 'empty_success'/0, 'valued_response'/0, 'broker_info'/0, 'hook_spec'/0, 'conn_info'/0, 'client_info'/0, 'message'/0, 'property'/0, 'topic_filter'/0, 'sub_opts'/0]). - --spec encode_msg(provider_loaded_request() | loaded_response() | provider_unloaded_request() | client_connect_request() | client_connack_request() | client_connected_request() | client_disconnected_request() | client_authenticate_request() | client_check_acl_request() | client_subscribe_request() | client_unsubscribe_request() | session_created_request() | session_subscribed_request() | session_unsubscribed_request() | session_resumed_request() | session_discarded_request() | session_takeovered_request() | session_terminated_request() | message_publish_request() | message_delivered_request() | message_dropped_request() | message_acked_request() | empty_success() | valued_response() | broker_info() | hook_spec() | conn_info() | client_info() | message() | property() | topic_filter() | sub_opts(), atom()) -> binary(). -encode_msg(Msg, MsgName) when is_atom(MsgName) -> - encode_msg(Msg, MsgName, []). - --spec encode_msg(provider_loaded_request() | loaded_response() | provider_unloaded_request() | client_connect_request() | client_connack_request() | client_connected_request() | client_disconnected_request() | client_authenticate_request() | client_check_acl_request() | client_subscribe_request() | client_unsubscribe_request() | session_created_request() | session_subscribed_request() | session_unsubscribed_request() | session_resumed_request() | session_discarded_request() | session_takeovered_request() | session_terminated_request() | message_publish_request() | message_delivered_request() | message_dropped_request() | message_acked_request() | empty_success() | valued_response() | broker_info() | hook_spec() | conn_info() | client_info() | message() | property() | topic_filter() | sub_opts(), atom(), list()) -> binary(). -encode_msg(Msg, MsgName, Opts) -> - case proplists:get_bool(verify, Opts) of - true -> verify_msg(Msg, MsgName, Opts); - false -> ok - end, - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - provider_loaded_request -> - encode_msg_provider_loaded_request(id(Msg, TrUserData), - TrUserData); - loaded_response -> - encode_msg_loaded_response(id(Msg, TrUserData), - TrUserData); - provider_unloaded_request -> - encode_msg_provider_unloaded_request(id(Msg, - TrUserData), - TrUserData); - client_connect_request -> - encode_msg_client_connect_request(id(Msg, TrUserData), - TrUserData); - client_connack_request -> - encode_msg_client_connack_request(id(Msg, TrUserData), - TrUserData); - client_connected_request -> - encode_msg_client_connected_request(id(Msg, TrUserData), - TrUserData); - client_disconnected_request -> - encode_msg_client_disconnected_request(id(Msg, - TrUserData), - TrUserData); - client_authenticate_request -> - encode_msg_client_authenticate_request(id(Msg, - TrUserData), - TrUserData); - client_check_acl_request -> - encode_msg_client_check_acl_request(id(Msg, TrUserData), - TrUserData); - client_subscribe_request -> - encode_msg_client_subscribe_request(id(Msg, TrUserData), - TrUserData); - client_unsubscribe_request -> - encode_msg_client_unsubscribe_request(id(Msg, - TrUserData), - TrUserData); - session_created_request -> - encode_msg_session_created_request(id(Msg, TrUserData), - TrUserData); - session_subscribed_request -> - encode_msg_session_subscribed_request(id(Msg, - TrUserData), - TrUserData); - session_unsubscribed_request -> - encode_msg_session_unsubscribed_request(id(Msg, - TrUserData), - TrUserData); - session_resumed_request -> - encode_msg_session_resumed_request(id(Msg, TrUserData), - TrUserData); - session_discarded_request -> - encode_msg_session_discarded_request(id(Msg, - TrUserData), - TrUserData); - session_takeovered_request -> - encode_msg_session_takeovered_request(id(Msg, - TrUserData), - TrUserData); - session_terminated_request -> - encode_msg_session_terminated_request(id(Msg, - TrUserData), - TrUserData); - message_publish_request -> - encode_msg_message_publish_request(id(Msg, TrUserData), - TrUserData); - message_delivered_request -> - encode_msg_message_delivered_request(id(Msg, - TrUserData), - TrUserData); - message_dropped_request -> - encode_msg_message_dropped_request(id(Msg, TrUserData), - TrUserData); - message_acked_request -> - encode_msg_message_acked_request(id(Msg, TrUserData), - TrUserData); - empty_success -> - encode_msg_empty_success(id(Msg, TrUserData), - TrUserData); - valued_response -> - encode_msg_valued_response(id(Msg, TrUserData), - TrUserData); - broker_info -> - encode_msg_broker_info(id(Msg, TrUserData), TrUserData); - hook_spec -> - encode_msg_hook_spec(id(Msg, TrUserData), TrUserData); - conn_info -> - encode_msg_conn_info(id(Msg, TrUserData), TrUserData); - client_info -> - encode_msg_client_info(id(Msg, TrUserData), TrUserData); - message -> - encode_msg_message(id(Msg, TrUserData), TrUserData); - property -> - encode_msg_property(id(Msg, TrUserData), TrUserData); - topic_filter -> - encode_msg_topic_filter(id(Msg, TrUserData), - TrUserData); - sub_opts -> - encode_msg_sub_opts(id(Msg, TrUserData), TrUserData) - end. - - -encode_msg_provider_loaded_request(Msg, TrUserData) -> - encode_msg_provider_loaded_request(Msg, - <<>>, - TrUserData). - - -encode_msg_provider_loaded_request(#{} = M, Bin, - TrUserData) -> - case M of - #{broker := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_provider_loaded_request_broker(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_loaded_response(Msg, TrUserData) -> - encode_msg_loaded_response(Msg, <<>>, TrUserData). - - -encode_msg_loaded_response(#{} = M, Bin, TrUserData) -> - case M of - #{hooks := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> - e_field_loaded_response_hooks(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_provider_unloaded_request(_Msg, - _TrUserData) -> - <<>>. - -encode_msg_client_connect_request(Msg, TrUserData) -> - encode_msg_client_connect_request(Msg, - <<>>, - TrUserData). - - -encode_msg_client_connect_request(#{} = M, Bin, - TrUserData) -> - B1 = case M of - #{conninfo := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_client_connect_request_conninfo(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end, - case M of - #{props := F2} -> - TrF2 = id(F2, TrUserData), - if TrF2 == [] -> B1; - true -> - e_field_client_connect_request_props(TrF2, - B1, - TrUserData) - end; - _ -> B1 - end. - -encode_msg_client_connack_request(Msg, TrUserData) -> - encode_msg_client_connack_request(Msg, - <<>>, - TrUserData). - - -encode_msg_client_connack_request(#{} = M, Bin, - TrUserData) -> - B1 = case M of - #{conninfo := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_client_connack_request_conninfo(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{result_code := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> - e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{props := F3} -> - TrF3 = id(F3, TrUserData), - if TrF3 == [] -> B2; - true -> - e_field_client_connack_request_props(TrF3, - B2, - TrUserData) - end; - _ -> B2 - end. - -encode_msg_client_connected_request(Msg, TrUserData) -> - encode_msg_client_connected_request(Msg, - <<>>, - TrUserData). - - -encode_msg_client_connected_request(#{} = M, Bin, - TrUserData) -> - case M of - #{clientinfo := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_client_connected_request_clientinfo(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_client_disconnected_request(Msg, - TrUserData) -> - encode_msg_client_disconnected_request(Msg, - <<>>, - TrUserData). - - -encode_msg_client_disconnected_request(#{} = M, Bin, - TrUserData) -> - B1 = case M of - #{clientinfo := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_client_disconnected_request_clientinfo(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end, - case M of - #{reason := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> - e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_client_authenticate_request(Msg, - TrUserData) -> - encode_msg_client_authenticate_request(Msg, - <<>>, - TrUserData). - - -encode_msg_client_authenticate_request(#{} = M, Bin, - TrUserData) -> - B1 = case M of - #{clientinfo := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_client_authenticate_request_clientinfo(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end, - case M of - #{result := F2} -> - begin - TrF2 = id(F2, TrUserData), - if TrF2 =:= false -> B1; - true -> e_type_bool(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_client_check_acl_request(Msg, TrUserData) -> - encode_msg_client_check_acl_request(Msg, - <<>>, - TrUserData). - - -encode_msg_client_check_acl_request(#{} = M, Bin, - TrUserData) -> - B1 = case M of - #{clientinfo := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_client_check_acl_request_clientinfo(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{type := F2} -> - begin - TrF2 = id(F2, TrUserData), - if TrF2 =:= 'PUBLISH'; TrF2 =:= 0 -> B1; - true -> - 'e_enum_client_check_acl_request.AclReqType'(TrF2, - <>, - TrUserData) - end - end; - _ -> B1 - end, - B3 = case M of - #{topic := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> - e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end, - case M of - #{result := F4} -> - begin - TrF4 = id(F4, TrUserData), - if TrF4 =:= false -> B3; - true -> e_type_bool(TrF4, <>, TrUserData) - end - end; - _ -> B3 - end. - -encode_msg_client_subscribe_request(Msg, TrUserData) -> - encode_msg_client_subscribe_request(Msg, - <<>>, - TrUserData). - - -encode_msg_client_subscribe_request(#{} = M, Bin, - TrUserData) -> - B1 = case M of - #{clientinfo := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_client_subscribe_request_clientinfo(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{props := F2} -> - TrF2 = id(F2, TrUserData), - if TrF2 == [] -> B1; - true -> - e_field_client_subscribe_request_props(TrF2, - B1, - TrUserData) - end; - _ -> B1 - end, - case M of - #{topic_filters := F3} -> - TrF3 = id(F3, TrUserData), - if TrF3 == [] -> B2; - true -> - e_field_client_subscribe_request_topic_filters(TrF3, - B2, - TrUserData) - end; - _ -> B2 - end. - -encode_msg_client_unsubscribe_request(Msg, - TrUserData) -> - encode_msg_client_unsubscribe_request(Msg, - <<>>, - TrUserData). - - -encode_msg_client_unsubscribe_request(#{} = M, Bin, - TrUserData) -> - B1 = case M of - #{clientinfo := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_client_unsubscribe_request_clientinfo(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{props := F2} -> - TrF2 = id(F2, TrUserData), - if TrF2 == [] -> B1; - true -> - e_field_client_unsubscribe_request_props(TrF2, - B1, - TrUserData) - end; - _ -> B1 - end, - case M of - #{topic_filters := F3} -> - TrF3 = id(F3, TrUserData), - if TrF3 == [] -> B2; - true -> - e_field_client_unsubscribe_request_topic_filters(TrF3, - B2, - TrUserData) - end; - _ -> B2 - end. - -encode_msg_session_created_request(Msg, TrUserData) -> - encode_msg_session_created_request(Msg, - <<>>, - TrUserData). - - -encode_msg_session_created_request(#{} = M, Bin, - TrUserData) -> - case M of - #{clientinfo := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_session_created_request_clientinfo(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_session_subscribed_request(Msg, - TrUserData) -> - encode_msg_session_subscribed_request(Msg, - <<>>, - TrUserData). - - -encode_msg_session_subscribed_request(#{} = M, Bin, - TrUserData) -> - B1 = case M of - #{clientinfo := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_session_subscribed_request_clientinfo(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{topic := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> - e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{subopts := F3} -> - begin - TrF3 = id(F3, TrUserData), - if TrF3 =:= undefined -> B2; - true -> - e_mfield_session_subscribed_request_subopts(TrF3, - <>, - TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_session_unsubscribed_request(Msg, - TrUserData) -> - encode_msg_session_unsubscribed_request(Msg, - <<>>, - TrUserData). - - -encode_msg_session_unsubscribed_request(#{} = M, Bin, - TrUserData) -> - B1 = case M of - #{clientinfo := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_session_unsubscribed_request_clientinfo(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end, - case M of - #{topic := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> - e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_session_resumed_request(Msg, TrUserData) -> - encode_msg_session_resumed_request(Msg, - <<>>, - TrUserData). - - -encode_msg_session_resumed_request(#{} = M, Bin, - TrUserData) -> - case M of - #{clientinfo := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_session_resumed_request_clientinfo(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_session_discarded_request(Msg, TrUserData) -> - encode_msg_session_discarded_request(Msg, - <<>>, - TrUserData). - - -encode_msg_session_discarded_request(#{} = M, Bin, - TrUserData) -> - case M of - #{clientinfo := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_session_discarded_request_clientinfo(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_session_takeovered_request(Msg, - TrUserData) -> - encode_msg_session_takeovered_request(Msg, - <<>>, - TrUserData). - - -encode_msg_session_takeovered_request(#{} = M, Bin, - TrUserData) -> - case M of - #{clientinfo := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_session_takeovered_request_clientinfo(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_session_terminated_request(Msg, - TrUserData) -> - encode_msg_session_terminated_request(Msg, - <<>>, - TrUserData). - - -encode_msg_session_terminated_request(#{} = M, Bin, - TrUserData) -> - B1 = case M of - #{clientinfo := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_session_terminated_request_clientinfo(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end, - case M of - #{reason := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> - e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_message_publish_request(Msg, TrUserData) -> - encode_msg_message_publish_request(Msg, - <<>>, - TrUserData). - - -encode_msg_message_publish_request(#{} = M, Bin, - TrUserData) -> - case M of - #{message := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_message_publish_request_message(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_message_delivered_request(Msg, TrUserData) -> - encode_msg_message_delivered_request(Msg, - <<>>, - TrUserData). - - -encode_msg_message_delivered_request(#{} = M, Bin, - TrUserData) -> - B1 = case M of - #{clientinfo := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_message_delivered_request_clientinfo(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end, - case M of - #{message := F2} -> - begin - TrF2 = id(F2, TrUserData), - if TrF2 =:= undefined -> B1; - true -> - e_mfield_message_delivered_request_message(TrF2, - <>, - TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_message_dropped_request(Msg, TrUserData) -> - encode_msg_message_dropped_request(Msg, - <<>>, - TrUserData). - - -encode_msg_message_dropped_request(#{} = M, Bin, - TrUserData) -> - B1 = case M of - #{message := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_message_dropped_request_message(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end, - case M of - #{reason := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> - e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_message_acked_request(Msg, TrUserData) -> - encode_msg_message_acked_request(Msg, <<>>, TrUserData). - - -encode_msg_message_acked_request(#{} = M, Bin, - TrUserData) -> - B1 = case M of - #{clientinfo := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> - e_mfield_message_acked_request_clientinfo(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end, - case M of - #{message := F2} -> - begin - TrF2 = id(F2, TrUserData), - if TrF2 =:= undefined -> B1; - true -> - e_mfield_message_acked_request_message(TrF2, - <>, - TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_empty_success(_Msg, _TrUserData) -> <<>>. - -encode_msg_valued_response(Msg, TrUserData) -> - encode_msg_valued_response(Msg, <<>>, TrUserData). - - -encode_msg_valued_response(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{type := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= 'CONTINUE'; TrF1 =:= 0 -> Bin; - true -> - 'e_enum_valued_response.ResponsedType'(TrF1, - <>, - TrUserData) - end - end; - _ -> Bin - end, - case M of - #{value := F2} -> - case id(F2, TrUserData) of - {bool_result, TF2} -> - begin - TrTF2 = id(TF2, TrUserData), - e_type_bool(TrTF2, <>, TrUserData) - end; - {message, TF2} -> - begin - TrTF2 = id(TF2, TrUserData), - e_mfield_valued_response_message(TrTF2, - <>, - TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_broker_info(Msg, TrUserData) -> - encode_msg_broker_info(Msg, <<>>, TrUserData). - - -encode_msg_broker_info(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{version := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> - e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{sysdescr := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> - e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - B3 = case M of - #{uptime := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> - e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end, - case M of - #{datetime := F4} -> - begin - TrF4 = id(F4, TrUserData), - case is_empty_string(TrF4) of - true -> B3; - false -> - e_type_string(TrF4, <>, TrUserData) - end - end; - _ -> B3 - end. - -encode_msg_hook_spec(Msg, TrUserData) -> - encode_msg_hook_spec(Msg, <<>>, TrUserData). - - -encode_msg_hook_spec(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{name := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> - e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{topics := F2} -> - TrF2 = id(F2, TrUserData), - if TrF2 == [] -> B1; - true -> e_field_hook_spec_topics(TrF2, B1, TrUserData) - end; - _ -> B1 - end. - -encode_msg_conn_info(Msg, TrUserData) -> - encode_msg_conn_info(Msg, <<>>, TrUserData). - - -encode_msg_conn_info(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{node := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> - e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{clientid := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> - e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - B3 = case M of - #{username := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> - e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end, - B4 = case M of - #{peerhost := F4} -> - begin - TrF4 = id(F4, TrUserData), - case is_empty_string(TrF4) of - true -> B3; - false -> - e_type_string(TrF4, <>, TrUserData) - end - end; - _ -> B3 - end, - B5 = case M of - #{sockport := F5} -> - begin - TrF5 = id(F5, TrUserData), - if TrF5 =:= 0 -> B4; - true -> e_varint(TrF5, <>, TrUserData) - end - end; - _ -> B4 - end, - B6 = case M of - #{proto_name := F6} -> - begin - TrF6 = id(F6, TrUserData), - case is_empty_string(TrF6) of - true -> B5; - false -> - e_type_string(TrF6, <>, TrUserData) - end - end; - _ -> B5 - end, - B7 = case M of - #{proto_ver := F7} -> - begin - TrF7 = id(F7, TrUserData), - case is_empty_string(TrF7) of - true -> B6; - false -> - e_type_string(TrF7, <>, TrUserData) - end - end; - _ -> B6 - end, - case M of - #{keepalive := F8} -> - begin - TrF8 = id(F8, TrUserData), - if TrF8 =:= 0 -> B7; - true -> e_varint(TrF8, <>, TrUserData) - end - end; - _ -> B7 - end. - -encode_msg_client_info(Msg, TrUserData) -> - encode_msg_client_info(Msg, <<>>, TrUserData). - - -encode_msg_client_info(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{node := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> - e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{clientid := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> - e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - B3 = case M of - #{username := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> - e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end, - B4 = case M of - #{password := F4} -> - begin - TrF4 = id(F4, TrUserData), - case is_empty_string(TrF4) of - true -> B3; - false -> - e_type_string(TrF4, <>, TrUserData) - end - end; - _ -> B3 - end, - B5 = case M of - #{peerhost := F5} -> - begin - TrF5 = id(F5, TrUserData), - case is_empty_string(TrF5) of - true -> B4; - false -> - e_type_string(TrF5, <>, TrUserData) - end - end; - _ -> B4 - end, - B6 = case M of - #{sockport := F6} -> - begin - TrF6 = id(F6, TrUserData), - if TrF6 =:= 0 -> B5; - true -> e_varint(TrF6, <>, TrUserData) - end - end; - _ -> B5 - end, - B7 = case M of - #{protocol := F7} -> - begin - TrF7 = id(F7, TrUserData), - case is_empty_string(TrF7) of - true -> B6; - false -> - e_type_string(TrF7, <>, TrUserData) - end - end; - _ -> B6 - end, - B8 = case M of - #{mountpoint := F8} -> - begin - TrF8 = id(F8, TrUserData), - case is_empty_string(TrF8) of - true -> B7; - false -> - e_type_string(TrF8, <>, TrUserData) - end - end; - _ -> B7 - end, - B9 = case M of - #{is_superuser := F9} -> - begin - TrF9 = id(F9, TrUserData), - if TrF9 =:= false -> B8; - true -> e_type_bool(TrF9, <>, TrUserData) - end - end; - _ -> B8 - end, - B10 = case M of - #{anonymous := F10} -> - begin - TrF10 = id(F10, TrUserData), - if TrF10 =:= false -> B9; - true -> - e_type_bool(TrF10, <>, TrUserData) - end - end; - _ -> B9 - end, - B11 = case M of - #{cn := F11} -> - begin - TrF11 = id(F11, TrUserData), - case is_empty_string(TrF11) of - true -> B10; - false -> - e_type_string(TrF11, - <>, - TrUserData) - end - end; - _ -> B10 - end, - case M of - #{dn := F12} -> - begin - TrF12 = id(F12, TrUserData), - case is_empty_string(TrF12) of - true -> B11; - false -> - e_type_string(TrF12, <>, TrUserData) - end - end; - _ -> B11 - end. - -encode_msg_message(Msg, TrUserData) -> - encode_msg_message(Msg, <<>>, TrUserData). - - -encode_msg_message(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{node := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> - e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{id := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> - e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - B3 = case M of - #{qos := F3} -> - begin - TrF3 = id(F3, TrUserData), - if TrF3 =:= 0 -> B2; - true -> e_varint(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end, - B4 = case M of - #{from := F4} -> - begin - TrF4 = id(F4, TrUserData), - case is_empty_string(TrF4) of - true -> B3; - false -> - e_type_string(TrF4, <>, TrUserData) - end - end; - _ -> B3 - end, - B5 = case M of - #{topic := F5} -> - begin - TrF5 = id(F5, TrUserData), - case is_empty_string(TrF5) of - true -> B4; - false -> - e_type_string(TrF5, <>, TrUserData) - end - end; - _ -> B4 - end, - B6 = case M of - #{payload := F6} -> - begin - TrF6 = id(F6, TrUserData), - case iolist_size(TrF6) of - 0 -> B5; - _ -> e_type_bytes(TrF6, <>, TrUserData) - end - end; - _ -> B5 - end, - case M of - #{timestamp := F7} -> - begin - TrF7 = id(F7, TrUserData), - if TrF7 =:= 0 -> B6; - true -> e_varint(TrF7, <>, TrUserData) - end - end; - _ -> B6 - end. - -encode_msg_property(Msg, TrUserData) -> - encode_msg_property(Msg, <<>>, TrUserData). - - -encode_msg_property(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{name := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> - e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{value := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> - e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_topic_filter(Msg, TrUserData) -> - encode_msg_topic_filter(Msg, <<>>, TrUserData). - - -encode_msg_topic_filter(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{name := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> - e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{qos := F2} -> - begin - TrF2 = id(F2, TrUserData), - if TrF2 =:= 0 -> B1; - true -> e_varint(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_sub_opts(Msg, TrUserData) -> - encode_msg_sub_opts(Msg, <<>>, TrUserData). - - -encode_msg_sub_opts(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{qos := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= 0 -> Bin; - true -> e_varint(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{share := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> - e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - B3 = case M of - #{rh := F3} -> - begin - TrF3 = id(F3, TrUserData), - if TrF3 =:= 0 -> B2; - true -> e_varint(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end, - B4 = case M of - #{rap := F4} -> - begin - TrF4 = id(F4, TrUserData), - if TrF4 =:= 0 -> B3; - true -> e_varint(TrF4, <>, TrUserData) - end - end; - _ -> B3 - end, - case M of - #{nl := F5} -> - begin - TrF5 = id(F5, TrUserData), - if TrF5 =:= 0 -> B4; - true -> e_varint(TrF5, <>, TrUserData) - end - end; - _ -> B4 - end. - -e_mfield_provider_loaded_request_broker(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_broker_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_loaded_response_hooks(Msg, Bin, TrUserData) -> - SubBin = encode_msg_hook_spec(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_loaded_response_hooks([Elem | Rest], Bin, - TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_loaded_response_hooks(id(Elem, - TrUserData), - Bin2, - TrUserData), - e_field_loaded_response_hooks(Rest, Bin3, TrUserData); -e_field_loaded_response_hooks([], Bin, _TrUserData) -> - Bin. - -e_mfield_client_connect_request_conninfo(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_conn_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_client_connect_request_props(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_property(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_client_connect_request_props([Elem | Rest], Bin, - TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_client_connect_request_props(id(Elem, - TrUserData), - Bin2, - TrUserData), - e_field_client_connect_request_props(Rest, - Bin3, - TrUserData); -e_field_client_connect_request_props([], Bin, - _TrUserData) -> - Bin. - -e_mfield_client_connack_request_conninfo(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_conn_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_client_connack_request_props(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_property(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_client_connack_request_props([Elem | Rest], Bin, - TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_client_connack_request_props(id(Elem, - TrUserData), - Bin2, - TrUserData), - e_field_client_connack_request_props(Rest, - Bin3, - TrUserData); -e_field_client_connack_request_props([], Bin, - _TrUserData) -> - Bin. - -e_mfield_client_connected_request_clientinfo(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_client_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_client_disconnected_request_clientinfo(Msg, - Bin, TrUserData) -> - SubBin = encode_msg_client_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_client_authenticate_request_clientinfo(Msg, - Bin, TrUserData) -> - SubBin = encode_msg_client_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_client_check_acl_request_clientinfo(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_client_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_client_subscribe_request_clientinfo(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_client_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_client_subscribe_request_props(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_property(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_client_subscribe_request_props([Elem | Rest], - Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_client_subscribe_request_props(id(Elem, - TrUserData), - Bin2, - TrUserData), - e_field_client_subscribe_request_props(Rest, - Bin3, - TrUserData); -e_field_client_subscribe_request_props([], Bin, - _TrUserData) -> - Bin. - -e_mfield_client_subscribe_request_topic_filters(Msg, - Bin, TrUserData) -> - SubBin = encode_msg_topic_filter(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_client_subscribe_request_topic_filters([Elem - | Rest], - Bin, TrUserData) -> - Bin2 = <>, - Bin3 = - e_mfield_client_subscribe_request_topic_filters(id(Elem, - TrUserData), - Bin2, - TrUserData), - e_field_client_subscribe_request_topic_filters(Rest, - Bin3, - TrUserData); -e_field_client_subscribe_request_topic_filters([], Bin, - _TrUserData) -> - Bin. - -e_mfield_client_unsubscribe_request_clientinfo(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_client_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_client_unsubscribe_request_props(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_property(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_client_unsubscribe_request_props([Elem | Rest], - Bin, TrUserData) -> - Bin2 = <>, - Bin3 = - e_mfield_client_unsubscribe_request_props(id(Elem, - TrUserData), - Bin2, - TrUserData), - e_field_client_unsubscribe_request_props(Rest, - Bin3, - TrUserData); -e_field_client_unsubscribe_request_props([], Bin, - _TrUserData) -> - Bin. - -e_mfield_client_unsubscribe_request_topic_filters(Msg, - Bin, TrUserData) -> - SubBin = encode_msg_topic_filter(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_client_unsubscribe_request_topic_filters([Elem - | Rest], - Bin, TrUserData) -> - Bin2 = <>, - Bin3 = - e_mfield_client_unsubscribe_request_topic_filters(id(Elem, - TrUserData), - Bin2, - TrUserData), - e_field_client_unsubscribe_request_topic_filters(Rest, - Bin3, - TrUserData); -e_field_client_unsubscribe_request_topic_filters([], - Bin, _TrUserData) -> - Bin. - -e_mfield_session_created_request_clientinfo(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_client_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_session_subscribed_request_clientinfo(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_client_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_session_subscribed_request_subopts(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_sub_opts(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_session_unsubscribed_request_clientinfo(Msg, - Bin, TrUserData) -> - SubBin = encode_msg_client_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_session_resumed_request_clientinfo(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_client_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_session_discarded_request_clientinfo(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_client_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_session_takeovered_request_clientinfo(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_client_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_session_terminated_request_clientinfo(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_client_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_message_publish_request_message(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_message(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_message_delivered_request_clientinfo(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_client_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_message_delivered_request_message(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_message(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_message_dropped_request_message(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_message(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_message_acked_request_clientinfo(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_client_info(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_message_acked_request_message(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_message(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_valued_response_message(Msg, Bin, - TrUserData) -> - SubBin = encode_msg_message(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_hook_spec_topics([Elem | Rest], Bin, - TrUserData) -> - Bin2 = <>, - Bin3 = e_type_string(id(Elem, TrUserData), - Bin2, - TrUserData), - e_field_hook_spec_topics(Rest, Bin3, TrUserData); -e_field_hook_spec_topics([], Bin, _TrUserData) -> Bin. - -'e_enum_client_check_acl_request.AclReqType'('PUBLISH', - Bin, _TrUserData) -> - <>; -'e_enum_client_check_acl_request.AclReqType'('SUBSCRIBE', - Bin, _TrUserData) -> - <>; -'e_enum_client_check_acl_request.AclReqType'(V, Bin, - _TrUserData) -> - e_varint(V, Bin). - -'e_enum_valued_response.ResponsedType'('CONTINUE', Bin, - _TrUserData) -> - <>; -'e_enum_valued_response.ResponsedType'('IGNORE', Bin, - _TrUserData) -> - <>; -'e_enum_valued_response.ResponsedType'('STOP_AND_RETURN', - Bin, _TrUserData) -> - <>; -'e_enum_valued_response.ResponsedType'(V, Bin, - _TrUserData) -> - e_varint(V, Bin). - --compile({nowarn_unused_function,e_type_sint/3}). -e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> - e_varint(Value * 2, Bin); -e_type_sint(Value, Bin, _TrUserData) -> - e_varint(Value * -2 - 1, Bin). - --compile({nowarn_unused_function,e_type_int32/3}). -e_type_int32(Value, Bin, _TrUserData) - when 0 =< Value, Value =< 127 -> - <>; -e_type_int32(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_int64/3}). -e_type_int64(Value, Bin, _TrUserData) - when 0 =< Value, Value =< 127 -> - <>; -e_type_int64(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_bool/3}). -e_type_bool(true, Bin, _TrUserData) -> - <>; -e_type_bool(false, Bin, _TrUserData) -> - <>; -e_type_bool(1, Bin, _TrUserData) -> <>; -e_type_bool(0, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_string/3}). -e_type_string(S, Bin, _TrUserData) -> - Utf8 = unicode:characters_to_binary(S), - Bin2 = e_varint(byte_size(Utf8), Bin), - <>. - --compile({nowarn_unused_function,e_type_bytes/3}). -e_type_bytes(Bytes, Bin, _TrUserData) - when is_binary(Bytes) -> - Bin2 = e_varint(byte_size(Bytes), Bin), - <>; -e_type_bytes(Bytes, Bin, _TrUserData) - when is_list(Bytes) -> - BytesBin = iolist_to_binary(Bytes), - Bin2 = e_varint(byte_size(BytesBin), Bin), - <>. - --compile({nowarn_unused_function,e_type_fixed32/3}). -e_type_fixed32(Value, Bin, _TrUserData) -> - <>. - --compile({nowarn_unused_function,e_type_sfixed32/3}). -e_type_sfixed32(Value, Bin, _TrUserData) -> - <>. - --compile({nowarn_unused_function,e_type_fixed64/3}). -e_type_fixed64(Value, Bin, _TrUserData) -> - <>. - --compile({nowarn_unused_function,e_type_sfixed64/3}). -e_type_sfixed64(Value, Bin, _TrUserData) -> - <>. - --compile({nowarn_unused_function,e_type_float/3}). -e_type_float(V, Bin, _) when is_number(V) -> - <>; -e_type_float(infinity, Bin, _) -> - <>; -e_type_float('-infinity', Bin, _) -> - <>; -e_type_float(nan, Bin, _) -> - <>. - --compile({nowarn_unused_function,e_type_double/3}). -e_type_double(V, Bin, _) when is_number(V) -> - <>; -e_type_double(infinity, Bin, _) -> - <>; -e_type_double('-infinity', Bin, _) -> - <>; -e_type_double(nan, Bin, _) -> - <>. - --compile({nowarn_unused_function,e_varint/3}). -e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). - --compile({nowarn_unused_function,e_varint/2}). -e_varint(N, Bin) when N =< 127 -> <>; -e_varint(N, Bin) -> - Bin2 = <>, - e_varint(N bsr 7, Bin2). - -is_empty_string("") -> true; -is_empty_string(<<>>) -> true; -is_empty_string(L) when is_list(L) -> - not string_has_chars(L); -is_empty_string(B) when is_binary(B) -> false. - -string_has_chars([C | _]) when is_integer(C) -> true; -string_has_chars([H | T]) -> - case string_has_chars(H) of - true -> true; - false -> string_has_chars(T) - end; -string_has_chars(B) - when is_binary(B), byte_size(B) =/= 0 -> - true; -string_has_chars(C) when is_integer(C) -> true; -string_has_chars(<<>>) -> false; -string_has_chars([]) -> false. - - -decode_msg(Bin, MsgName) when is_binary(Bin) -> - decode_msg(Bin, MsgName, []). - -decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> - TrUserData = proplists:get_value(user_data, Opts), - decode_msg_1_catch(Bin, MsgName, TrUserData). - --ifdef('OTP_RELEASE'). -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --else. -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch Class:Reason -> - StackTrace = erlang:get_stacktrace(), - error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --endif. - -decode_msg_2_doit(provider_loaded_request, Bin, - TrUserData) -> - id(decode_msg_provider_loaded_request(Bin, TrUserData), - TrUserData); -decode_msg_2_doit(loaded_response, Bin, TrUserData) -> - id(decode_msg_loaded_response(Bin, TrUserData), - TrUserData); -decode_msg_2_doit(provider_unloaded_request, Bin, - TrUserData) -> - id(decode_msg_provider_unloaded_request(Bin, - TrUserData), - TrUserData); -decode_msg_2_doit(client_connect_request, Bin, - TrUserData) -> - id(decode_msg_client_connect_request(Bin, TrUserData), - TrUserData); -decode_msg_2_doit(client_connack_request, Bin, - TrUserData) -> - id(decode_msg_client_connack_request(Bin, TrUserData), - TrUserData); -decode_msg_2_doit(client_connected_request, Bin, - TrUserData) -> - id(decode_msg_client_connected_request(Bin, TrUserData), - TrUserData); -decode_msg_2_doit(client_disconnected_request, Bin, - TrUserData) -> - id(decode_msg_client_disconnected_request(Bin, - TrUserData), - TrUserData); -decode_msg_2_doit(client_authenticate_request, Bin, - TrUserData) -> - id(decode_msg_client_authenticate_request(Bin, - TrUserData), - TrUserData); -decode_msg_2_doit(client_check_acl_request, Bin, - TrUserData) -> - id(decode_msg_client_check_acl_request(Bin, TrUserData), - TrUserData); -decode_msg_2_doit(client_subscribe_request, Bin, - TrUserData) -> - id(decode_msg_client_subscribe_request(Bin, TrUserData), - TrUserData); -decode_msg_2_doit(client_unsubscribe_request, Bin, - TrUserData) -> - id(decode_msg_client_unsubscribe_request(Bin, - TrUserData), - TrUserData); -decode_msg_2_doit(session_created_request, Bin, - TrUserData) -> - id(decode_msg_session_created_request(Bin, TrUserData), - TrUserData); -decode_msg_2_doit(session_subscribed_request, Bin, - TrUserData) -> - id(decode_msg_session_subscribed_request(Bin, - TrUserData), - TrUserData); -decode_msg_2_doit(session_unsubscribed_request, Bin, - TrUserData) -> - id(decode_msg_session_unsubscribed_request(Bin, - TrUserData), - TrUserData); -decode_msg_2_doit(session_resumed_request, Bin, - TrUserData) -> - id(decode_msg_session_resumed_request(Bin, TrUserData), - TrUserData); -decode_msg_2_doit(session_discarded_request, Bin, - TrUserData) -> - id(decode_msg_session_discarded_request(Bin, - TrUserData), - TrUserData); -decode_msg_2_doit(session_takeovered_request, Bin, - TrUserData) -> - id(decode_msg_session_takeovered_request(Bin, - TrUserData), - TrUserData); -decode_msg_2_doit(session_terminated_request, Bin, - TrUserData) -> - id(decode_msg_session_terminated_request(Bin, - TrUserData), - TrUserData); -decode_msg_2_doit(message_publish_request, Bin, - TrUserData) -> - id(decode_msg_message_publish_request(Bin, TrUserData), - TrUserData); -decode_msg_2_doit(message_delivered_request, Bin, - TrUserData) -> - id(decode_msg_message_delivered_request(Bin, - TrUserData), - TrUserData); -decode_msg_2_doit(message_dropped_request, Bin, - TrUserData) -> - id(decode_msg_message_dropped_request(Bin, TrUserData), - TrUserData); -decode_msg_2_doit(message_acked_request, Bin, - TrUserData) -> - id(decode_msg_message_acked_request(Bin, TrUserData), - TrUserData); -decode_msg_2_doit(empty_success, Bin, TrUserData) -> - id(decode_msg_empty_success(Bin, TrUserData), - TrUserData); -decode_msg_2_doit(valued_response, Bin, TrUserData) -> - id(decode_msg_valued_response(Bin, TrUserData), - TrUserData); -decode_msg_2_doit(broker_info, Bin, TrUserData) -> - id(decode_msg_broker_info(Bin, TrUserData), TrUserData); -decode_msg_2_doit(hook_spec, Bin, TrUserData) -> - id(decode_msg_hook_spec(Bin, TrUserData), TrUserData); -decode_msg_2_doit(conn_info, Bin, TrUserData) -> - id(decode_msg_conn_info(Bin, TrUserData), TrUserData); -decode_msg_2_doit(client_info, Bin, TrUserData) -> - id(decode_msg_client_info(Bin, TrUserData), TrUserData); -decode_msg_2_doit(message, Bin, TrUserData) -> - id(decode_msg_message(Bin, TrUserData), TrUserData); -decode_msg_2_doit(property, Bin, TrUserData) -> - id(decode_msg_property(Bin, TrUserData), TrUserData); -decode_msg_2_doit(topic_filter, Bin, TrUserData) -> - id(decode_msg_topic_filter(Bin, TrUserData), - TrUserData); -decode_msg_2_doit(sub_opts, Bin, TrUserData) -> - id(decode_msg_sub_opts(Bin, TrUserData), TrUserData). - - - -decode_msg_provider_loaded_request(Bin, TrUserData) -> - dfp_read_field_def_provider_loaded_request(Bin, - 0, - 0, - id('$undef', TrUserData), - TrUserData). - -dfp_read_field_def_provider_loaded_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - d_field_provider_loaded_request_broker(Rest, - Z1, - Z2, - F@_1, - TrUserData); -dfp_read_field_def_provider_loaded_request(<<>>, 0, 0, - F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{broker => F@_1} - end; -dfp_read_field_def_provider_loaded_request(Other, Z1, - Z2, F@_1, TrUserData) -> - dg_read_field_def_provider_loaded_request(Other, - Z1, - Z2, - F@_1, - TrUserData). - -dg_read_field_def_provider_loaded_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_provider_loaded_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -dg_read_field_def_provider_loaded_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_provider_loaded_request_broker(Rest, - 0, - 0, - F@_1, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_provider_loaded_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 1 -> - skip_64_provider_loaded_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 2 -> - skip_length_delimited_provider_loaded_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 3 -> - skip_group_provider_loaded_request(Rest, - Key bsr 3, - 0, - F@_1, - TrUserData); - 5 -> - skip_32_provider_loaded_request(Rest, - 0, - 0, - F@_1, - TrUserData) - end - end; -dg_read_field_def_provider_loaded_request(<<>>, 0, 0, - F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{broker => F@_1} - end. - -d_field_provider_loaded_request_broker(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 57 -> - d_field_provider_loaded_request_broker(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -d_field_provider_loaded_request_broker(<<0:1, X:7, - Rest/binary>>, - N, Acc, Prev, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_broker_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_provider_loaded_request(RestF, - 0, - 0, - if Prev == '$undef' -> NewFValue; - true -> - merge_msg_broker_info(Prev, - NewFValue, - TrUserData) - end, - TrUserData). - -skip_varint_provider_loaded_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - skip_varint_provider_loaded_request(Rest, - Z1, - Z2, - F@_1, - TrUserData); -skip_varint_provider_loaded_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_provider_loaded_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -skip_length_delimited_provider_loaded_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 57 -> - skip_length_delimited_provider_loaded_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -skip_length_delimited_provider_loaded_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_provider_loaded_request(Rest2, - 0, - 0, - F@_1, - TrUserData). - -skip_group_provider_loaded_request(Bin, FNum, Z2, F@_1, - TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_provider_loaded_request(Rest, - 0, - Z2, - F@_1, - TrUserData). - -skip_32_provider_loaded_request(<<_:32, Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_provider_loaded_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -skip_64_provider_loaded_request(<<_:64, Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_provider_loaded_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -decode_msg_loaded_response(Bin, TrUserData) -> - dfp_read_field_def_loaded_response(Bin, - 0, - 0, - id([], TrUserData), - TrUserData). - -dfp_read_field_def_loaded_response(<<10, Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - d_field_loaded_response_hooks(Rest, - Z1, - Z2, - F@_1, - TrUserData); -dfp_read_field_def_loaded_response(<<>>, 0, 0, R1, - TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{hooks => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_loaded_response(Other, Z1, Z2, F@_1, - TrUserData) -> - dg_read_field_def_loaded_response(Other, - Z1, - Z2, - F@_1, - TrUserData). - -dg_read_field_def_loaded_response(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_loaded_response(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -dg_read_field_def_loaded_response(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_loaded_response_hooks(Rest, - 0, - 0, - F@_1, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_loaded_response(Rest, - 0, - 0, - F@_1, - TrUserData); - 1 -> - skip_64_loaded_response(Rest, 0, 0, F@_1, TrUserData); - 2 -> - skip_length_delimited_loaded_response(Rest, - 0, - 0, - F@_1, - TrUserData); - 3 -> - skip_group_loaded_response(Rest, - Key bsr 3, - 0, - F@_1, - TrUserData); - 5 -> - skip_32_loaded_response(Rest, 0, 0, F@_1, TrUserData) - end - end; -dg_read_field_def_loaded_response(<<>>, 0, 0, R1, - TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{hooks => lists_reverse(R1, TrUserData)} - end. - -d_field_loaded_response_hooks(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 57 -> - d_field_loaded_response_hooks(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -d_field_loaded_response_hooks(<<0:1, X:7, Rest/binary>>, - N, Acc, Prev, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_hook_spec(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_loaded_response(RestF, - 0, - 0, - cons(NewFValue, Prev, TrUserData), - TrUserData). - -skip_varint_loaded_response(<<1:1, _:7, Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - skip_varint_loaded_response(Rest, - Z1, - Z2, - F@_1, - TrUserData); -skip_varint_loaded_response(<<0:1, _:7, Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_loaded_response(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -skip_length_delimited_loaded_response(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 57 -> - skip_length_delimited_loaded_response(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -skip_length_delimited_loaded_response(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_loaded_response(Rest2, - 0, - 0, - F@_1, - TrUserData). - -skip_group_loaded_response(Bin, FNum, Z2, F@_1, - TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_loaded_response(Rest, - 0, - Z2, - F@_1, - TrUserData). - -skip_32_loaded_response(<<_:32, Rest/binary>>, Z1, Z2, - F@_1, TrUserData) -> - dfp_read_field_def_loaded_response(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -skip_64_loaded_response(<<_:64, Rest/binary>>, Z1, Z2, - F@_1, TrUserData) -> - dfp_read_field_def_loaded_response(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -decode_msg_provider_unloaded_request(Bin, TrUserData) -> - dfp_read_field_def_provider_unloaded_request(Bin, - 0, - 0, - TrUserData). - -dfp_read_field_def_provider_unloaded_request(<<>>, 0, 0, - _) -> - #{}; -dfp_read_field_def_provider_unloaded_request(Other, Z1, - Z2, TrUserData) -> - dg_read_field_def_provider_unloaded_request(Other, - Z1, - Z2, - TrUserData). - -dg_read_field_def_provider_unloaded_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_provider_unloaded_request(Rest, - N + 7, - X bsl N + Acc, - TrUserData); -dg_read_field_def_provider_unloaded_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> - skip_varint_provider_unloaded_request(Rest, - 0, - 0, - TrUserData); - 1 -> - skip_64_provider_unloaded_request(Rest, - 0, - 0, - TrUserData); - 2 -> - skip_length_delimited_provider_unloaded_request(Rest, - 0, - 0, - TrUserData); - 3 -> - skip_group_provider_unloaded_request(Rest, - Key bsr 3, - 0, - TrUserData); - 5 -> - skip_32_provider_unloaded_request(Rest, - 0, - 0, - TrUserData) - end; -dg_read_field_def_provider_unloaded_request(<<>>, 0, 0, - _) -> - #{}. - -skip_varint_provider_unloaded_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, TrUserData) -> - skip_varint_provider_unloaded_request(Rest, - Z1, - Z2, - TrUserData); -skip_varint_provider_unloaded_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, TrUserData) -> - dfp_read_field_def_provider_unloaded_request(Rest, - Z1, - Z2, - TrUserData). - -skip_length_delimited_provider_unloaded_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, TrUserData) - when N < 57 -> - skip_length_delimited_provider_unloaded_request(Rest, - N + 7, - X bsl N + Acc, - TrUserData); -skip_length_delimited_provider_unloaded_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_provider_unloaded_request(Rest2, - 0, - 0, - TrUserData). - -skip_group_provider_unloaded_request(Bin, FNum, Z2, - TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_provider_unloaded_request(Rest, - 0, - Z2, - TrUserData). - -skip_32_provider_unloaded_request(<<_:32, Rest/binary>>, - Z1, Z2, TrUserData) -> - dfp_read_field_def_provider_unloaded_request(Rest, - Z1, - Z2, - TrUserData). - -skip_64_provider_unloaded_request(<<_:64, Rest/binary>>, - Z1, Z2, TrUserData) -> - dfp_read_field_def_provider_unloaded_request(Rest, - Z1, - Z2, - TrUserData). - -decode_msg_client_connect_request(Bin, TrUserData) -> - dfp_read_field_def_client_connect_request(Bin, - 0, - 0, - id('$undef', TrUserData), - id([], TrUserData), - TrUserData). - -dfp_read_field_def_client_connect_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - d_field_client_connect_request_conninfo(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_client_connect_request(<<18, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - d_field_client_connect_request_props(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_client_connect_request(<<>>, 0, 0, - F@_1, R1, TrUserData) -> - S1 = #{}, - S2 = if F@_1 == '$undef' -> S1; - true -> S1#{conninfo => F@_1} - end, - if R1 == '$undef' -> S2; - true -> S2#{props => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_client_connect_request(Other, Z1, Z2, - F@_1, F@_2, TrUserData) -> - dg_read_field_def_client_connect_request(Other, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -dg_read_field_def_client_connect_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_client_connect_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -dg_read_field_def_client_connect_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_client_connect_request_conninfo(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 18 -> - d_field_client_connect_request_props(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_client_connect_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 1 -> - skip_64_client_connect_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 2 -> - skip_length_delimited_client_connect_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 3 -> - skip_group_client_connect_request(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - TrUserData); - 5 -> - skip_32_client_connect_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData) - end - end; -dg_read_field_def_client_connect_request(<<>>, 0, 0, - F@_1, R1, TrUserData) -> - S1 = #{}, - S2 = if F@_1 == '$undef' -> S1; - true -> S1#{conninfo => F@_1} - end, - if R1 == '$undef' -> S2; - true -> S2#{props => lists_reverse(R1, TrUserData)} - end. - -d_field_client_connect_request_conninfo(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_client_connect_request_conninfo(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_client_connect_request_conninfo(<<0:1, X:7, - Rest/binary>>, - N, Acc, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_conn_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_client_connect_request(RestF, - 0, - 0, - if Prev == '$undef' -> NewFValue; - true -> - merge_msg_conn_info(Prev, - NewFValue, - TrUserData) - end, - F@_2, - TrUserData). - -d_field_client_connect_request_props(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_client_connect_request_props(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_client_connect_request_props(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, Prev, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_property(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_client_connect_request(RestF, - 0, - 0, - F@_1, - cons(NewFValue, Prev, TrUserData), - TrUserData). - -skip_varint_client_connect_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - skip_varint_client_connect_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -skip_varint_client_connect_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_client_connect_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_length_delimited_client_connect_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - skip_length_delimited_client_connect_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -skip_length_delimited_client_connect_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_client_connect_request(Rest2, - 0, - 0, - F@_1, - F@_2, - TrUserData). - -skip_group_client_connect_request(Bin, FNum, Z2, F@_1, - F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_client_connect_request(Rest, - 0, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_32_client_connect_request(<<_:32, Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_client_connect_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_64_client_connect_request(<<_:64, Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_client_connect_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -decode_msg_client_connack_request(Bin, TrUserData) -> - dfp_read_field_def_client_connack_request(Bin, - 0, - 0, - id('$undef', TrUserData), - id(<<>>, TrUserData), - id([], TrUserData), - TrUserData). - -dfp_read_field_def_client_connack_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, - TrUserData) -> - d_field_client_connack_request_conninfo(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData); -dfp_read_field_def_client_connack_request(<<18, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, - TrUserData) -> - d_field_client_connack_request_result_code(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData); -dfp_read_field_def_client_connack_request(<<26, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, - TrUserData) -> - d_field_client_connack_request_props(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData); -dfp_read_field_def_client_connack_request(<<>>, 0, 0, - F@_1, F@_2, R1, TrUserData) -> - S1 = #{result_code => F@_2}, - S2 = if F@_1 == '$undef' -> S1; - true -> S1#{conninfo => F@_1} - end, - if R1 == '$undef' -> S2; - true -> S2#{props => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_client_connack_request(Other, Z1, Z2, - F@_1, F@_2, F@_3, TrUserData) -> - dg_read_field_def_client_connack_request(Other, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -dg_read_field_def_client_connack_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_client_connack_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -dg_read_field_def_client_connack_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_client_connack_request_conninfo(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 18 -> - d_field_client_connack_request_result_code(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 26 -> - d_field_client_connack_request_props(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_client_connack_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 1 -> - skip_64_client_connack_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 2 -> - skip_length_delimited_client_connack_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 3 -> - skip_group_client_connack_request(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 5 -> - skip_32_client_connack_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData) - end - end; -dg_read_field_def_client_connack_request(<<>>, 0, 0, - F@_1, F@_2, R1, TrUserData) -> - S1 = #{result_code => F@_2}, - S2 = if F@_1 == '$undef' -> S1; - true -> S1#{conninfo => F@_1} - end, - if R1 == '$undef' -> S2; - true -> S2#{props => lists_reverse(R1, TrUserData)} - end. - -d_field_client_connack_request_conninfo(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 57 -> - d_field_client_connack_request_conninfo(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -d_field_client_connack_request_conninfo(<<0:1, X:7, - Rest/binary>>, - N, Acc, Prev, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_conn_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_client_connack_request(RestF, - 0, - 0, - if Prev == '$undef' -> NewFValue; - true -> - merge_msg_conn_info(Prev, - NewFValue, - TrUserData) - end, - F@_2, - F@_3, - TrUserData). - -d_field_client_connack_request_result_code(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 57 -> - d_field_client_connack_request_result_code(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -d_field_client_connack_request_result_code(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_client_connack_request(RestF, - 0, - 0, - F@_1, - NewFValue, - F@_3, - TrUserData). - -d_field_client_connack_request_props(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 57 -> - d_field_client_connack_request_props(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -d_field_client_connack_request_props(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, Prev, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_property(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_client_connack_request(RestF, - 0, - 0, - F@_1, - F@_2, - cons(NewFValue, Prev, TrUserData), - TrUserData). - -skip_varint_client_connack_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> - skip_varint_client_connack_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData); -skip_varint_client_connack_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> - dfp_read_field_def_client_connack_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -skip_length_delimited_client_connack_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) - when N < 57 -> - skip_length_delimited_client_connack_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -skip_length_delimited_client_connack_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_client_connack_request(Rest2, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData). - -skip_group_client_connack_request(Bin, FNum, Z2, F@_1, - F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_client_connack_request(Rest, - 0, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -skip_32_client_connack_request(<<_:32, Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> - dfp_read_field_def_client_connack_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -skip_64_client_connack_request(<<_:64, Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> - dfp_read_field_def_client_connack_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -decode_msg_client_connected_request(Bin, TrUserData) -> - dfp_read_field_def_client_connected_request(Bin, - 0, - 0, - id('$undef', TrUserData), - TrUserData). - -dfp_read_field_def_client_connected_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - d_field_client_connected_request_clientinfo(Rest, - Z1, - Z2, - F@_1, - TrUserData); -dfp_read_field_def_client_connected_request(<<>>, 0, 0, - F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end; -dfp_read_field_def_client_connected_request(Other, Z1, - Z2, F@_1, TrUserData) -> - dg_read_field_def_client_connected_request(Other, - Z1, - Z2, - F@_1, - TrUserData). - -dg_read_field_def_client_connected_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_client_connected_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -dg_read_field_def_client_connected_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_client_connected_request_clientinfo(Rest, - 0, - 0, - F@_1, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_client_connected_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 1 -> - skip_64_client_connected_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 2 -> - skip_length_delimited_client_connected_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 3 -> - skip_group_client_connected_request(Rest, - Key bsr 3, - 0, - F@_1, - TrUserData); - 5 -> - skip_32_client_connected_request(Rest, - 0, - 0, - F@_1, - TrUserData) - end - end; -dg_read_field_def_client_connected_request(<<>>, 0, 0, - F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end. - -d_field_client_connected_request_clientinfo(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 57 -> - d_field_client_connected_request_clientinfo(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -d_field_client_connected_request_clientinfo(<<0:1, X:7, - Rest/binary>>, - N, Acc, Prev, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_client_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_client_connected_request(RestF, - 0, - 0, - if Prev == '$undef' -> - NewFValue; - true -> - merge_msg_client_info(Prev, - NewFValue, - TrUserData) - end, - TrUserData). - -skip_varint_client_connected_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - skip_varint_client_connected_request(Rest, - Z1, - Z2, - F@_1, - TrUserData); -skip_varint_client_connected_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_client_connected_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -skip_length_delimited_client_connected_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 57 -> - skip_length_delimited_client_connected_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -skip_length_delimited_client_connected_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_client_connected_request(Rest2, - 0, - 0, - F@_1, - TrUserData). - -skip_group_client_connected_request(Bin, FNum, Z2, F@_1, - TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_client_connected_request(Rest, - 0, - Z2, - F@_1, - TrUserData). - -skip_32_client_connected_request(<<_:32, Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_client_connected_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -skip_64_client_connected_request(<<_:64, Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_client_connected_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -decode_msg_client_disconnected_request(Bin, - TrUserData) -> - dfp_read_field_def_client_disconnected_request(Bin, - 0, - 0, - id('$undef', TrUserData), - id(<<>>, TrUserData), - TrUserData). - -dfp_read_field_def_client_disconnected_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, - TrUserData) -> - d_field_client_disconnected_request_clientinfo(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_client_disconnected_request(<<18, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, - TrUserData) -> - d_field_client_disconnected_request_reason(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_client_disconnected_request(<<>>, 0, - 0, F@_1, F@_2, _) -> - S1 = #{reason => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end; -dfp_read_field_def_client_disconnected_request(Other, - Z1, Z2, F@_1, F@_2, - TrUserData) -> - dg_read_field_def_client_disconnected_request(Other, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -dg_read_field_def_client_disconnected_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_client_disconnected_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -dg_read_field_def_client_disconnected_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_client_disconnected_request_clientinfo(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 18 -> - d_field_client_disconnected_request_reason(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_client_disconnected_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 1 -> - skip_64_client_disconnected_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 2 -> - skip_length_delimited_client_disconnected_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 3 -> - skip_group_client_disconnected_request(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - TrUserData); - 5 -> - skip_32_client_disconnected_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData) - end - end; -dg_read_field_def_client_disconnected_request(<<>>, 0, - 0, F@_1, F@_2, _) -> - S1 = #{reason => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end. - -d_field_client_disconnected_request_clientinfo(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_client_disconnected_request_clientinfo(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_client_disconnected_request_clientinfo(<<0:1, - X:7, Rest/binary>>, - N, Acc, Prev, F@_2, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_client_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_client_disconnected_request(RestF, - 0, - 0, - if Prev == '$undef' -> - NewFValue; - true -> - merge_msg_client_info(Prev, - NewFValue, - TrUserData) - end, - F@_2, - TrUserData). - -d_field_client_disconnected_request_reason(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_client_disconnected_request_reason(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_client_disconnected_request_reason(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_client_disconnected_request(RestF, - 0, - 0, - F@_1, - NewFValue, - TrUserData). - -skip_varint_client_disconnected_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - skip_varint_client_disconnected_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -skip_varint_client_disconnected_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_client_disconnected_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_length_delimited_client_disconnected_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, - TrUserData) - when N < 57 -> - skip_length_delimited_client_disconnected_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -skip_length_delimited_client_disconnected_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, - TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_client_disconnected_request(Rest2, - 0, - 0, - F@_1, - F@_2, - TrUserData). - -skip_group_client_disconnected_request(Bin, FNum, Z2, - F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_client_disconnected_request(Rest, - 0, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_32_client_disconnected_request(<<_:32, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_client_disconnected_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_64_client_disconnected_request(<<_:64, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_client_disconnected_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -decode_msg_client_authenticate_request(Bin, - TrUserData) -> - dfp_read_field_def_client_authenticate_request(Bin, - 0, - 0, - id('$undef', TrUserData), - id(false, TrUserData), - TrUserData). - -dfp_read_field_def_client_authenticate_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, - TrUserData) -> - d_field_client_authenticate_request_clientinfo(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_client_authenticate_request(<<16, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, - TrUserData) -> - d_field_client_authenticate_request_result(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_client_authenticate_request(<<>>, 0, - 0, F@_1, F@_2, _) -> - S1 = #{result => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end; -dfp_read_field_def_client_authenticate_request(Other, - Z1, Z2, F@_1, F@_2, - TrUserData) -> - dg_read_field_def_client_authenticate_request(Other, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -dg_read_field_def_client_authenticate_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_client_authenticate_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -dg_read_field_def_client_authenticate_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_client_authenticate_request_clientinfo(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 16 -> - d_field_client_authenticate_request_result(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_client_authenticate_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 1 -> - skip_64_client_authenticate_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 2 -> - skip_length_delimited_client_authenticate_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 3 -> - skip_group_client_authenticate_request(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - TrUserData); - 5 -> - skip_32_client_authenticate_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData) - end - end; -dg_read_field_def_client_authenticate_request(<<>>, 0, - 0, F@_1, F@_2, _) -> - S1 = #{result => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end. - -d_field_client_authenticate_request_clientinfo(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_client_authenticate_request_clientinfo(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_client_authenticate_request_clientinfo(<<0:1, - X:7, Rest/binary>>, - N, Acc, Prev, F@_2, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_client_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_client_authenticate_request(RestF, - 0, - 0, - if Prev == '$undef' -> - NewFValue; - true -> - merge_msg_client_info(Prev, - NewFValue, - TrUserData) - end, - F@_2, - TrUserData). - -d_field_client_authenticate_request_result(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_client_authenticate_request_result(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_client_authenticate_request_result(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, _, TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, - TrUserData), - Rest}, - dfp_read_field_def_client_authenticate_request(RestF, - 0, - 0, - F@_1, - NewFValue, - TrUserData). - -skip_varint_client_authenticate_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - skip_varint_client_authenticate_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -skip_varint_client_authenticate_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_client_authenticate_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_length_delimited_client_authenticate_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, - TrUserData) - when N < 57 -> - skip_length_delimited_client_authenticate_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -skip_length_delimited_client_authenticate_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, - TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_client_authenticate_request(Rest2, - 0, - 0, - F@_1, - F@_2, - TrUserData). - -skip_group_client_authenticate_request(Bin, FNum, Z2, - F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_client_authenticate_request(Rest, - 0, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_32_client_authenticate_request(<<_:32, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_client_authenticate_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_64_client_authenticate_request(<<_:64, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_client_authenticate_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -decode_msg_client_check_acl_request(Bin, TrUserData) -> - dfp_read_field_def_client_check_acl_request(Bin, - 0, - 0, - id('$undef', TrUserData), - id('PUBLISH', TrUserData), - id(<<>>, TrUserData), - id(false, TrUserData), - TrUserData). - -dfp_read_field_def_client_check_acl_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, F@_4, - TrUserData) -> - d_field_client_check_acl_request_clientinfo(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -dfp_read_field_def_client_check_acl_request(<<16, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, F@_4, - TrUserData) -> - d_field_client_check_acl_request_type(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -dfp_read_field_def_client_check_acl_request(<<26, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, F@_4, - TrUserData) -> - d_field_client_check_acl_request_topic(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -dfp_read_field_def_client_check_acl_request(<<32, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, F@_4, - TrUserData) -> - d_field_client_check_acl_request_result(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -dfp_read_field_def_client_check_acl_request(<<>>, 0, 0, - F@_1, F@_2, F@_3, F@_4, _) -> - S1 = #{type => F@_2, topic => F@_3, result => F@_4}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end; -dfp_read_field_def_client_check_acl_request(Other, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, - TrUserData) -> - dg_read_field_def_client_check_acl_request(Other, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData). - -dg_read_field_def_client_check_acl_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, - TrUserData) - when N < 32 - 7 -> - dg_read_field_def_client_check_acl_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -dg_read_field_def_client_check_acl_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, - TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_client_check_acl_request_clientinfo(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); - 16 -> - d_field_client_check_acl_request_type(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); - 26 -> - d_field_client_check_acl_request_topic(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); - 32 -> - d_field_client_check_acl_request_result(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_client_check_acl_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); - 1 -> - skip_64_client_check_acl_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); - 2 -> - skip_length_delimited_client_check_acl_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); - 3 -> - skip_group_client_check_acl_request(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); - 5 -> - skip_32_client_check_acl_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData) - end - end; -dg_read_field_def_client_check_acl_request(<<>>, 0, 0, - F@_1, F@_2, F@_3, F@_4, _) -> - S1 = #{type => F@_2, topic => F@_3, result => F@_4}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end. - -d_field_client_check_acl_request_clientinfo(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, - TrUserData) - when N < 57 -> - d_field_client_check_acl_request_clientinfo(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -d_field_client_check_acl_request_clientinfo(<<0:1, X:7, - Rest/binary>>, - N, Acc, Prev, F@_2, F@_3, F@_4, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_client_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_client_check_acl_request(RestF, - 0, - 0, - if Prev == '$undef' -> - NewFValue; - true -> - merge_msg_client_info(Prev, - NewFValue, - TrUserData) - end, - F@_2, - F@_3, - F@_4, - TrUserData). - -d_field_client_check_acl_request_type(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, - TrUserData) - when N < 57 -> - d_field_client_check_acl_request_type(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -d_field_client_check_acl_request_type(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, _, F@_3, F@_4, - TrUserData) -> - {NewFValue, RestF} = - {id('d_enum_client_check_acl_request.AclReqType'(begin - <> = - <<(X bsl N + - Acc):32/unsigned-native>>, - id(Res, TrUserData) - end), - TrUserData), - Rest}, - dfp_read_field_def_client_check_acl_request(RestF, - 0, - 0, - F@_1, - NewFValue, - F@_3, - F@_4, - TrUserData). - -d_field_client_check_acl_request_topic(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, - TrUserData) - when N < 57 -> - d_field_client_check_acl_request_topic(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -d_field_client_check_acl_request_topic(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, _, F@_4, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_client_check_acl_request(RestF, - 0, - 0, - F@_1, - F@_2, - NewFValue, - F@_4, - TrUserData). - -d_field_client_check_acl_request_result(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, - TrUserData) - when N < 57 -> - d_field_client_check_acl_request_result(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -d_field_client_check_acl_request_result(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, _, - TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, - TrUserData), - Rest}, - dfp_read_field_def_client_check_acl_request(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - NewFValue, - TrUserData). - -skip_varint_client_check_acl_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, F@_4, - TrUserData) -> - skip_varint_client_check_acl_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -skip_varint_client_check_acl_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, F@_4, - TrUserData) -> - dfp_read_field_def_client_check_acl_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData). - -skip_length_delimited_client_check_acl_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, - TrUserData) - when N < 57 -> - skip_length_delimited_client_check_acl_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -skip_length_delimited_client_check_acl_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, - TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_client_check_acl_request(Rest2, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData). - -skip_group_client_check_acl_request(Bin, FNum, Z2, F@_1, - F@_2, F@_3, F@_4, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_client_check_acl_request(Rest, - 0, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData). - -skip_32_client_check_acl_request(<<_:32, Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - dfp_read_field_def_client_check_acl_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData). - -skip_64_client_check_acl_request(<<_:64, Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - dfp_read_field_def_client_check_acl_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData). - -decode_msg_client_subscribe_request(Bin, TrUserData) -> - dfp_read_field_def_client_subscribe_request(Bin, - 0, - 0, - id('$undef', TrUserData), - id([], TrUserData), - id([], TrUserData), - TrUserData). - -dfp_read_field_def_client_subscribe_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, - TrUserData) -> - d_field_client_subscribe_request_clientinfo(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData); -dfp_read_field_def_client_subscribe_request(<<18, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, - TrUserData) -> - d_field_client_subscribe_request_props(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData); -dfp_read_field_def_client_subscribe_request(<<26, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, - TrUserData) -> - d_field_client_subscribe_request_topic_filters(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData); -dfp_read_field_def_client_subscribe_request(<<>>, 0, 0, - F@_1, R1, R2, TrUserData) -> - S1 = #{}, - S2 = if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end, - S3 = if R1 == '$undef' -> S2; - true -> S2#{props => lists_reverse(R1, TrUserData)} - end, - if R2 == '$undef' -> S3; - true -> - S3#{topic_filters => lists_reverse(R2, TrUserData)} - end; -dfp_read_field_def_client_subscribe_request(Other, Z1, - Z2, F@_1, F@_2, F@_3, TrUserData) -> - dg_read_field_def_client_subscribe_request(Other, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -dg_read_field_def_client_subscribe_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_client_subscribe_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -dg_read_field_def_client_subscribe_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_client_subscribe_request_clientinfo(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 18 -> - d_field_client_subscribe_request_props(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 26 -> - d_field_client_subscribe_request_topic_filters(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_client_subscribe_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 1 -> - skip_64_client_subscribe_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 2 -> - skip_length_delimited_client_subscribe_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 3 -> - skip_group_client_subscribe_request(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 5 -> - skip_32_client_subscribe_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData) - end - end; -dg_read_field_def_client_subscribe_request(<<>>, 0, 0, - F@_1, R1, R2, TrUserData) -> - S1 = #{}, - S2 = if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end, - S3 = if R1 == '$undef' -> S2; - true -> S2#{props => lists_reverse(R1, TrUserData)} - end, - if R2 == '$undef' -> S3; - true -> - S3#{topic_filters => lists_reverse(R2, TrUserData)} - end. - -d_field_client_subscribe_request_clientinfo(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) - when N < 57 -> - d_field_client_subscribe_request_clientinfo(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -d_field_client_subscribe_request_clientinfo(<<0:1, X:7, - Rest/binary>>, - N, Acc, Prev, F@_2, F@_3, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_client_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_client_subscribe_request(RestF, - 0, - 0, - if Prev == '$undef' -> - NewFValue; - true -> - merge_msg_client_info(Prev, - NewFValue, - TrUserData) - end, - F@_2, - F@_3, - TrUserData). - -d_field_client_subscribe_request_props(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 57 -> - d_field_client_subscribe_request_props(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -d_field_client_subscribe_request_props(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, Prev, F@_3, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_property(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_client_subscribe_request(RestF, - 0, - 0, - F@_1, - cons(NewFValue, - Prev, - TrUserData), - F@_3, - TrUserData). - -d_field_client_subscribe_request_topic_filters(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) - when N < 57 -> - d_field_client_subscribe_request_topic_filters(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -d_field_client_subscribe_request_topic_filters(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, Prev, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_topic_filter(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_client_subscribe_request(RestF, - 0, - 0, - F@_1, - F@_2, - cons(NewFValue, - Prev, - TrUserData), - TrUserData). - -skip_varint_client_subscribe_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> - skip_varint_client_subscribe_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData); -skip_varint_client_subscribe_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> - dfp_read_field_def_client_subscribe_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -skip_length_delimited_client_subscribe_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) - when N < 57 -> - skip_length_delimited_client_subscribe_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -skip_length_delimited_client_subscribe_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_client_subscribe_request(Rest2, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData). - -skip_group_client_subscribe_request(Bin, FNum, Z2, F@_1, - F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_client_subscribe_request(Rest, - 0, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -skip_32_client_subscribe_request(<<_:32, Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> - dfp_read_field_def_client_subscribe_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -skip_64_client_subscribe_request(<<_:64, Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> - dfp_read_field_def_client_subscribe_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -decode_msg_client_unsubscribe_request(Bin, - TrUserData) -> - dfp_read_field_def_client_unsubscribe_request(Bin, - 0, - 0, - id('$undef', TrUserData), - id([], TrUserData), - id([], TrUserData), - TrUserData). - -dfp_read_field_def_client_unsubscribe_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, - TrUserData) -> - d_field_client_unsubscribe_request_clientinfo(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData); -dfp_read_field_def_client_unsubscribe_request(<<18, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, - TrUserData) -> - d_field_client_unsubscribe_request_props(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData); -dfp_read_field_def_client_unsubscribe_request(<<26, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, - TrUserData) -> - d_field_client_unsubscribe_request_topic_filters(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData); -dfp_read_field_def_client_unsubscribe_request(<<>>, 0, - 0, F@_1, R1, R2, TrUserData) -> - S1 = #{}, - S2 = if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end, - S3 = if R1 == '$undef' -> S2; - true -> S2#{props => lists_reverse(R1, TrUserData)} - end, - if R2 == '$undef' -> S3; - true -> - S3#{topic_filters => lists_reverse(R2, TrUserData)} - end; -dfp_read_field_def_client_unsubscribe_request(Other, Z1, - Z2, F@_1, F@_2, F@_3, - TrUserData) -> - dg_read_field_def_client_unsubscribe_request(Other, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -dg_read_field_def_client_unsubscribe_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) - when N < 32 - 7 -> - dg_read_field_def_client_unsubscribe_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -dg_read_field_def_client_unsubscribe_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_client_unsubscribe_request_clientinfo(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 18 -> - d_field_client_unsubscribe_request_props(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 26 -> - d_field_client_unsubscribe_request_topic_filters(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_client_unsubscribe_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 1 -> - skip_64_client_unsubscribe_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 2 -> - skip_length_delimited_client_unsubscribe_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 3 -> - skip_group_client_unsubscribe_request(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 5 -> - skip_32_client_unsubscribe_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData) - end - end; -dg_read_field_def_client_unsubscribe_request(<<>>, 0, 0, - F@_1, R1, R2, TrUserData) -> - S1 = #{}, - S2 = if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end, - S3 = if R1 == '$undef' -> S2; - true -> S2#{props => lists_reverse(R1, TrUserData)} - end, - if R2 == '$undef' -> S3; - true -> - S3#{topic_filters => lists_reverse(R2, TrUserData)} - end. - -d_field_client_unsubscribe_request_clientinfo(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) - when N < 57 -> - d_field_client_unsubscribe_request_clientinfo(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -d_field_client_unsubscribe_request_clientinfo(<<0:1, - X:7, Rest/binary>>, - N, Acc, Prev, F@_2, F@_3, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_client_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_client_unsubscribe_request(RestF, - 0, - 0, - if Prev == '$undef' -> - NewFValue; - true -> - merge_msg_client_info(Prev, - NewFValue, - TrUserData) - end, - F@_2, - F@_3, - TrUserData). - -d_field_client_unsubscribe_request_props(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 57 -> - d_field_client_unsubscribe_request_props(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -d_field_client_unsubscribe_request_props(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, Prev, F@_3, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_property(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_client_unsubscribe_request(RestF, - 0, - 0, - F@_1, - cons(NewFValue, - Prev, - TrUserData), - F@_3, - TrUserData). - -d_field_client_unsubscribe_request_topic_filters(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) - when N < 57 -> - d_field_client_unsubscribe_request_topic_filters(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -d_field_client_unsubscribe_request_topic_filters(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, Prev, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_topic_filter(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_client_unsubscribe_request(RestF, - 0, - 0, - F@_1, - F@_2, - cons(NewFValue, - Prev, - TrUserData), - TrUserData). - -skip_varint_client_unsubscribe_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> - skip_varint_client_unsubscribe_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData); -skip_varint_client_unsubscribe_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> - dfp_read_field_def_client_unsubscribe_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -skip_length_delimited_client_unsubscribe_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) - when N < 57 -> - skip_length_delimited_client_unsubscribe_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -skip_length_delimited_client_unsubscribe_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_client_unsubscribe_request(Rest2, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData). - -skip_group_client_unsubscribe_request(Bin, FNum, Z2, - F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_client_unsubscribe_request(Rest, - 0, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -skip_32_client_unsubscribe_request(<<_:32, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> - dfp_read_field_def_client_unsubscribe_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -skip_64_client_unsubscribe_request(<<_:64, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> - dfp_read_field_def_client_unsubscribe_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -decode_msg_session_created_request(Bin, TrUserData) -> - dfp_read_field_def_session_created_request(Bin, - 0, - 0, - id('$undef', TrUserData), - TrUserData). - -dfp_read_field_def_session_created_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - d_field_session_created_request_clientinfo(Rest, - Z1, - Z2, - F@_1, - TrUserData); -dfp_read_field_def_session_created_request(<<>>, 0, 0, - F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end; -dfp_read_field_def_session_created_request(Other, Z1, - Z2, F@_1, TrUserData) -> - dg_read_field_def_session_created_request(Other, - Z1, - Z2, - F@_1, - TrUserData). - -dg_read_field_def_session_created_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_session_created_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -dg_read_field_def_session_created_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_session_created_request_clientinfo(Rest, - 0, - 0, - F@_1, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_session_created_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 1 -> - skip_64_session_created_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 2 -> - skip_length_delimited_session_created_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 3 -> - skip_group_session_created_request(Rest, - Key bsr 3, - 0, - F@_1, - TrUserData); - 5 -> - skip_32_session_created_request(Rest, - 0, - 0, - F@_1, - TrUserData) - end - end; -dg_read_field_def_session_created_request(<<>>, 0, 0, - F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end. - -d_field_session_created_request_clientinfo(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 57 -> - d_field_session_created_request_clientinfo(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -d_field_session_created_request_clientinfo(<<0:1, X:7, - Rest/binary>>, - N, Acc, Prev, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_client_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_session_created_request(RestF, - 0, - 0, - if Prev == '$undef' -> NewFValue; - true -> - merge_msg_client_info(Prev, - NewFValue, - TrUserData) - end, - TrUserData). - -skip_varint_session_created_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - skip_varint_session_created_request(Rest, - Z1, - Z2, - F@_1, - TrUserData); -skip_varint_session_created_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_session_created_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -skip_length_delimited_session_created_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 57 -> - skip_length_delimited_session_created_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -skip_length_delimited_session_created_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_session_created_request(Rest2, - 0, - 0, - F@_1, - TrUserData). - -skip_group_session_created_request(Bin, FNum, Z2, F@_1, - TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_session_created_request(Rest, - 0, - Z2, - F@_1, - TrUserData). - -skip_32_session_created_request(<<_:32, Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_session_created_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -skip_64_session_created_request(<<_:64, Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_session_created_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -decode_msg_session_subscribed_request(Bin, - TrUserData) -> - dfp_read_field_def_session_subscribed_request(Bin, - 0, - 0, - id('$undef', TrUserData), - id(<<>>, TrUserData), - id('$undef', TrUserData), - TrUserData). - -dfp_read_field_def_session_subscribed_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, - TrUserData) -> - d_field_session_subscribed_request_clientinfo(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData); -dfp_read_field_def_session_subscribed_request(<<18, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, - TrUserData) -> - d_field_session_subscribed_request_topic(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData); -dfp_read_field_def_session_subscribed_request(<<26, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, - TrUserData) -> - d_field_session_subscribed_request_subopts(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData); -dfp_read_field_def_session_subscribed_request(<<>>, 0, - 0, F@_1, F@_2, F@_3, _) -> - S1 = #{topic => F@_2}, - S2 = if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end, - if F@_3 == '$undef' -> S2; - true -> S2#{subopts => F@_3} - end; -dfp_read_field_def_session_subscribed_request(Other, Z1, - Z2, F@_1, F@_2, F@_3, - TrUserData) -> - dg_read_field_def_session_subscribed_request(Other, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -dg_read_field_def_session_subscribed_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) - when N < 32 - 7 -> - dg_read_field_def_session_subscribed_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -dg_read_field_def_session_subscribed_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_session_subscribed_request_clientinfo(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 18 -> - d_field_session_subscribed_request_topic(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 26 -> - d_field_session_subscribed_request_subopts(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_session_subscribed_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 1 -> - skip_64_session_subscribed_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 2 -> - skip_length_delimited_session_subscribed_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 3 -> - skip_group_session_subscribed_request(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - F@_3, - TrUserData); - 5 -> - skip_32_session_subscribed_request(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData) - end - end; -dg_read_field_def_session_subscribed_request(<<>>, 0, 0, - F@_1, F@_2, F@_3, _) -> - S1 = #{topic => F@_2}, - S2 = if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end, - if F@_3 == '$undef' -> S2; - true -> S2#{subopts => F@_3} - end. - -d_field_session_subscribed_request_clientinfo(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) - when N < 57 -> - d_field_session_subscribed_request_clientinfo(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -d_field_session_subscribed_request_clientinfo(<<0:1, - X:7, Rest/binary>>, - N, Acc, Prev, F@_2, F@_3, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_client_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_session_subscribed_request(RestF, - 0, - 0, - if Prev == '$undef' -> - NewFValue; - true -> - merge_msg_client_info(Prev, - NewFValue, - TrUserData) - end, - F@_2, - F@_3, - TrUserData). - -d_field_session_subscribed_request_topic(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 57 -> - d_field_session_subscribed_request_topic(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -d_field_session_subscribed_request_topic(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_session_subscribed_request(RestF, - 0, - 0, - F@_1, - NewFValue, - F@_3, - TrUserData). - -d_field_session_subscribed_request_subopts(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 57 -> - d_field_session_subscribed_request_subopts(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -d_field_session_subscribed_request_subopts(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, Prev, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_sub_opts(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_session_subscribed_request(RestF, - 0, - 0, - F@_1, - F@_2, - if Prev == '$undef' -> - NewFValue; - true -> - merge_msg_sub_opts(Prev, - NewFValue, - TrUserData) - end, - TrUserData). - -skip_varint_session_subscribed_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> - skip_varint_session_subscribed_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData); -skip_varint_session_subscribed_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> - dfp_read_field_def_session_subscribed_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -skip_length_delimited_session_subscribed_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) - when N < 57 -> - skip_length_delimited_session_subscribed_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - TrUserData); -skip_length_delimited_session_subscribed_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, - TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_session_subscribed_request(Rest2, - 0, - 0, - F@_1, - F@_2, - F@_3, - TrUserData). - -skip_group_session_subscribed_request(Bin, FNum, Z2, - F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_session_subscribed_request(Rest, - 0, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -skip_32_session_subscribed_request(<<_:32, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> - dfp_read_field_def_session_subscribed_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -skip_64_session_subscribed_request(<<_:64, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> - dfp_read_field_def_session_subscribed_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - TrUserData). - -decode_msg_session_unsubscribed_request(Bin, - TrUserData) -> - dfp_read_field_def_session_unsubscribed_request(Bin, - 0, - 0, - id('$undef', TrUserData), - id(<<>>, TrUserData), - TrUserData). - -dfp_read_field_def_session_unsubscribed_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, - TrUserData) -> - d_field_session_unsubscribed_request_clientinfo(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_session_unsubscribed_request(<<18, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, - TrUserData) -> - d_field_session_unsubscribed_request_topic(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_session_unsubscribed_request(<<>>, 0, - 0, F@_1, F@_2, _) -> - S1 = #{topic => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end; -dfp_read_field_def_session_unsubscribed_request(Other, - Z1, Z2, F@_1, F@_2, - TrUserData) -> - dg_read_field_def_session_unsubscribed_request(Other, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -dg_read_field_def_session_unsubscribed_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_session_unsubscribed_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -dg_read_field_def_session_unsubscribed_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, - TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_session_unsubscribed_request_clientinfo(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 18 -> - d_field_session_unsubscribed_request_topic(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_session_unsubscribed_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 1 -> - skip_64_session_unsubscribed_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 2 -> - skip_length_delimited_session_unsubscribed_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 3 -> - skip_group_session_unsubscribed_request(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - TrUserData); - 5 -> - skip_32_session_unsubscribed_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData) - end - end; -dg_read_field_def_session_unsubscribed_request(<<>>, 0, - 0, F@_1, F@_2, _) -> - S1 = #{topic => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end. - -d_field_session_unsubscribed_request_clientinfo(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_session_unsubscribed_request_clientinfo(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_session_unsubscribed_request_clientinfo(<<0:1, - X:7, Rest/binary>>, - N, Acc, Prev, F@_2, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_client_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_session_unsubscribed_request(RestF, - 0, - 0, - if Prev == '$undef' -> - NewFValue; - true -> - merge_msg_client_info(Prev, - NewFValue, - TrUserData) - end, - F@_2, - TrUserData). - -d_field_session_unsubscribed_request_topic(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_session_unsubscribed_request_topic(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_session_unsubscribed_request_topic(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_session_unsubscribed_request(RestF, - 0, - 0, - F@_1, - NewFValue, - TrUserData). - -skip_varint_session_unsubscribed_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - skip_varint_session_unsubscribed_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -skip_varint_session_unsubscribed_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_session_unsubscribed_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_length_delimited_session_unsubscribed_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, - TrUserData) - when N < 57 -> - skip_length_delimited_session_unsubscribed_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -skip_length_delimited_session_unsubscribed_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, - TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_session_unsubscribed_request(Rest2, - 0, - 0, - F@_1, - F@_2, - TrUserData). - -skip_group_session_unsubscribed_request(Bin, FNum, Z2, - F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_session_unsubscribed_request(Rest, - 0, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_32_session_unsubscribed_request(<<_:32, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_session_unsubscribed_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_64_session_unsubscribed_request(<<_:64, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_session_unsubscribed_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -decode_msg_session_resumed_request(Bin, TrUserData) -> - dfp_read_field_def_session_resumed_request(Bin, - 0, - 0, - id('$undef', TrUserData), - TrUserData). - -dfp_read_field_def_session_resumed_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - d_field_session_resumed_request_clientinfo(Rest, - Z1, - Z2, - F@_1, - TrUserData); -dfp_read_field_def_session_resumed_request(<<>>, 0, 0, - F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end; -dfp_read_field_def_session_resumed_request(Other, Z1, - Z2, F@_1, TrUserData) -> - dg_read_field_def_session_resumed_request(Other, - Z1, - Z2, - F@_1, - TrUserData). - -dg_read_field_def_session_resumed_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_session_resumed_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -dg_read_field_def_session_resumed_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_session_resumed_request_clientinfo(Rest, - 0, - 0, - F@_1, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_session_resumed_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 1 -> - skip_64_session_resumed_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 2 -> - skip_length_delimited_session_resumed_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 3 -> - skip_group_session_resumed_request(Rest, - Key bsr 3, - 0, - F@_1, - TrUserData); - 5 -> - skip_32_session_resumed_request(Rest, - 0, - 0, - F@_1, - TrUserData) - end - end; -dg_read_field_def_session_resumed_request(<<>>, 0, 0, - F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end. - -d_field_session_resumed_request_clientinfo(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 57 -> - d_field_session_resumed_request_clientinfo(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -d_field_session_resumed_request_clientinfo(<<0:1, X:7, - Rest/binary>>, - N, Acc, Prev, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_client_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_session_resumed_request(RestF, - 0, - 0, - if Prev == '$undef' -> NewFValue; - true -> - merge_msg_client_info(Prev, - NewFValue, - TrUserData) - end, - TrUserData). - -skip_varint_session_resumed_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - skip_varint_session_resumed_request(Rest, - Z1, - Z2, - F@_1, - TrUserData); -skip_varint_session_resumed_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_session_resumed_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -skip_length_delimited_session_resumed_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 57 -> - skip_length_delimited_session_resumed_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -skip_length_delimited_session_resumed_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_session_resumed_request(Rest2, - 0, - 0, - F@_1, - TrUserData). - -skip_group_session_resumed_request(Bin, FNum, Z2, F@_1, - TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_session_resumed_request(Rest, - 0, - Z2, - F@_1, - TrUserData). - -skip_32_session_resumed_request(<<_:32, Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_session_resumed_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -skip_64_session_resumed_request(<<_:64, Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_session_resumed_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -decode_msg_session_discarded_request(Bin, TrUserData) -> - dfp_read_field_def_session_discarded_request(Bin, - 0, - 0, - id('$undef', TrUserData), - TrUserData). - -dfp_read_field_def_session_discarded_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - d_field_session_discarded_request_clientinfo(Rest, - Z1, - Z2, - F@_1, - TrUserData); -dfp_read_field_def_session_discarded_request(<<>>, 0, 0, - F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end; -dfp_read_field_def_session_discarded_request(Other, Z1, - Z2, F@_1, TrUserData) -> - dg_read_field_def_session_discarded_request(Other, - Z1, - Z2, - F@_1, - TrUserData). - -dg_read_field_def_session_discarded_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_session_discarded_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -dg_read_field_def_session_discarded_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_session_discarded_request_clientinfo(Rest, - 0, - 0, - F@_1, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_session_discarded_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 1 -> - skip_64_session_discarded_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 2 -> - skip_length_delimited_session_discarded_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 3 -> - skip_group_session_discarded_request(Rest, - Key bsr 3, - 0, - F@_1, - TrUserData); - 5 -> - skip_32_session_discarded_request(Rest, - 0, - 0, - F@_1, - TrUserData) - end - end; -dg_read_field_def_session_discarded_request(<<>>, 0, 0, - F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end. - -d_field_session_discarded_request_clientinfo(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 57 -> - d_field_session_discarded_request_clientinfo(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -d_field_session_discarded_request_clientinfo(<<0:1, X:7, - Rest/binary>>, - N, Acc, Prev, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_client_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_session_discarded_request(RestF, - 0, - 0, - if Prev == '$undef' -> - NewFValue; - true -> - merge_msg_client_info(Prev, - NewFValue, - TrUserData) - end, - TrUserData). - -skip_varint_session_discarded_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - skip_varint_session_discarded_request(Rest, - Z1, - Z2, - F@_1, - TrUserData); -skip_varint_session_discarded_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_session_discarded_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -skip_length_delimited_session_discarded_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 57 -> - skip_length_delimited_session_discarded_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -skip_length_delimited_session_discarded_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_session_discarded_request(Rest2, - 0, - 0, - F@_1, - TrUserData). - -skip_group_session_discarded_request(Bin, FNum, Z2, - F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_session_discarded_request(Rest, - 0, - Z2, - F@_1, - TrUserData). - -skip_32_session_discarded_request(<<_:32, Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_session_discarded_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -skip_64_session_discarded_request(<<_:64, Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_session_discarded_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -decode_msg_session_takeovered_request(Bin, - TrUserData) -> - dfp_read_field_def_session_takeovered_request(Bin, - 0, - 0, - id('$undef', TrUserData), - TrUserData). - -dfp_read_field_def_session_takeovered_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - d_field_session_takeovered_request_clientinfo(Rest, - Z1, - Z2, - F@_1, - TrUserData); -dfp_read_field_def_session_takeovered_request(<<>>, 0, - 0, F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end; -dfp_read_field_def_session_takeovered_request(Other, Z1, - Z2, F@_1, TrUserData) -> - dg_read_field_def_session_takeovered_request(Other, - Z1, - Z2, - F@_1, - TrUserData). - -dg_read_field_def_session_takeovered_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_session_takeovered_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -dg_read_field_def_session_takeovered_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_session_takeovered_request_clientinfo(Rest, - 0, - 0, - F@_1, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_session_takeovered_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 1 -> - skip_64_session_takeovered_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 2 -> - skip_length_delimited_session_takeovered_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 3 -> - skip_group_session_takeovered_request(Rest, - Key bsr 3, - 0, - F@_1, - TrUserData); - 5 -> - skip_32_session_takeovered_request(Rest, - 0, - 0, - F@_1, - TrUserData) - end - end; -dg_read_field_def_session_takeovered_request(<<>>, 0, 0, - F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end. - -d_field_session_takeovered_request_clientinfo(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 57 -> - d_field_session_takeovered_request_clientinfo(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -d_field_session_takeovered_request_clientinfo(<<0:1, - X:7, Rest/binary>>, - N, Acc, Prev, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_client_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_session_takeovered_request(RestF, - 0, - 0, - if Prev == '$undef' -> - NewFValue; - true -> - merge_msg_client_info(Prev, - NewFValue, - TrUserData) - end, - TrUserData). - -skip_varint_session_takeovered_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - skip_varint_session_takeovered_request(Rest, - Z1, - Z2, - F@_1, - TrUserData); -skip_varint_session_takeovered_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_session_takeovered_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -skip_length_delimited_session_takeovered_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 57 -> - skip_length_delimited_session_takeovered_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -skip_length_delimited_session_takeovered_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_session_takeovered_request(Rest2, - 0, - 0, - F@_1, - TrUserData). - -skip_group_session_takeovered_request(Bin, FNum, Z2, - F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_session_takeovered_request(Rest, - 0, - Z2, - F@_1, - TrUserData). - -skip_32_session_takeovered_request(<<_:32, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_session_takeovered_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -skip_64_session_takeovered_request(<<_:64, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_session_takeovered_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -decode_msg_session_terminated_request(Bin, - TrUserData) -> - dfp_read_field_def_session_terminated_request(Bin, - 0, - 0, - id('$undef', TrUserData), - id(<<>>, TrUserData), - TrUserData). - -dfp_read_field_def_session_terminated_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - d_field_session_terminated_request_clientinfo(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_session_terminated_request(<<18, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - d_field_session_terminated_request_reason(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_session_terminated_request(<<>>, 0, - 0, F@_1, F@_2, _) -> - S1 = #{reason => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end; -dfp_read_field_def_session_terminated_request(Other, Z1, - Z2, F@_1, F@_2, TrUserData) -> - dg_read_field_def_session_terminated_request(Other, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -dg_read_field_def_session_terminated_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_session_terminated_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -dg_read_field_def_session_terminated_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_session_terminated_request_clientinfo(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 18 -> - d_field_session_terminated_request_reason(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_session_terminated_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 1 -> - skip_64_session_terminated_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 2 -> - skip_length_delimited_session_terminated_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 3 -> - skip_group_session_terminated_request(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - TrUserData); - 5 -> - skip_32_session_terminated_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData) - end - end; -dg_read_field_def_session_terminated_request(<<>>, 0, 0, - F@_1, F@_2, _) -> - S1 = #{reason => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end. - -d_field_session_terminated_request_clientinfo(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_session_terminated_request_clientinfo(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_session_terminated_request_clientinfo(<<0:1, - X:7, Rest/binary>>, - N, Acc, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_client_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_session_terminated_request(RestF, - 0, - 0, - if Prev == '$undef' -> - NewFValue; - true -> - merge_msg_client_info(Prev, - NewFValue, - TrUserData) - end, - F@_2, - TrUserData). - -d_field_session_terminated_request_reason(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_session_terminated_request_reason(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_session_terminated_request_reason(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_session_terminated_request(RestF, - 0, - 0, - F@_1, - NewFValue, - TrUserData). - -skip_varint_session_terminated_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - skip_varint_session_terminated_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -skip_varint_session_terminated_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_session_terminated_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_length_delimited_session_terminated_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - skip_length_delimited_session_terminated_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -skip_length_delimited_session_terminated_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, - TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_session_terminated_request(Rest2, - 0, - 0, - F@_1, - F@_2, - TrUserData). - -skip_group_session_terminated_request(Bin, FNum, Z2, - F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_session_terminated_request(Rest, - 0, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_32_session_terminated_request(<<_:32, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_session_terminated_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_64_session_terminated_request(<<_:64, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_session_terminated_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -decode_msg_message_publish_request(Bin, TrUserData) -> - dfp_read_field_def_message_publish_request(Bin, - 0, - 0, - id('$undef', TrUserData), - TrUserData). - -dfp_read_field_def_message_publish_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - d_field_message_publish_request_message(Rest, - Z1, - Z2, - F@_1, - TrUserData); -dfp_read_field_def_message_publish_request(<<>>, 0, 0, - F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{message => F@_1} - end; -dfp_read_field_def_message_publish_request(Other, Z1, - Z2, F@_1, TrUserData) -> - dg_read_field_def_message_publish_request(Other, - Z1, - Z2, - F@_1, - TrUserData). - -dg_read_field_def_message_publish_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_message_publish_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -dg_read_field_def_message_publish_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_message_publish_request_message(Rest, - 0, - 0, - F@_1, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_message_publish_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 1 -> - skip_64_message_publish_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 2 -> - skip_length_delimited_message_publish_request(Rest, - 0, - 0, - F@_1, - TrUserData); - 3 -> - skip_group_message_publish_request(Rest, - Key bsr 3, - 0, - F@_1, - TrUserData); - 5 -> - skip_32_message_publish_request(Rest, - 0, - 0, - F@_1, - TrUserData) - end - end; -dg_read_field_def_message_publish_request(<<>>, 0, 0, - F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{message => F@_1} - end. - -d_field_message_publish_request_message(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 57 -> - d_field_message_publish_request_message(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -d_field_message_publish_request_message(<<0:1, X:7, - Rest/binary>>, - N, Acc, Prev, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_message(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_message_publish_request(RestF, - 0, - 0, - if Prev == '$undef' -> NewFValue; - true -> - merge_msg_message(Prev, - NewFValue, - TrUserData) - end, - TrUserData). - -skip_varint_message_publish_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - skip_varint_message_publish_request(Rest, - Z1, - Z2, - F@_1, - TrUserData); -skip_varint_message_publish_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_message_publish_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -skip_length_delimited_message_publish_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 57 -> - skip_length_delimited_message_publish_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - TrUserData); -skip_length_delimited_message_publish_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_message_publish_request(Rest2, - 0, - 0, - F@_1, - TrUserData). - -skip_group_message_publish_request(Bin, FNum, Z2, F@_1, - TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_message_publish_request(Rest, - 0, - Z2, - F@_1, - TrUserData). - -skip_32_message_publish_request(<<_:32, Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_message_publish_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -skip_64_message_publish_request(<<_:64, Rest/binary>>, - Z1, Z2, F@_1, TrUserData) -> - dfp_read_field_def_message_publish_request(Rest, - Z1, - Z2, - F@_1, - TrUserData). - -decode_msg_message_delivered_request(Bin, TrUserData) -> - dfp_read_field_def_message_delivered_request(Bin, - 0, - 0, - id('$undef', TrUserData), - id('$undef', TrUserData), - TrUserData). - -dfp_read_field_def_message_delivered_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - d_field_message_delivered_request_clientinfo(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_message_delivered_request(<<18, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - d_field_message_delivered_request_message(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_message_delivered_request(<<>>, 0, 0, - F@_1, F@_2, _) -> - S1 = #{}, - S2 = if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end, - if F@_2 == '$undef' -> S2; - true -> S2#{message => F@_2} - end; -dfp_read_field_def_message_delivered_request(Other, Z1, - Z2, F@_1, F@_2, TrUserData) -> - dg_read_field_def_message_delivered_request(Other, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -dg_read_field_def_message_delivered_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_message_delivered_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -dg_read_field_def_message_delivered_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_message_delivered_request_clientinfo(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 18 -> - d_field_message_delivered_request_message(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_message_delivered_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 1 -> - skip_64_message_delivered_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 2 -> - skip_length_delimited_message_delivered_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 3 -> - skip_group_message_delivered_request(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - TrUserData); - 5 -> - skip_32_message_delivered_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData) - end - end; -dg_read_field_def_message_delivered_request(<<>>, 0, 0, - F@_1, F@_2, _) -> - S1 = #{}, - S2 = if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end, - if F@_2 == '$undef' -> S2; - true -> S2#{message => F@_2} - end. - -d_field_message_delivered_request_clientinfo(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_message_delivered_request_clientinfo(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_message_delivered_request_clientinfo(<<0:1, X:7, - Rest/binary>>, - N, Acc, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_client_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_message_delivered_request(RestF, - 0, - 0, - if Prev == '$undef' -> - NewFValue; - true -> - merge_msg_client_info(Prev, - NewFValue, - TrUserData) - end, - F@_2, - TrUserData). - -d_field_message_delivered_request_message(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_message_delivered_request_message(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_message_delivered_request_message(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, Prev, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_message(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_message_delivered_request(RestF, - 0, - 0, - F@_1, - if Prev == '$undef' -> - NewFValue; - true -> - merge_msg_message(Prev, - NewFValue, - TrUserData) - end, - TrUserData). - -skip_varint_message_delivered_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - skip_varint_message_delivered_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -skip_varint_message_delivered_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_message_delivered_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_length_delimited_message_delivered_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - skip_length_delimited_message_delivered_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -skip_length_delimited_message_delivered_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, - TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_message_delivered_request(Rest2, - 0, - 0, - F@_1, - F@_2, - TrUserData). - -skip_group_message_delivered_request(Bin, FNum, Z2, - F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_message_delivered_request(Rest, - 0, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_32_message_delivered_request(<<_:32, Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_message_delivered_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_64_message_delivered_request(<<_:64, Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_message_delivered_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -decode_msg_message_dropped_request(Bin, TrUserData) -> - dfp_read_field_def_message_dropped_request(Bin, - 0, - 0, - id('$undef', TrUserData), - id(<<>>, TrUserData), - TrUserData). - -dfp_read_field_def_message_dropped_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - d_field_message_dropped_request_message(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_message_dropped_request(<<18, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - d_field_message_dropped_request_reason(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_message_dropped_request(<<>>, 0, 0, - F@_1, F@_2, _) -> - S1 = #{reason => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{message => F@_1} - end; -dfp_read_field_def_message_dropped_request(Other, Z1, - Z2, F@_1, F@_2, TrUserData) -> - dg_read_field_def_message_dropped_request(Other, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -dg_read_field_def_message_dropped_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_message_dropped_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -dg_read_field_def_message_dropped_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_message_dropped_request_message(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 18 -> - d_field_message_dropped_request_reason(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_message_dropped_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 1 -> - skip_64_message_dropped_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 2 -> - skip_length_delimited_message_dropped_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 3 -> - skip_group_message_dropped_request(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - TrUserData); - 5 -> - skip_32_message_dropped_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData) - end - end; -dg_read_field_def_message_dropped_request(<<>>, 0, 0, - F@_1, F@_2, _) -> - S1 = #{reason => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{message => F@_1} - end. - -d_field_message_dropped_request_message(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_message_dropped_request_message(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_message_dropped_request_message(<<0:1, X:7, - Rest/binary>>, - N, Acc, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_message(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_message_dropped_request(RestF, - 0, - 0, - if Prev == '$undef' -> NewFValue; - true -> - merge_msg_message(Prev, - NewFValue, - TrUserData) - end, - F@_2, - TrUserData). - -d_field_message_dropped_request_reason(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_message_dropped_request_reason(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_message_dropped_request_reason(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_message_dropped_request(RestF, - 0, - 0, - F@_1, - NewFValue, - TrUserData). - -skip_varint_message_dropped_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - skip_varint_message_dropped_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -skip_varint_message_dropped_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_message_dropped_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_length_delimited_message_dropped_request(<<1:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - skip_length_delimited_message_dropped_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -skip_length_delimited_message_dropped_request(<<0:1, - X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_message_dropped_request(Rest2, - 0, - 0, - F@_1, - F@_2, - TrUserData). - -skip_group_message_dropped_request(Bin, FNum, Z2, F@_1, - F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_message_dropped_request(Rest, - 0, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_32_message_dropped_request(<<_:32, Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_message_dropped_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_64_message_dropped_request(<<_:64, Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_message_dropped_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -decode_msg_message_acked_request(Bin, TrUserData) -> - dfp_read_field_def_message_acked_request(Bin, - 0, - 0, - id('$undef', TrUserData), - id('$undef', TrUserData), - TrUserData). - -dfp_read_field_def_message_acked_request(<<10, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - d_field_message_acked_request_clientinfo(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_message_acked_request(<<18, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - d_field_message_acked_request_message(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_message_acked_request(<<>>, 0, 0, - F@_1, F@_2, _) -> - S1 = #{}, - S2 = if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end, - if F@_2 == '$undef' -> S2; - true -> S2#{message => F@_2} - end; -dfp_read_field_def_message_acked_request(Other, Z1, Z2, - F@_1, F@_2, TrUserData) -> - dg_read_field_def_message_acked_request(Other, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -dg_read_field_def_message_acked_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_message_acked_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -dg_read_field_def_message_acked_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_message_acked_request_clientinfo(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 18 -> - d_field_message_acked_request_message(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_message_acked_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 1 -> - skip_64_message_acked_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 2 -> - skip_length_delimited_message_acked_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 3 -> - skip_group_message_acked_request(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - TrUserData); - 5 -> - skip_32_message_acked_request(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData) - end - end; -dg_read_field_def_message_acked_request(<<>>, 0, 0, - F@_1, F@_2, _) -> - S1 = #{}, - S2 = if F@_1 == '$undef' -> S1; - true -> S1#{clientinfo => F@_1} - end, - if F@_2 == '$undef' -> S2; - true -> S2#{message => F@_2} - end. - -d_field_message_acked_request_clientinfo(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_message_acked_request_clientinfo(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_message_acked_request_clientinfo(<<0:1, X:7, - Rest/binary>>, - N, Acc, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_client_info(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_message_acked_request(RestF, - 0, - 0, - if Prev == '$undef' -> NewFValue; - true -> - merge_msg_client_info(Prev, - NewFValue, - TrUserData) - end, - F@_2, - TrUserData). - -d_field_message_acked_request_message(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_message_acked_request_message(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_message_acked_request_message(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, Prev, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_message(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_message_acked_request(RestF, - 0, - 0, - F@_1, - if Prev == '$undef' -> NewFValue; - true -> - merge_msg_message(Prev, - NewFValue, - TrUserData) - end, - TrUserData). - -skip_varint_message_acked_request(<<1:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - skip_varint_message_acked_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -skip_varint_message_acked_request(<<0:1, _:7, - Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_message_acked_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_length_delimited_message_acked_request(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - skip_length_delimited_message_acked_request(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -skip_length_delimited_message_acked_request(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_message_acked_request(Rest2, - 0, - 0, - F@_1, - F@_2, - TrUserData). - -skip_group_message_acked_request(Bin, FNum, Z2, F@_1, - F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_message_acked_request(Rest, - 0, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_32_message_acked_request(<<_:32, Rest/binary>>, Z1, - Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_message_acked_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_64_message_acked_request(<<_:64, Rest/binary>>, Z1, - Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_message_acked_request(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -decode_msg_empty_success(Bin, TrUserData) -> - dfp_read_field_def_empty_success(Bin, 0, 0, TrUserData). - -dfp_read_field_def_empty_success(<<>>, 0, 0, _) -> #{}; -dfp_read_field_def_empty_success(Other, Z1, Z2, - TrUserData) -> - dg_read_field_def_empty_success(Other, - Z1, - Z2, - TrUserData). - -dg_read_field_def_empty_success(<<1:1, X:7, - Rest/binary>>, - N, Acc, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_empty_success(Rest, - N + 7, - X bsl N + Acc, - TrUserData); -dg_read_field_def_empty_success(<<0:1, X:7, - Rest/binary>>, - N, Acc, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> skip_varint_empty_success(Rest, 0, 0, TrUserData); - 1 -> skip_64_empty_success(Rest, 0, 0, TrUserData); - 2 -> - skip_length_delimited_empty_success(Rest, - 0, - 0, - TrUserData); - 3 -> - skip_group_empty_success(Rest, - Key bsr 3, - 0, - TrUserData); - 5 -> skip_32_empty_success(Rest, 0, 0, TrUserData) - end; -dg_read_field_def_empty_success(<<>>, 0, 0, _) -> #{}. - -skip_varint_empty_success(<<1:1, _:7, Rest/binary>>, Z1, - Z2, TrUserData) -> - skip_varint_empty_success(Rest, Z1, Z2, TrUserData); -skip_varint_empty_success(<<0:1, _:7, Rest/binary>>, Z1, - Z2, TrUserData) -> - dfp_read_field_def_empty_success(Rest, - Z1, - Z2, - TrUserData). - -skip_length_delimited_empty_success(<<1:1, X:7, - Rest/binary>>, - N, Acc, TrUserData) - when N < 57 -> - skip_length_delimited_empty_success(Rest, - N + 7, - X bsl N + Acc, - TrUserData); -skip_length_delimited_empty_success(<<0:1, X:7, - Rest/binary>>, - N, Acc, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_empty_success(Rest2, - 0, - 0, - TrUserData). - -skip_group_empty_success(Bin, FNum, Z2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_empty_success(Rest, - 0, - Z2, - TrUserData). - -skip_32_empty_success(<<_:32, Rest/binary>>, Z1, Z2, - TrUserData) -> - dfp_read_field_def_empty_success(Rest, - Z1, - Z2, - TrUserData). - -skip_64_empty_success(<<_:64, Rest/binary>>, Z1, Z2, - TrUserData) -> - dfp_read_field_def_empty_success(Rest, - Z1, - Z2, - TrUserData). - -decode_msg_valued_response(Bin, TrUserData) -> - dfp_read_field_def_valued_response(Bin, - 0, - 0, - id('CONTINUE', TrUserData), - id('$undef', TrUserData), - TrUserData). - -dfp_read_field_def_valued_response(<<8, Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - d_field_valued_response_type(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_valued_response(<<24, Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - d_field_valued_response_bool_result(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_valued_response(<<34, Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - d_field_valued_response_message(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_valued_response(<<>>, 0, 0, F@_1, - F@_2, _) -> - S1 = #{type => F@_1}, - if F@_2 == '$undef' -> S1; - true -> S1#{value => F@_2} - end; -dfp_read_field_def_valued_response(Other, Z1, Z2, F@_1, - F@_2, TrUserData) -> - dg_read_field_def_valued_response(Other, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -dg_read_field_def_valued_response(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_valued_response(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -dg_read_field_def_valued_response(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 8 -> - d_field_valued_response_type(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 24 -> - d_field_valued_response_bool_result(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 34 -> - d_field_valued_response_message(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_valued_response(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 1 -> - skip_64_valued_response(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 2 -> - skip_length_delimited_valued_response(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 3 -> - skip_group_valued_response(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - TrUserData); - 5 -> - skip_32_valued_response(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData) - end - end; -dg_read_field_def_valued_response(<<>>, 0, 0, F@_1, - F@_2, _) -> - S1 = #{type => F@_1}, - if F@_2 == '$undef' -> S1; - true -> S1#{value => F@_2} - end. - -d_field_valued_response_type(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_valued_response_type(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_valued_response_type(<<0:1, X:7, Rest/binary>>, - N, Acc, _, F@_2, TrUserData) -> - {NewFValue, RestF} = - {id('d_enum_valued_response.ResponsedType'(begin - <> = - <<(X bsl N + - Acc):32/unsigned-native>>, - id(Res, TrUserData) - end), - TrUserData), - Rest}, - dfp_read_field_def_valued_response(RestF, - 0, - 0, - NewFValue, - F@_2, - TrUserData). - -d_field_valued_response_bool_result(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_valued_response_bool_result(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_valued_response_bool_result(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, _, TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, - TrUserData), - Rest}, - dfp_read_field_def_valued_response(RestF, - 0, - 0, - F@_1, - id({bool_result, NewFValue}, TrUserData), - TrUserData). - -d_field_valued_response_message(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_valued_response_message(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_valued_response_message(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, Prev, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_message(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_valued_response(RestF, - 0, - 0, - F@_1, - case Prev of - '$undef' -> - id({message, NewFValue}, - TrUserData); - {message, MVPrev} -> - id({message, - merge_msg_message(MVPrev, - NewFValue, - TrUserData)}, - TrUserData); - _ -> - id({message, NewFValue}, - TrUserData) - end, - TrUserData). - -skip_varint_valued_response(<<1:1, _:7, Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - skip_varint_valued_response(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -skip_varint_valued_response(<<0:1, _:7, Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_valued_response(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_length_delimited_valued_response(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - skip_length_delimited_valued_response(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -skip_length_delimited_valued_response(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_valued_response(Rest2, - 0, - 0, - F@_1, - F@_2, - TrUserData). - -skip_group_valued_response(Bin, FNum, Z2, F@_1, F@_2, - TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_valued_response(Rest, - 0, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_32_valued_response(<<_:32, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - dfp_read_field_def_valued_response(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_64_valued_response(<<_:64, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - dfp_read_field_def_valued_response(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -decode_msg_broker_info(Bin, TrUserData) -> - dfp_read_field_def_broker_info(Bin, - 0, - 0, - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - TrUserData). - -dfp_read_field_def_broker_info(<<10, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - d_field_broker_info_version(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -dfp_read_field_def_broker_info(<<18, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - d_field_broker_info_sysdescr(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -dfp_read_field_def_broker_info(<<26, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - d_field_broker_info_uptime(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -dfp_read_field_def_broker_info(<<34, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - d_field_broker_info_datetime(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -dfp_read_field_def_broker_info(<<>>, 0, 0, F@_1, F@_2, - F@_3, F@_4, _) -> - #{version => F@_1, sysdescr => F@_2, uptime => F@_3, - datetime => F@_4}; -dfp_read_field_def_broker_info(Other, Z1, Z2, F@_1, - F@_2, F@_3, F@_4, TrUserData) -> - dg_read_field_def_broker_info(Other, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData). - -dg_read_field_def_broker_info(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_broker_info(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -dg_read_field_def_broker_info(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_broker_info_version(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); - 18 -> - d_field_broker_info_sysdescr(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); - 26 -> - d_field_broker_info_uptime(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); - 34 -> - d_field_broker_info_datetime(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_broker_info(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); - 1 -> - skip_64_broker_info(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); - 2 -> - skip_length_delimited_broker_info(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); - 3 -> - skip_group_broker_info(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); - 5 -> - skip_32_broker_info(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData) - end - end; -dg_read_field_def_broker_info(<<>>, 0, 0, F@_1, F@_2, - F@_3, F@_4, _) -> - #{version => F@_1, sysdescr => F@_2, uptime => F@_3, - datetime => F@_4}. - -d_field_broker_info_version(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) - when N < 57 -> - d_field_broker_info_version(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -d_field_broker_info_version(<<0:1, X:7, Rest/binary>>, - N, Acc, _, F@_2, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_broker_info(RestF, - 0, - 0, - NewFValue, - F@_2, - F@_3, - F@_4, - TrUserData). - -d_field_broker_info_sysdescr(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) - when N < 57 -> - d_field_broker_info_sysdescr(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -d_field_broker_info_sysdescr(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, _, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_broker_info(RestF, - 0, - 0, - F@_1, - NewFValue, - F@_3, - F@_4, - TrUserData). - -d_field_broker_info_uptime(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) - when N < 57 -> - d_field_broker_info_uptime(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -d_field_broker_info_uptime(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, _, F@_4, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_broker_info(RestF, - 0, - 0, - F@_1, - F@_2, - NewFValue, - F@_4, - TrUserData). - -d_field_broker_info_datetime(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) - when N < 57 -> - d_field_broker_info_datetime(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -d_field_broker_info_datetime(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, _, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_broker_info(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - NewFValue, - TrUserData). - -skip_varint_broker_info(<<1:1, _:7, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - skip_varint_broker_info(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -skip_varint_broker_info(<<0:1, _:7, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - dfp_read_field_def_broker_info(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData). - -skip_length_delimited_broker_info(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) - when N < 57 -> - skip_length_delimited_broker_info(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData); -skip_length_delimited_broker_info(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_broker_info(Rest2, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData). - -skip_group_broker_info(Bin, FNum, Z2, F@_1, F@_2, F@_3, - F@_4, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_broker_info(Rest, - 0, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData). - -skip_32_broker_info(<<_:32, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, F@_4, TrUserData) -> - dfp_read_field_def_broker_info(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData). - -skip_64_broker_info(<<_:64, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, F@_4, TrUserData) -> - dfp_read_field_def_broker_info(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - TrUserData). - -decode_msg_hook_spec(Bin, TrUserData) -> - dfp_read_field_def_hook_spec(Bin, - 0, - 0, - id(<<>>, TrUserData), - id([], TrUserData), - TrUserData). - -dfp_read_field_def_hook_spec(<<10, Rest/binary>>, Z1, - Z2, F@_1, F@_2, TrUserData) -> - d_field_hook_spec_name(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_hook_spec(<<18, Rest/binary>>, Z1, - Z2, F@_1, F@_2, TrUserData) -> - d_field_hook_spec_topics(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_hook_spec(<<>>, 0, 0, F@_1, R1, - TrUserData) -> - #{name => F@_1, - topics => lists_reverse(R1, TrUserData)}; -dfp_read_field_def_hook_spec(Other, Z1, Z2, F@_1, F@_2, - TrUserData) -> - dg_read_field_def_hook_spec(Other, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -dg_read_field_def_hook_spec(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_hook_spec(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -dg_read_field_def_hook_spec(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_hook_spec_name(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 18 -> - d_field_hook_spec_topics(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_hook_spec(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 1 -> - skip_64_hook_spec(Rest, 0, 0, F@_1, F@_2, TrUserData); - 2 -> - skip_length_delimited_hook_spec(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 3 -> - skip_group_hook_spec(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - TrUserData); - 5 -> - skip_32_hook_spec(Rest, 0, 0, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_hook_spec(<<>>, 0, 0, F@_1, R1, - TrUserData) -> - #{name => F@_1, - topics => lists_reverse(R1, TrUserData)}. - -d_field_hook_spec_name(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_hook_spec_name(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_hook_spec_name(<<0:1, X:7, Rest/binary>>, N, - Acc, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_hook_spec(RestF, - 0, - 0, - NewFValue, - F@_2, - TrUserData). - -d_field_hook_spec_topics(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_hook_spec_topics(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_hook_spec_topics(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, Prev, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_hook_spec(RestF, - 0, - 0, - F@_1, - cons(NewFValue, Prev, TrUserData), - TrUserData). - -skip_varint_hook_spec(<<1:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - skip_varint_hook_spec(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -skip_varint_hook_spec(<<0:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - dfp_read_field_def_hook_spec(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_length_delimited_hook_spec(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - skip_length_delimited_hook_spec(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -skip_length_delimited_hook_spec(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_hook_spec(Rest2, - 0, - 0, - F@_1, - F@_2, - TrUserData). - -skip_group_hook_spec(Bin, FNum, Z2, F@_1, F@_2, - TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_hook_spec(Rest, - 0, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_32_hook_spec(<<_:32, Rest/binary>>, Z1, Z2, F@_1, - F@_2, TrUserData) -> - dfp_read_field_def_hook_spec(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_64_hook_spec(<<_:64, Rest/binary>>, Z1, Z2, F@_1, - F@_2, TrUserData) -> - dfp_read_field_def_hook_spec(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -decode_msg_conn_info(Bin, TrUserData) -> - dfp_read_field_def_conn_info(Bin, - 0, - 0, - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(0, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(0, TrUserData), - TrUserData). - -dfp_read_field_def_conn_info(<<10, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) -> - d_field_conn_info_node(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -dfp_read_field_def_conn_info(<<18, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) -> - d_field_conn_info_clientid(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -dfp_read_field_def_conn_info(<<26, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) -> - d_field_conn_info_username(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -dfp_read_field_def_conn_info(<<34, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) -> - d_field_conn_info_peerhost(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -dfp_read_field_def_conn_info(<<40, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) -> - d_field_conn_info_sockport(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -dfp_read_field_def_conn_info(<<50, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) -> - d_field_conn_info_proto_name(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -dfp_read_field_def_conn_info(<<58, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) -> - d_field_conn_info_proto_ver(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -dfp_read_field_def_conn_info(<<64, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) -> - d_field_conn_info_keepalive(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -dfp_read_field_def_conn_info(<<>>, 0, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, _) -> - #{node => F@_1, clientid => F@_2, username => F@_3, - peerhost => F@_4, sockport => F@_5, proto_name => F@_6, - proto_ver => F@_7, keepalive => F@_8}; -dfp_read_field_def_conn_info(Other, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> - dg_read_field_def_conn_info(Other, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData). - -dg_read_field_def_conn_info(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_conn_info(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -dg_read_field_def_conn_info(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_conn_info_node(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); - 18 -> - d_field_conn_info_clientid(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); - 26 -> - d_field_conn_info_username(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); - 34 -> - d_field_conn_info_peerhost(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); - 40 -> - d_field_conn_info_sockport(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); - 50 -> - d_field_conn_info_proto_name(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); - 58 -> - d_field_conn_info_proto_ver(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); - 64 -> - d_field_conn_info_keepalive(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_conn_info(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); - 1 -> - skip_64_conn_info(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); - 2 -> - skip_length_delimited_conn_info(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); - 3 -> - skip_group_conn_info(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); - 5 -> - skip_32_conn_info(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData) - end - end; -dg_read_field_def_conn_info(<<>>, 0, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, _) -> - #{node => F@_1, clientid => F@_2, username => F@_3, - peerhost => F@_4, sockport => F@_5, proto_name => F@_6, - proto_ver => F@_7, keepalive => F@_8}. - -d_field_conn_info_node(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) - when N < 57 -> - d_field_conn_info_node(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -d_field_conn_info_node(<<0:1, X:7, Rest/binary>>, N, - Acc, _, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_conn_info(RestF, - 0, - 0, - NewFValue, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData). - -d_field_conn_info_clientid(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) - when N < 57 -> - d_field_conn_info_clientid(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -d_field_conn_info_clientid(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, _, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_conn_info(RestF, - 0, - 0, - F@_1, - NewFValue, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData). - -d_field_conn_info_username(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) - when N < 57 -> - d_field_conn_info_username(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -d_field_conn_info_username(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, _, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_conn_info(RestF, - 0, - 0, - F@_1, - F@_2, - NewFValue, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData). - -d_field_conn_info_peerhost(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) - when N < 57 -> - d_field_conn_info_peerhost(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -d_field_conn_info_peerhost(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, _, F@_5, F@_6, F@_7, F@_8, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_conn_info(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - NewFValue, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData). - -d_field_conn_info_sockport(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) - when N < 57 -> - d_field_conn_info_sockport(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -d_field_conn_info_sockport(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, _, F@_6, F@_7, F@_8, - TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc, TrUserData), - Rest}, - dfp_read_field_def_conn_info(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - NewFValue, - F@_6, - F@_7, - F@_8, - TrUserData). - -d_field_conn_info_proto_name(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, TrUserData) - when N < 57 -> - d_field_conn_info_proto_name(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -d_field_conn_info_proto_name(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, _, F@_7, - F@_8, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_conn_info(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - NewFValue, - F@_7, - F@_8, - TrUserData). - -d_field_conn_info_proto_ver(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, TrUserData) - when N < 57 -> - d_field_conn_info_proto_ver(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -d_field_conn_info_proto_ver(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, _, F@_8, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_conn_info(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - NewFValue, - F@_8, - TrUserData). - -d_field_conn_info_keepalive(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, TrUserData) - when N < 57 -> - d_field_conn_info_keepalive(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -d_field_conn_info_keepalive(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, _, - TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc, TrUserData), - Rest}, - dfp_read_field_def_conn_info(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - NewFValue, - TrUserData). - -skip_varint_conn_info(<<1:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) -> - skip_varint_conn_info(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -skip_varint_conn_info(<<0:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - TrUserData) -> - dfp_read_field_def_conn_info(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData). - -skip_length_delimited_conn_info(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, - F@_7, F@_8, TrUserData) - when N < 57 -> - skip_length_delimited_conn_info(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData); -skip_length_delimited_conn_info(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, - F@_7, F@_8, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_conn_info(Rest2, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData). - -skip_group_conn_info(Bin, FNum, Z2, F@_1, F@_2, F@_3, - F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_conn_info(Rest, - 0, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData). - -skip_32_conn_info(<<_:32, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> - dfp_read_field_def_conn_info(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData). - -skip_64_conn_info(<<_:64, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> - dfp_read_field_def_conn_info(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - TrUserData). - -decode_msg_client_info(Bin, TrUserData) -> - dfp_read_field_def_client_info(Bin, - 0, - 0, - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(0, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(false, TrUserData), - id(false, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - TrUserData). - -dfp_read_field_def_client_info(<<10, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - d_field_client_info_node(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -dfp_read_field_def_client_info(<<18, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - d_field_client_info_clientid(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -dfp_read_field_def_client_info(<<26, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - d_field_client_info_username(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -dfp_read_field_def_client_info(<<34, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - d_field_client_info_password(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -dfp_read_field_def_client_info(<<42, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - d_field_client_info_peerhost(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -dfp_read_field_def_client_info(<<48, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - d_field_client_info_sockport(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -dfp_read_field_def_client_info(<<58, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - d_field_client_info_protocol(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -dfp_read_field_def_client_info(<<66, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - d_field_client_info_mountpoint(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -dfp_read_field_def_client_info(<<72, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - d_field_client_info_is_superuser(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -dfp_read_field_def_client_info(<<80, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - d_field_client_info_anonymous(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -dfp_read_field_def_client_info(<<90, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - d_field_client_info_cn(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -dfp_read_field_def_client_info(<<98, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - d_field_client_info_dn(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -dfp_read_field_def_client_info(<<>>, 0, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, - F@_11, F@_12, _) -> - #{node => F@_1, clientid => F@_2, username => F@_3, - password => F@_4, peerhost => F@_5, sockport => F@_6, - protocol => F@_7, mountpoint => F@_8, - is_superuser => F@_9, anonymous => F@_10, cn => F@_11, - dn => F@_12}; -dfp_read_field_def_client_info(Other, Z1, Z2, F@_1, - F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, - F@_10, F@_11, F@_12, TrUserData) -> - dg_read_field_def_client_info(Other, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData). - -dg_read_field_def_client_info(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_client_info(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -dg_read_field_def_client_info(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_client_info_node(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); - 18 -> - d_field_client_info_clientid(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); - 26 -> - d_field_client_info_username(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); - 34 -> - d_field_client_info_password(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); - 42 -> - d_field_client_info_peerhost(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); - 48 -> - d_field_client_info_sockport(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); - 58 -> - d_field_client_info_protocol(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); - 66 -> - d_field_client_info_mountpoint(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); - 72 -> - d_field_client_info_is_superuser(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); - 80 -> - d_field_client_info_anonymous(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); - 90 -> - d_field_client_info_cn(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); - 98 -> - d_field_client_info_dn(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_client_info(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); - 1 -> - skip_64_client_info(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); - 2 -> - skip_length_delimited_client_info(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); - 3 -> - skip_group_client_info(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); - 5 -> - skip_32_client_info(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData) - end - end; -dg_read_field_def_client_info(<<>>, 0, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, - F@_11, F@_12, _) -> - #{node => F@_1, clientid => F@_2, username => F@_3, - password => F@_4, peerhost => F@_5, sockport => F@_6, - protocol => F@_7, mountpoint => F@_8, - is_superuser => F@_9, anonymous => F@_10, cn => F@_11, - dn => F@_12}. - -d_field_client_info_node(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - F@_9, F@_10, F@_11, F@_12, TrUserData) - when N < 57 -> - d_field_client_info_node(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -d_field_client_info_node(<<0:1, X:7, Rest/binary>>, N, - Acc, _, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, - F@_10, F@_11, F@_12, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_client_info(RestF, - 0, - 0, - NewFValue, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData). - -d_field_client_info_clientid(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) - when N < 57 -> - d_field_client_info_clientid(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -d_field_client_info_clientid(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, _, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_client_info(RestF, - 0, - 0, - F@_1, - NewFValue, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData). - -d_field_client_info_username(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) - when N < 57 -> - d_field_client_info_username(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -d_field_client_info_username(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, _, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_client_info(RestF, - 0, - 0, - F@_1, - F@_2, - NewFValue, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData). - -d_field_client_info_password(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) - when N < 57 -> - d_field_client_info_password(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -d_field_client_info_password(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, _, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_client_info(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - NewFValue, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData). - -d_field_client_info_peerhost(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) - when N < 57 -> - d_field_client_info_peerhost(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -d_field_client_info_peerhost(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, _, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_client_info(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - NewFValue, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData). - -d_field_client_info_sockport(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) - when N < 57 -> - d_field_client_info_sockport(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -d_field_client_info_sockport(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, _, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc, TrUserData), - Rest}, - dfp_read_field_def_client_info(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - NewFValue, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData). - -d_field_client_info_protocol(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) - when N < 57 -> - d_field_client_info_protocol(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -d_field_client_info_protocol(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, _, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_client_info(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - NewFValue, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData). - -d_field_client_info_mountpoint(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) - when N < 57 -> - d_field_client_info_mountpoint(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -d_field_client_info_mountpoint(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - _, F@_9, F@_10, F@_11, F@_12, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_client_info(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - NewFValue, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData). - -d_field_client_info_is_superuser(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, - F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, - TrUserData) - when N < 57 -> - d_field_client_info_is_superuser(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -d_field_client_info_is_superuser(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, - F@_7, F@_8, _, F@_10, F@_11, F@_12, - TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, - TrUserData), - Rest}, - dfp_read_field_def_client_info(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - NewFValue, - F@_10, - F@_11, - F@_12, - TrUserData). - -d_field_client_info_anonymous(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, F@_10, F@_11, F@_12, TrUserData) - when N < 57 -> - d_field_client_info_anonymous(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -d_field_client_info_anonymous(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - F@_8, F@_9, _, F@_11, F@_12, TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, - TrUserData), - Rest}, - dfp_read_field_def_client_info(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - NewFValue, - F@_11, - F@_12, - TrUserData). - -d_field_client_info_cn(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - F@_9, F@_10, F@_11, F@_12, TrUserData) - when N < 57 -> - d_field_client_info_cn(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -d_field_client_info_cn(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - F@_9, F@_10, _, F@_12, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_client_info(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - NewFValue, - F@_12, - TrUserData). - -d_field_client_info_dn(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - F@_9, F@_10, F@_11, F@_12, TrUserData) - when N < 57 -> - d_field_client_info_dn(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -d_field_client_info_dn(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - F@_9, F@_10, F@_11, _, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_client_info(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - NewFValue, - TrUserData). - -skip_varint_client_info(<<1:1, _:7, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - F@_9, F@_10, F@_11, F@_12, TrUserData) -> - skip_varint_client_info(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -skip_varint_client_info(<<0:1, _:7, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, - F@_9, F@_10, F@_11, F@_12, TrUserData) -> - dfp_read_field_def_client_info(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData). - -skip_length_delimited_client_info(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, - F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, - TrUserData) - when N < 57 -> - skip_length_delimited_client_info(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData); -skip_length_delimited_client_info(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, - F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, - TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_client_info(Rest2, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData). - -skip_group_client_info(Bin, FNum, Z2, F@_1, F@_2, F@_3, - F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, - TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_client_info(Rest, - 0, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData). - -skip_32_client_info(<<_:32, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, - F@_11, F@_12, TrUserData) -> - dfp_read_field_def_client_info(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData). - -skip_64_client_info(<<_:64, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, - F@_11, F@_12, TrUserData) -> - dfp_read_field_def_client_info(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - TrUserData). - -decode_msg_message(Bin, TrUserData) -> - dfp_read_field_def_message(Bin, - 0, - 0, - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(0, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(0, TrUserData), - TrUserData). - -dfp_read_field_def_message(<<10, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - TrUserData) -> - d_field_message_node(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); -dfp_read_field_def_message(<<18, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - TrUserData) -> - d_field_message_id(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); -dfp_read_field_def_message(<<24, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - TrUserData) -> - d_field_message_qos(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); -dfp_read_field_def_message(<<34, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - TrUserData) -> - d_field_message_from(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); -dfp_read_field_def_message(<<42, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - TrUserData) -> - d_field_message_topic(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); -dfp_read_field_def_message(<<50, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - TrUserData) -> - d_field_message_payload(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); -dfp_read_field_def_message(<<56, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - TrUserData) -> - d_field_message_timestamp(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); -dfp_read_field_def_message(<<>>, 0, 0, F@_1, F@_2, F@_3, - F@_4, F@_5, F@_6, F@_7, _) -> - #{node => F@_1, id => F@_2, qos => F@_3, from => F@_4, - topic => F@_5, payload => F@_6, timestamp => F@_7}; -dfp_read_field_def_message(Other, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, F@_6, F@_7, TrUserData) -> - dg_read_field_def_message(Other, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData). - -dg_read_field_def_message(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - TrUserData) - when N < 32 - 7 -> - dg_read_field_def_message(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); -dg_read_field_def_message(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_message_node(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); - 18 -> - d_field_message_id(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); - 24 -> - d_field_message_qos(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); - 34 -> - d_field_message_from(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); - 42 -> - d_field_message_topic(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); - 50 -> - d_field_message_payload(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); - 56 -> - d_field_message_timestamp(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_message(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); - 1 -> - skip_64_message(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); - 2 -> - skip_length_delimited_message(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); - 3 -> - skip_group_message(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); - 5 -> - skip_32_message(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData) - end - end; -dg_read_field_def_message(<<>>, 0, 0, F@_1, F@_2, F@_3, - F@_4, F@_5, F@_6, F@_7, _) -> - #{node => F@_1, id => F@_2, qos => F@_3, from => F@_4, - topic => F@_5, payload => F@_6, timestamp => F@_7}. - -d_field_message_node(<<1:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, TrUserData) - when N < 57 -> - d_field_message_node(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); -d_field_message_node(<<0:1, X:7, Rest/binary>>, N, Acc, - _, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_message(RestF, - 0, - 0, - NewFValue, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData). - -d_field_message_id(<<1:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, TrUserData) - when N < 57 -> - d_field_message_id(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); -d_field_message_id(<<0:1, X:7, Rest/binary>>, N, Acc, - F@_1, _, F@_3, F@_4, F@_5, F@_6, F@_7, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_message(RestF, - 0, - 0, - F@_1, - NewFValue, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData). - -d_field_message_qos(<<1:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, TrUserData) - when N < 57 -> - d_field_message_qos(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); -d_field_message_qos(<<0:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, _, F@_4, F@_5, F@_6, F@_7, TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc, TrUserData), - Rest}, - dfp_read_field_def_message(RestF, - 0, - 0, - F@_1, - F@_2, - NewFValue, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData). - -d_field_message_from(<<1:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, TrUserData) - when N < 57 -> - d_field_message_from(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); -d_field_message_from(<<0:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, F@_3, _, F@_5, F@_6, F@_7, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_message(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - NewFValue, - F@_5, - F@_6, - F@_7, - TrUserData). - -d_field_message_topic(<<1:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, TrUserData) - when N < 57 -> - d_field_message_topic(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); -d_field_message_topic(<<0:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, F@_3, F@_4, _, F@_6, F@_7, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_message(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - NewFValue, - F@_6, - F@_7, - TrUserData). - -d_field_message_payload(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - TrUserData) - when N < 57 -> - d_field_message_payload(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); -d_field_message_payload(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, _, F@_7, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_message(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - NewFValue, - F@_7, - TrUserData). - -d_field_message_timestamp(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - TrUserData) - when N < 57 -> - d_field_message_timestamp(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); -d_field_message_timestamp(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, _, - TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc, TrUserData), - Rest}, - dfp_read_field_def_message(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - NewFValue, - TrUserData). - -skip_varint_message(<<1:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, TrUserData) -> - skip_varint_message(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); -skip_varint_message(<<0:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, TrUserData) -> - dfp_read_field_def_message(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData). - -skip_length_delimited_message(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - TrUserData) - when N < 57 -> - skip_length_delimited_message(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData); -skip_length_delimited_message(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, - TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_message(Rest2, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData). - -skip_group_message(Bin, FNum, Z2, F@_1, F@_2, F@_3, - F@_4, F@_5, F@_6, F@_7, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_message(Rest, - 0, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData). - -skip_32_message(<<_:32, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, TrUserData) -> - dfp_read_field_def_message(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData). - -skip_64_message(<<_:64, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, TrUserData) -> - dfp_read_field_def_message(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - TrUserData). - -decode_msg_property(Bin, TrUserData) -> - dfp_read_field_def_property(Bin, - 0, - 0, - id(<<>>, TrUserData), - id(<<>>, TrUserData), - TrUserData). - -dfp_read_field_def_property(<<10, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - d_field_property_name(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_property(<<18, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - d_field_property_value(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_property(<<>>, 0, 0, F@_1, F@_2, - _) -> - #{name => F@_1, value => F@_2}; -dfp_read_field_def_property(Other, Z1, Z2, F@_1, F@_2, - TrUserData) -> - dg_read_field_def_property(Other, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -dg_read_field_def_property(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_property(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -dg_read_field_def_property(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_property_name(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 18 -> - d_field_property_value(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_property(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 1 -> - skip_64_property(Rest, 0, 0, F@_1, F@_2, TrUserData); - 2 -> - skip_length_delimited_property(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 3 -> - skip_group_property(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - TrUserData); - 5 -> - skip_32_property(Rest, 0, 0, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_property(<<>>, 0, 0, F@_1, F@_2, _) -> - #{name => F@_1, value => F@_2}. - -d_field_property_name(<<1:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_property_name(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_property_name(<<0:1, X:7, Rest/binary>>, N, Acc, - _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_property(RestF, - 0, - 0, - NewFValue, - F@_2, - TrUserData). - -d_field_property_value(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_property_value(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_property_value(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_property(RestF, - 0, - 0, - F@_1, - NewFValue, - TrUserData). - -skip_varint_property(<<1:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - skip_varint_property(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -skip_varint_property(<<0:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - dfp_read_field_def_property(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_length_delimited_property(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - skip_length_delimited_property(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -skip_length_delimited_property(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_property(Rest2, - 0, - 0, - F@_1, - F@_2, - TrUserData). - -skip_group_property(Bin, FNum, Z2, F@_1, F@_2, - TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_property(Rest, - 0, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_32_property(<<_:32, Rest/binary>>, Z1, Z2, F@_1, - F@_2, TrUserData) -> - dfp_read_field_def_property(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_64_property(<<_:64, Rest/binary>>, Z1, Z2, F@_1, - F@_2, TrUserData) -> - dfp_read_field_def_property(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -decode_msg_topic_filter(Bin, TrUserData) -> - dfp_read_field_def_topic_filter(Bin, - 0, - 0, - id(<<>>, TrUserData), - id(0, TrUserData), - TrUserData). - -dfp_read_field_def_topic_filter(<<10, Rest/binary>>, Z1, - Z2, F@_1, F@_2, TrUserData) -> - d_field_topic_filter_name(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_topic_filter(<<16, Rest/binary>>, Z1, - Z2, F@_1, F@_2, TrUserData) -> - d_field_topic_filter_qos(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -dfp_read_field_def_topic_filter(<<>>, 0, 0, F@_1, F@_2, - _) -> - #{name => F@_1, qos => F@_2}; -dfp_read_field_def_topic_filter(Other, Z1, Z2, F@_1, - F@_2, TrUserData) -> - dg_read_field_def_topic_filter(Other, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -dg_read_field_def_topic_filter(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_topic_filter(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -dg_read_field_def_topic_filter(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> - d_field_topic_filter_name(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 16 -> - d_field_topic_filter_qos(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_topic_filter(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 1 -> - skip_64_topic_filter(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 2 -> - skip_length_delimited_topic_filter(Rest, - 0, - 0, - F@_1, - F@_2, - TrUserData); - 3 -> - skip_group_topic_filter(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - TrUserData); - 5 -> - skip_32_topic_filter(Rest, 0, 0, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_topic_filter(<<>>, 0, 0, F@_1, F@_2, - _) -> - #{name => F@_1, qos => F@_2}. - -d_field_topic_filter_name(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_topic_filter_name(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_topic_filter_name(<<0:1, X:7, Rest/binary>>, N, - Acc, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_topic_filter(RestF, - 0, - 0, - NewFValue, - F@_2, - TrUserData). - -d_field_topic_filter_qos(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_topic_filter_qos(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -d_field_topic_filter_qos(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, _, TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc, TrUserData), - Rest}, - dfp_read_field_def_topic_filter(RestF, - 0, - 0, - F@_1, - NewFValue, - TrUserData). - -skip_varint_topic_filter(<<1:1, _:7, Rest/binary>>, Z1, - Z2, F@_1, F@_2, TrUserData) -> - skip_varint_topic_filter(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData); -skip_varint_topic_filter(<<0:1, _:7, Rest/binary>>, Z1, - Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_topic_filter(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_length_delimited_topic_filter(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - skip_length_delimited_topic_filter(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - TrUserData); -skip_length_delimited_topic_filter(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_topic_filter(Rest2, - 0, - 0, - F@_1, - F@_2, - TrUserData). - -skip_group_topic_filter(Bin, FNum, Z2, F@_1, F@_2, - TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_topic_filter(Rest, - 0, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_32_topic_filter(<<_:32, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - dfp_read_field_def_topic_filter(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -skip_64_topic_filter(<<_:64, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - dfp_read_field_def_topic_filter(Rest, - Z1, - Z2, - F@_1, - F@_2, - TrUserData). - -decode_msg_sub_opts(Bin, TrUserData) -> - dfp_read_field_def_sub_opts(Bin, - 0, - 0, - id(0, TrUserData), - id(<<>>, TrUserData), - id(0, TrUserData), - id(0, TrUserData), - id(0, TrUserData), - TrUserData). - -dfp_read_field_def_sub_opts(<<8, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - d_field_sub_opts_qos(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); -dfp_read_field_def_sub_opts(<<18, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - d_field_sub_opts_share(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); -dfp_read_field_def_sub_opts(<<24, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - d_field_sub_opts_rh(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); -dfp_read_field_def_sub_opts(<<32, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - d_field_sub_opts_rap(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); -dfp_read_field_def_sub_opts(<<40, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - d_field_sub_opts_nl(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); -dfp_read_field_def_sub_opts(<<>>, 0, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, _) -> - #{qos => F@_1, share => F@_2, rh => F@_3, rap => F@_4, - nl => F@_5}; -dfp_read_field_def_sub_opts(Other, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData) -> - dg_read_field_def_sub_opts(Other, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData). - -dg_read_field_def_sub_opts(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_sub_opts(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); -dg_read_field_def_sub_opts(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 8 -> - d_field_sub_opts_qos(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); - 18 -> - d_field_sub_opts_share(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); - 24 -> - d_field_sub_opts_rh(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); - 32 -> - d_field_sub_opts_rap(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); - 40 -> - d_field_sub_opts_nl(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_sub_opts(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); - 1 -> - skip_64_sub_opts(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); - 2 -> - skip_length_delimited_sub_opts(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); - 3 -> - skip_group_sub_opts(Rest, - Key bsr 3, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); - 5 -> - skip_32_sub_opts(Rest, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData) - end - end; -dg_read_field_def_sub_opts(<<>>, 0, 0, F@_1, F@_2, F@_3, - F@_4, F@_5, _) -> - #{qos => F@_1, share => F@_2, rh => F@_3, rap => F@_4, - nl => F@_5}. - -d_field_sub_opts_qos(<<1:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 57 -> - d_field_sub_opts_qos(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); -d_field_sub_opts_qos(<<0:1, X:7, Rest/binary>>, N, Acc, - _, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc, TrUserData), - Rest}, - dfp_read_field_def_sub_opts(RestF, - 0, - 0, - NewFValue, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData). - -d_field_sub_opts_share(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 57 -> - d_field_sub_opts_share(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); -d_field_sub_opts_share(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, _, F@_3, F@_4, F@_5, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_sub_opts(RestF, - 0, - 0, - F@_1, - NewFValue, - F@_3, - F@_4, - F@_5, - TrUserData). - -d_field_sub_opts_rh(<<1:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 57 -> - d_field_sub_opts_rh(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); -d_field_sub_opts_rh(<<0:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, _, F@_4, F@_5, TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc, TrUserData), - Rest}, - dfp_read_field_def_sub_opts(RestF, - 0, - 0, - F@_1, - F@_2, - NewFValue, - F@_4, - F@_5, - TrUserData). - -d_field_sub_opts_rap(<<1:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 57 -> - d_field_sub_opts_rap(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); -d_field_sub_opts_rap(<<0:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, F@_3, _, F@_5, TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc, TrUserData), - Rest}, - dfp_read_field_def_sub_opts(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - NewFValue, - F@_5, - TrUserData). - -d_field_sub_opts_nl(<<1:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 57 -> - d_field_sub_opts_nl(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); -d_field_sub_opts_nl(<<0:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, F@_3, F@_4, _, TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc, TrUserData), - Rest}, - dfp_read_field_def_sub_opts(RestF, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - NewFValue, - TrUserData). - -skip_varint_sub_opts(<<1:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - skip_varint_sub_opts(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); -skip_varint_sub_opts(<<0:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - dfp_read_field_def_sub_opts(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData). - -skip_length_delimited_sub_opts(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 57 -> - skip_length_delimited_sub_opts(Rest, - N + 7, - X bsl N + Acc, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData); -skip_length_delimited_sub_opts(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, - TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_sub_opts(Rest2, - 0, - 0, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData). - -skip_group_sub_opts(Bin, FNum, Z2, F@_1, F@_2, F@_3, - F@_4, F@_5, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_sub_opts(Rest, - 0, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData). - -skip_32_sub_opts(<<_:32, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, F@_4, F@_5, TrUserData) -> - dfp_read_field_def_sub_opts(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData). - -skip_64_sub_opts(<<_:64, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, F@_4, F@_5, TrUserData) -> - dfp_read_field_def_sub_opts(Rest, - Z1, - Z2, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - TrUserData). - -'d_enum_client_check_acl_request.AclReqType'(0) -> - 'PUBLISH'; -'d_enum_client_check_acl_request.AclReqType'(1) -> - 'SUBSCRIBE'; -'d_enum_client_check_acl_request.AclReqType'(V) -> V. - -'d_enum_valued_response.ResponsedType'(0) -> 'CONTINUE'; -'d_enum_valued_response.ResponsedType'(1) -> 'IGNORE'; -'d_enum_valued_response.ResponsedType'(2) -> - 'STOP_AND_RETURN'; -'d_enum_valued_response.ResponsedType'(V) -> V. - -read_group(Bin, FieldNum) -> - {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), - <> = Bin, - {Group, Rest}. - -%% Like skipping over fields, but record the total length, -%% Each field is <(FieldNum bsl 3) bor FieldType> ++ -%% Record the length because varints may be non-optimally encoded. -%% -%% Groups can be nested, but assume the same FieldNum cannot be nested -%% because group field numbers are shared with the rest of the fields -%% numbers. Thus we can search just for an group-end with the same -%% field number. -%% -%% (The only time the same group field number could occur would -%% be in a nested sub message, but then it would be inside a -%% length-delimited entry, which we skip-read by length.) -read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) - when N < (32-7) -> - read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); -read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, - FieldNum) -> - Key = X bsl N + Acc, - TagLen1 = TagLen + 1, - case {Key bsr 3, Key band 7} of - {FieldNum, 4} -> % 4 = group_end - {NumBytes, TagLen1}; - {_, 0} -> % 0 = varint - read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); - {_, 1} -> % 1 = bits64 - <<_:64, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); - {_, 2} -> % 2 = length_delimited - read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); - {_, 3} -> % 3 = group_start - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 4} -> % 4 = group_end - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 5} -> % 5 = bits32 - <<_:32, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) - end. - -read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); -read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> - read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). - -read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); -read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> - Len = X bsl N + Acc, - NumBytes1 = NumBytes + 1, - <<_:Len/binary, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). - -merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> - merge_msgs(Prev, New, MsgName, []). - -merge_msgs(Prev, New, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - provider_loaded_request -> - merge_msg_provider_loaded_request(Prev, - New, - TrUserData); - loaded_response -> - merge_msg_loaded_response(Prev, New, TrUserData); - provider_unloaded_request -> - merge_msg_provider_unloaded_request(Prev, - New, - TrUserData); - client_connect_request -> - merge_msg_client_connect_request(Prev, New, TrUserData); - client_connack_request -> - merge_msg_client_connack_request(Prev, New, TrUserData); - client_connected_request -> - merge_msg_client_connected_request(Prev, - New, - TrUserData); - client_disconnected_request -> - merge_msg_client_disconnected_request(Prev, - New, - TrUserData); - client_authenticate_request -> - merge_msg_client_authenticate_request(Prev, - New, - TrUserData); - client_check_acl_request -> - merge_msg_client_check_acl_request(Prev, - New, - TrUserData); - client_subscribe_request -> - merge_msg_client_subscribe_request(Prev, - New, - TrUserData); - client_unsubscribe_request -> - merge_msg_client_unsubscribe_request(Prev, - New, - TrUserData); - session_created_request -> - merge_msg_session_created_request(Prev, - New, - TrUserData); - session_subscribed_request -> - merge_msg_session_subscribed_request(Prev, - New, - TrUserData); - session_unsubscribed_request -> - merge_msg_session_unsubscribed_request(Prev, - New, - TrUserData); - session_resumed_request -> - merge_msg_session_resumed_request(Prev, - New, - TrUserData); - session_discarded_request -> - merge_msg_session_discarded_request(Prev, - New, - TrUserData); - session_takeovered_request -> - merge_msg_session_takeovered_request(Prev, - New, - TrUserData); - session_terminated_request -> - merge_msg_session_terminated_request(Prev, - New, - TrUserData); - message_publish_request -> - merge_msg_message_publish_request(Prev, - New, - TrUserData); - message_delivered_request -> - merge_msg_message_delivered_request(Prev, - New, - TrUserData); - message_dropped_request -> - merge_msg_message_dropped_request(Prev, - New, - TrUserData); - message_acked_request -> - merge_msg_message_acked_request(Prev, New, TrUserData); - empty_success -> - merge_msg_empty_success(Prev, New, TrUserData); - valued_response -> - merge_msg_valued_response(Prev, New, TrUserData); - broker_info -> - merge_msg_broker_info(Prev, New, TrUserData); - hook_spec -> merge_msg_hook_spec(Prev, New, TrUserData); - conn_info -> merge_msg_conn_info(Prev, New, TrUserData); - client_info -> - merge_msg_client_info(Prev, New, TrUserData); - message -> merge_msg_message(Prev, New, TrUserData); - property -> merge_msg_property(Prev, New, TrUserData); - topic_filter -> - merge_msg_topic_filter(Prev, New, TrUserData); - sub_opts -> merge_msg_sub_opts(Prev, New, TrUserData) - end. - --compile({nowarn_unused_function,merge_msg_provider_loaded_request/3}). -merge_msg_provider_loaded_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{broker := PFbroker}, #{broker := NFbroker}} -> - S1#{broker => - merge_msg_broker_info(PFbroker, NFbroker, TrUserData)}; - {_, #{broker := NFbroker}} -> S1#{broker => NFbroker}; - {#{broker := PFbroker}, _} -> S1#{broker => PFbroker}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_loaded_response/3}). -merge_msg_loaded_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{hooks := PFhooks}, #{hooks := NFhooks}} -> - S1#{hooks => 'erlang_++'(PFhooks, NFhooks, TrUserData)}; - {_, #{hooks := NFhooks}} -> S1#{hooks => NFhooks}; - {#{hooks := PFhooks}, _} -> S1#{hooks => PFhooks}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_provider_unloaded_request/3}). -merge_msg_provider_unloaded_request(_Prev, New, - _TrUserData) -> - New. - --compile({nowarn_unused_function,merge_msg_client_connect_request/3}). -merge_msg_client_connect_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{conninfo := PFconninfo}, - #{conninfo := NFconninfo}} -> - S1#{conninfo => - merge_msg_conn_info(PFconninfo, - NFconninfo, - TrUserData)}; - {_, #{conninfo := NFconninfo}} -> - S1#{conninfo => NFconninfo}; - {#{conninfo := PFconninfo}, _} -> - S1#{conninfo => PFconninfo}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {#{props := PFprops}, #{props := NFprops}} -> - S2#{props => 'erlang_++'(PFprops, NFprops, TrUserData)}; - {_, #{props := NFprops}} -> S2#{props => NFprops}; - {#{props := PFprops}, _} -> S2#{props => PFprops}; - {_, _} -> S2 - end. - --compile({nowarn_unused_function,merge_msg_client_connack_request/3}). -merge_msg_client_connack_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{conninfo := PFconninfo}, - #{conninfo := NFconninfo}} -> - S1#{conninfo => - merge_msg_conn_info(PFconninfo, - NFconninfo, - TrUserData)}; - {_, #{conninfo := NFconninfo}} -> - S1#{conninfo => NFconninfo}; - {#{conninfo := PFconninfo}, _} -> - S1#{conninfo => PFconninfo}; - {_, _} -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{result_code := NFresult_code}} -> - S2#{result_code => NFresult_code}; - {#{result_code := PFresult_code}, _} -> - S2#{result_code => PFresult_code}; - _ -> S2 - end, - case {PMsg, NMsg} of - {#{props := PFprops}, #{props := NFprops}} -> - S3#{props => 'erlang_++'(PFprops, NFprops, TrUserData)}; - {_, #{props := NFprops}} -> S3#{props => NFprops}; - {#{props := PFprops}, _} -> S3#{props => PFprops}; - {_, _} -> S3 - end. - --compile({nowarn_unused_function,merge_msg_client_connected_request/3}). -merge_msg_client_connected_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{clientinfo := PFclientinfo}, - #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => - merge_msg_client_info(PFclientinfo, - NFclientinfo, - TrUserData)}; - {_, #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => NFclientinfo}; - {#{clientinfo := PFclientinfo}, _} -> - S1#{clientinfo => PFclientinfo}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_client_disconnected_request/3}). -merge_msg_client_disconnected_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{clientinfo := PFclientinfo}, - #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => - merge_msg_client_info(PFclientinfo, - NFclientinfo, - TrUserData)}; - {_, #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => NFclientinfo}; - {#{clientinfo := PFclientinfo}, _} -> - S1#{clientinfo => PFclientinfo}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{reason := NFreason}} -> S2#{reason => NFreason}; - {#{reason := PFreason}, _} -> S2#{reason => PFreason}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_client_authenticate_request/3}). -merge_msg_client_authenticate_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{clientinfo := PFclientinfo}, - #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => - merge_msg_client_info(PFclientinfo, - NFclientinfo, - TrUserData)}; - {_, #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => NFclientinfo}; - {#{clientinfo := PFclientinfo}, _} -> - S1#{clientinfo => PFclientinfo}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{result := NFresult}} -> S2#{result => NFresult}; - {#{result := PFresult}, _} -> S2#{result => PFresult}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_client_check_acl_request/3}). -merge_msg_client_check_acl_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{clientinfo := PFclientinfo}, - #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => - merge_msg_client_info(PFclientinfo, - NFclientinfo, - TrUserData)}; - {_, #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => NFclientinfo}; - {#{clientinfo := PFclientinfo}, _} -> - S1#{clientinfo => PFclientinfo}; - {_, _} -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{type := NFtype}} -> S2#{type => NFtype}; - {#{type := PFtype}, _} -> S2#{type => PFtype}; - _ -> S2 - end, - S4 = case {PMsg, NMsg} of - {_, #{topic := NFtopic}} -> S3#{topic => NFtopic}; - {#{topic := PFtopic}, _} -> S3#{topic => PFtopic}; - _ -> S3 - end, - case {PMsg, NMsg} of - {_, #{result := NFresult}} -> S4#{result => NFresult}; - {#{result := PFresult}, _} -> S4#{result => PFresult}; - _ -> S4 - end. - --compile({nowarn_unused_function,merge_msg_client_subscribe_request/3}). -merge_msg_client_subscribe_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{clientinfo := PFclientinfo}, - #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => - merge_msg_client_info(PFclientinfo, - NFclientinfo, - TrUserData)}; - {_, #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => NFclientinfo}; - {#{clientinfo := PFclientinfo}, _} -> - S1#{clientinfo => PFclientinfo}; - {_, _} -> S1 - end, - S3 = case {PMsg, NMsg} of - {#{props := PFprops}, #{props := NFprops}} -> - S2#{props => 'erlang_++'(PFprops, NFprops, TrUserData)}; - {_, #{props := NFprops}} -> S2#{props => NFprops}; - {#{props := PFprops}, _} -> S2#{props => PFprops}; - {_, _} -> S2 - end, - case {PMsg, NMsg} of - {#{topic_filters := PFtopic_filters}, - #{topic_filters := NFtopic_filters}} -> - S3#{topic_filters => - 'erlang_++'(PFtopic_filters, - NFtopic_filters, - TrUserData)}; - {_, #{topic_filters := NFtopic_filters}} -> - S3#{topic_filters => NFtopic_filters}; - {#{topic_filters := PFtopic_filters}, _} -> - S3#{topic_filters => PFtopic_filters}; - {_, _} -> S3 - end. - --compile({nowarn_unused_function,merge_msg_client_unsubscribe_request/3}). -merge_msg_client_unsubscribe_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{clientinfo := PFclientinfo}, - #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => - merge_msg_client_info(PFclientinfo, - NFclientinfo, - TrUserData)}; - {_, #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => NFclientinfo}; - {#{clientinfo := PFclientinfo}, _} -> - S1#{clientinfo => PFclientinfo}; - {_, _} -> S1 - end, - S3 = case {PMsg, NMsg} of - {#{props := PFprops}, #{props := NFprops}} -> - S2#{props => 'erlang_++'(PFprops, NFprops, TrUserData)}; - {_, #{props := NFprops}} -> S2#{props => NFprops}; - {#{props := PFprops}, _} -> S2#{props => PFprops}; - {_, _} -> S2 - end, - case {PMsg, NMsg} of - {#{topic_filters := PFtopic_filters}, - #{topic_filters := NFtopic_filters}} -> - S3#{topic_filters => - 'erlang_++'(PFtopic_filters, - NFtopic_filters, - TrUserData)}; - {_, #{topic_filters := NFtopic_filters}} -> - S3#{topic_filters => NFtopic_filters}; - {#{topic_filters := PFtopic_filters}, _} -> - S3#{topic_filters => PFtopic_filters}; - {_, _} -> S3 - end. - --compile({nowarn_unused_function,merge_msg_session_created_request/3}). -merge_msg_session_created_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{clientinfo := PFclientinfo}, - #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => - merge_msg_client_info(PFclientinfo, - NFclientinfo, - TrUserData)}; - {_, #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => NFclientinfo}; - {#{clientinfo := PFclientinfo}, _} -> - S1#{clientinfo => PFclientinfo}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_session_subscribed_request/3}). -merge_msg_session_subscribed_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{clientinfo := PFclientinfo}, - #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => - merge_msg_client_info(PFclientinfo, - NFclientinfo, - TrUserData)}; - {_, #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => NFclientinfo}; - {#{clientinfo := PFclientinfo}, _} -> - S1#{clientinfo => PFclientinfo}; - {_, _} -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{topic := NFtopic}} -> S2#{topic => NFtopic}; - {#{topic := PFtopic}, _} -> S2#{topic => PFtopic}; - _ -> S2 - end, - case {PMsg, NMsg} of - {#{subopts := PFsubopts}, #{subopts := NFsubopts}} -> - S3#{subopts => - merge_msg_sub_opts(PFsubopts, NFsubopts, TrUserData)}; - {_, #{subopts := NFsubopts}} -> - S3#{subopts => NFsubopts}; - {#{subopts := PFsubopts}, _} -> - S3#{subopts => PFsubopts}; - {_, _} -> S3 - end. - --compile({nowarn_unused_function,merge_msg_session_unsubscribed_request/3}). -merge_msg_session_unsubscribed_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{clientinfo := PFclientinfo}, - #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => - merge_msg_client_info(PFclientinfo, - NFclientinfo, - TrUserData)}; - {_, #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => NFclientinfo}; - {#{clientinfo := PFclientinfo}, _} -> - S1#{clientinfo => PFclientinfo}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{topic := NFtopic}} -> S2#{topic => NFtopic}; - {#{topic := PFtopic}, _} -> S2#{topic => PFtopic}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_session_resumed_request/3}). -merge_msg_session_resumed_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{clientinfo := PFclientinfo}, - #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => - merge_msg_client_info(PFclientinfo, - NFclientinfo, - TrUserData)}; - {_, #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => NFclientinfo}; - {#{clientinfo := PFclientinfo}, _} -> - S1#{clientinfo => PFclientinfo}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_session_discarded_request/3}). -merge_msg_session_discarded_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{clientinfo := PFclientinfo}, - #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => - merge_msg_client_info(PFclientinfo, - NFclientinfo, - TrUserData)}; - {_, #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => NFclientinfo}; - {#{clientinfo := PFclientinfo}, _} -> - S1#{clientinfo => PFclientinfo}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_session_takeovered_request/3}). -merge_msg_session_takeovered_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{clientinfo := PFclientinfo}, - #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => - merge_msg_client_info(PFclientinfo, - NFclientinfo, - TrUserData)}; - {_, #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => NFclientinfo}; - {#{clientinfo := PFclientinfo}, _} -> - S1#{clientinfo => PFclientinfo}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_session_terminated_request/3}). -merge_msg_session_terminated_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{clientinfo := PFclientinfo}, - #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => - merge_msg_client_info(PFclientinfo, - NFclientinfo, - TrUserData)}; - {_, #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => NFclientinfo}; - {#{clientinfo := PFclientinfo}, _} -> - S1#{clientinfo => PFclientinfo}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{reason := NFreason}} -> S2#{reason => NFreason}; - {#{reason := PFreason}, _} -> S2#{reason => PFreason}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_message_publish_request/3}). -merge_msg_message_publish_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{message := PFmessage}, #{message := NFmessage}} -> - S1#{message => - merge_msg_message(PFmessage, NFmessage, TrUserData)}; - {_, #{message := NFmessage}} -> - S1#{message => NFmessage}; - {#{message := PFmessage}, _} -> - S1#{message => PFmessage}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_message_delivered_request/3}). -merge_msg_message_delivered_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{clientinfo := PFclientinfo}, - #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => - merge_msg_client_info(PFclientinfo, - NFclientinfo, - TrUserData)}; - {_, #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => NFclientinfo}; - {#{clientinfo := PFclientinfo}, _} -> - S1#{clientinfo => PFclientinfo}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {#{message := PFmessage}, #{message := NFmessage}} -> - S2#{message => - merge_msg_message(PFmessage, NFmessage, TrUserData)}; - {_, #{message := NFmessage}} -> - S2#{message => NFmessage}; - {#{message := PFmessage}, _} -> - S2#{message => PFmessage}; - {_, _} -> S2 - end. - --compile({nowarn_unused_function,merge_msg_message_dropped_request/3}). -merge_msg_message_dropped_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{message := PFmessage}, #{message := NFmessage}} -> - S1#{message => - merge_msg_message(PFmessage, NFmessage, TrUserData)}; - {_, #{message := NFmessage}} -> - S1#{message => NFmessage}; - {#{message := PFmessage}, _} -> - S1#{message => PFmessage}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{reason := NFreason}} -> S2#{reason => NFreason}; - {#{reason := PFreason}, _} -> S2#{reason => PFreason}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_message_acked_request/3}). -merge_msg_message_acked_request(PMsg, NMsg, - TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{clientinfo := PFclientinfo}, - #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => - merge_msg_client_info(PFclientinfo, - NFclientinfo, - TrUserData)}; - {_, #{clientinfo := NFclientinfo}} -> - S1#{clientinfo => NFclientinfo}; - {#{clientinfo := PFclientinfo}, _} -> - S1#{clientinfo => PFclientinfo}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {#{message := PFmessage}, #{message := NFmessage}} -> - S2#{message => - merge_msg_message(PFmessage, NFmessage, TrUserData)}; - {_, #{message := NFmessage}} -> - S2#{message => NFmessage}; - {#{message := PFmessage}, _} -> - S2#{message => PFmessage}; - {_, _} -> S2 - end. - --compile({nowarn_unused_function,merge_msg_empty_success/3}). -merge_msg_empty_success(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,merge_msg_valued_response/3}). -merge_msg_valued_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{type := NFtype}} -> S1#{type => NFtype}; - {#{type := PFtype}, _} -> S1#{type => PFtype}; - _ -> S1 - end, - case {PMsg, NMsg} of - {#{value := {message, OPFvalue}}, - #{value := {message, ONFvalue}}} -> - S2#{value => - {message, - merge_msg_message(OPFvalue, ONFvalue, TrUserData)}}; - {_, #{value := NFvalue}} -> S2#{value => NFvalue}; - {#{value := PFvalue}, _} -> S2#{value => PFvalue}; - {_, _} -> S2 - end. - --compile({nowarn_unused_function,merge_msg_broker_info/3}). -merge_msg_broker_info(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{version := NFversion}} -> - S1#{version => NFversion}; - {#{version := PFversion}, _} -> - S1#{version => PFversion}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{sysdescr := NFsysdescr}} -> - S2#{sysdescr => NFsysdescr}; - {#{sysdescr := PFsysdescr}, _} -> - S2#{sysdescr => PFsysdescr}; - _ -> S2 - end, - S4 = case {PMsg, NMsg} of - {_, #{uptime := NFuptime}} -> S3#{uptime => NFuptime}; - {#{uptime := PFuptime}, _} -> S3#{uptime => PFuptime}; - _ -> S3 - end, - case {PMsg, NMsg} of - {_, #{datetime := NFdatetime}} -> - S4#{datetime => NFdatetime}; - {#{datetime := PFdatetime}, _} -> - S4#{datetime => PFdatetime}; - _ -> S4 - end. - --compile({nowarn_unused_function,merge_msg_hook_spec/3}). -merge_msg_hook_spec(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{name := NFname}} -> S1#{name => NFname}; - {#{name := PFname}, _} -> S1#{name => PFname}; - _ -> S1 - end, - case {PMsg, NMsg} of - {#{topics := PFtopics}, #{topics := NFtopics}} -> - S2#{topics => - 'erlang_++'(PFtopics, NFtopics, TrUserData)}; - {_, #{topics := NFtopics}} -> S2#{topics => NFtopics}; - {#{topics := PFtopics}, _} -> S2#{topics => PFtopics}; - {_, _} -> S2 - end. - --compile({nowarn_unused_function,merge_msg_conn_info/3}). -merge_msg_conn_info(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{node := NFnode}} -> S1#{node => NFnode}; - {#{node := PFnode}, _} -> S1#{node => PFnode}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{clientid := NFclientid}} -> - S2#{clientid => NFclientid}; - {#{clientid := PFclientid}, _} -> - S2#{clientid => PFclientid}; - _ -> S2 - end, - S4 = case {PMsg, NMsg} of - {_, #{username := NFusername}} -> - S3#{username => NFusername}; - {#{username := PFusername}, _} -> - S3#{username => PFusername}; - _ -> S3 - end, - S5 = case {PMsg, NMsg} of - {_, #{peerhost := NFpeerhost}} -> - S4#{peerhost => NFpeerhost}; - {#{peerhost := PFpeerhost}, _} -> - S4#{peerhost => PFpeerhost}; - _ -> S4 - end, - S6 = case {PMsg, NMsg} of - {_, #{sockport := NFsockport}} -> - S5#{sockport => NFsockport}; - {#{sockport := PFsockport}, _} -> - S5#{sockport => PFsockport}; - _ -> S5 - end, - S7 = case {PMsg, NMsg} of - {_, #{proto_name := NFproto_name}} -> - S6#{proto_name => NFproto_name}; - {#{proto_name := PFproto_name}, _} -> - S6#{proto_name => PFproto_name}; - _ -> S6 - end, - S8 = case {PMsg, NMsg} of - {_, #{proto_ver := NFproto_ver}} -> - S7#{proto_ver => NFproto_ver}; - {#{proto_ver := PFproto_ver}, _} -> - S7#{proto_ver => PFproto_ver}; - _ -> S7 - end, - case {PMsg, NMsg} of - {_, #{keepalive := NFkeepalive}} -> - S8#{keepalive => NFkeepalive}; - {#{keepalive := PFkeepalive}, _} -> - S8#{keepalive => PFkeepalive}; - _ -> S8 - end. - --compile({nowarn_unused_function,merge_msg_client_info/3}). -merge_msg_client_info(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{node := NFnode}} -> S1#{node => NFnode}; - {#{node := PFnode}, _} -> S1#{node => PFnode}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{clientid := NFclientid}} -> - S2#{clientid => NFclientid}; - {#{clientid := PFclientid}, _} -> - S2#{clientid => PFclientid}; - _ -> S2 - end, - S4 = case {PMsg, NMsg} of - {_, #{username := NFusername}} -> - S3#{username => NFusername}; - {#{username := PFusername}, _} -> - S3#{username => PFusername}; - _ -> S3 - end, - S5 = case {PMsg, NMsg} of - {_, #{password := NFpassword}} -> - S4#{password => NFpassword}; - {#{password := PFpassword}, _} -> - S4#{password => PFpassword}; - _ -> S4 - end, - S6 = case {PMsg, NMsg} of - {_, #{peerhost := NFpeerhost}} -> - S5#{peerhost => NFpeerhost}; - {#{peerhost := PFpeerhost}, _} -> - S5#{peerhost => PFpeerhost}; - _ -> S5 - end, - S7 = case {PMsg, NMsg} of - {_, #{sockport := NFsockport}} -> - S6#{sockport => NFsockport}; - {#{sockport := PFsockport}, _} -> - S6#{sockport => PFsockport}; - _ -> S6 - end, - S8 = case {PMsg, NMsg} of - {_, #{protocol := NFprotocol}} -> - S7#{protocol => NFprotocol}; - {#{protocol := PFprotocol}, _} -> - S7#{protocol => PFprotocol}; - _ -> S7 - end, - S9 = case {PMsg, NMsg} of - {_, #{mountpoint := NFmountpoint}} -> - S8#{mountpoint => NFmountpoint}; - {#{mountpoint := PFmountpoint}, _} -> - S8#{mountpoint => PFmountpoint}; - _ -> S8 - end, - S10 = case {PMsg, NMsg} of - {_, #{is_superuser := NFis_superuser}} -> - S9#{is_superuser => NFis_superuser}; - {#{is_superuser := PFis_superuser}, _} -> - S9#{is_superuser => PFis_superuser}; - _ -> S9 - end, - S11 = case {PMsg, NMsg} of - {_, #{anonymous := NFanonymous}} -> - S10#{anonymous => NFanonymous}; - {#{anonymous := PFanonymous}, _} -> - S10#{anonymous => PFanonymous}; - _ -> S10 - end, - S12 = case {PMsg, NMsg} of - {_, #{cn := NFcn}} -> S11#{cn => NFcn}; - {#{cn := PFcn}, _} -> S11#{cn => PFcn}; - _ -> S11 - end, - case {PMsg, NMsg} of - {_, #{dn := NFdn}} -> S12#{dn => NFdn}; - {#{dn := PFdn}, _} -> S12#{dn => PFdn}; - _ -> S12 - end. - --compile({nowarn_unused_function,merge_msg_message/3}). -merge_msg_message(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{node := NFnode}} -> S1#{node => NFnode}; - {#{node := PFnode}, _} -> S1#{node => PFnode}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{id := NFid}} -> S2#{id => NFid}; - {#{id := PFid}, _} -> S2#{id => PFid}; - _ -> S2 - end, - S4 = case {PMsg, NMsg} of - {_, #{qos := NFqos}} -> S3#{qos => NFqos}; - {#{qos := PFqos}, _} -> S3#{qos => PFqos}; - _ -> S3 - end, - S5 = case {PMsg, NMsg} of - {_, #{from := NFfrom}} -> S4#{from => NFfrom}; - {#{from := PFfrom}, _} -> S4#{from => PFfrom}; - _ -> S4 - end, - S6 = case {PMsg, NMsg} of - {_, #{topic := NFtopic}} -> S5#{topic => NFtopic}; - {#{topic := PFtopic}, _} -> S5#{topic => PFtopic}; - _ -> S5 - end, - S7 = case {PMsg, NMsg} of - {_, #{payload := NFpayload}} -> - S6#{payload => NFpayload}; - {#{payload := PFpayload}, _} -> - S6#{payload => PFpayload}; - _ -> S6 - end, - case {PMsg, NMsg} of - {_, #{timestamp := NFtimestamp}} -> - S7#{timestamp => NFtimestamp}; - {#{timestamp := PFtimestamp}, _} -> - S7#{timestamp => PFtimestamp}; - _ -> S7 - end. - --compile({nowarn_unused_function,merge_msg_property/3}). -merge_msg_property(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{name := NFname}} -> S1#{name => NFname}; - {#{name := PFname}, _} -> S1#{name => PFname}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{value := NFvalue}} -> S2#{value => NFvalue}; - {#{value := PFvalue}, _} -> S2#{value => PFvalue}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_topic_filter/3}). -merge_msg_topic_filter(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{name := NFname}} -> S1#{name => NFname}; - {#{name := PFname}, _} -> S1#{name => PFname}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{qos := NFqos}} -> S2#{qos => NFqos}; - {#{qos := PFqos}, _} -> S2#{qos => PFqos}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_sub_opts/3}). -merge_msg_sub_opts(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{qos := NFqos}} -> S1#{qos => NFqos}; - {#{qos := PFqos}, _} -> S1#{qos => PFqos}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{share := NFshare}} -> S2#{share => NFshare}; - {#{share := PFshare}, _} -> S2#{share => PFshare}; - _ -> S2 - end, - S4 = case {PMsg, NMsg} of - {_, #{rh := NFrh}} -> S3#{rh => NFrh}; - {#{rh := PFrh}, _} -> S3#{rh => PFrh}; - _ -> S3 - end, - S5 = case {PMsg, NMsg} of - {_, #{rap := NFrap}} -> S4#{rap => NFrap}; - {#{rap := PFrap}, _} -> S4#{rap => PFrap}; - _ -> S4 - end, - case {PMsg, NMsg} of - {_, #{nl := NFnl}} -> S5#{nl => NFnl}; - {#{nl := PFnl}, _} -> S5#{nl => PFnl}; - _ -> S5 - end. - - -verify_msg(Msg, MsgName) when is_atom(MsgName) -> - verify_msg(Msg, MsgName, []). - -verify_msg(Msg, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - provider_loaded_request -> - v_msg_provider_loaded_request(Msg, - [MsgName], - TrUserData); - loaded_response -> - v_msg_loaded_response(Msg, [MsgName], TrUserData); - provider_unloaded_request -> - v_msg_provider_unloaded_request(Msg, - [MsgName], - TrUserData); - client_connect_request -> - v_msg_client_connect_request(Msg, - [MsgName], - TrUserData); - client_connack_request -> - v_msg_client_connack_request(Msg, - [MsgName], - TrUserData); - client_connected_request -> - v_msg_client_connected_request(Msg, - [MsgName], - TrUserData); - client_disconnected_request -> - v_msg_client_disconnected_request(Msg, - [MsgName], - TrUserData); - client_authenticate_request -> - v_msg_client_authenticate_request(Msg, - [MsgName], - TrUserData); - client_check_acl_request -> - v_msg_client_check_acl_request(Msg, - [MsgName], - TrUserData); - client_subscribe_request -> - v_msg_client_subscribe_request(Msg, - [MsgName], - TrUserData); - client_unsubscribe_request -> - v_msg_client_unsubscribe_request(Msg, - [MsgName], - TrUserData); - session_created_request -> - v_msg_session_created_request(Msg, - [MsgName], - TrUserData); - session_subscribed_request -> - v_msg_session_subscribed_request(Msg, - [MsgName], - TrUserData); - session_unsubscribed_request -> - v_msg_session_unsubscribed_request(Msg, - [MsgName], - TrUserData); - session_resumed_request -> - v_msg_session_resumed_request(Msg, - [MsgName], - TrUserData); - session_discarded_request -> - v_msg_session_discarded_request(Msg, - [MsgName], - TrUserData); - session_takeovered_request -> - v_msg_session_takeovered_request(Msg, - [MsgName], - TrUserData); - session_terminated_request -> - v_msg_session_terminated_request(Msg, - [MsgName], - TrUserData); - message_publish_request -> - v_msg_message_publish_request(Msg, - [MsgName], - TrUserData); - message_delivered_request -> - v_msg_message_delivered_request(Msg, - [MsgName], - TrUserData); - message_dropped_request -> - v_msg_message_dropped_request(Msg, - [MsgName], - TrUserData); - message_acked_request -> - v_msg_message_acked_request(Msg, [MsgName], TrUserData); - empty_success -> - v_msg_empty_success(Msg, [MsgName], TrUserData); - valued_response -> - v_msg_valued_response(Msg, [MsgName], TrUserData); - broker_info -> - v_msg_broker_info(Msg, [MsgName], TrUserData); - hook_spec -> - v_msg_hook_spec(Msg, [MsgName], TrUserData); - conn_info -> - v_msg_conn_info(Msg, [MsgName], TrUserData); - client_info -> - v_msg_client_info(Msg, [MsgName], TrUserData); - message -> v_msg_message(Msg, [MsgName], TrUserData); - property -> v_msg_property(Msg, [MsgName], TrUserData); - topic_filter -> - v_msg_topic_filter(Msg, [MsgName], TrUserData); - sub_opts -> v_msg_sub_opts(Msg, [MsgName], TrUserData); - _ -> mk_type_error(not_a_known_message, Msg, []) - end. - - --compile({nowarn_unused_function,v_msg_provider_loaded_request/3}). --dialyzer({nowarn_function,v_msg_provider_loaded_request/3}). -v_msg_provider_loaded_request(#{} = M, Path, - TrUserData) -> - case M of - #{broker := F1} -> - v_msg_broker_info(F1, [broker | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (broker) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_provider_loaded_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - provider_loaded_request}, - M, - Path); -v_msg_provider_loaded_request(X, Path, _TrUserData) -> - mk_type_error({expected_msg, provider_loaded_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_loaded_response/3}). --dialyzer({nowarn_function,v_msg_loaded_response/3}). -v_msg_loaded_response(#{} = M, Path, TrUserData) -> - case M of - #{hooks := F1} -> - if is_list(F1) -> - _ = [v_msg_hook_spec(Elem, [hooks | Path], TrUserData) - || Elem <- F1], - ok; - true -> - mk_type_error({invalid_list_of, {msg, hook_spec}}, - F1, - [hooks | Path]) - end; - _ -> ok - end, - lists:foreach(fun (hooks) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_loaded_response(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - loaded_response}, - M, - Path); -v_msg_loaded_response(X, Path, _TrUserData) -> - mk_type_error({expected_msg, loaded_response}, X, Path). - --compile({nowarn_unused_function,v_msg_provider_unloaded_request/3}). --dialyzer({nowarn_function,v_msg_provider_unloaded_request/3}). -v_msg_provider_unloaded_request(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_provider_unloaded_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - provider_unloaded_request}, - M, - Path); -v_msg_provider_unloaded_request(X, Path, _TrUserData) -> - mk_type_error({expected_msg, provider_unloaded_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_client_connect_request/3}). --dialyzer({nowarn_function,v_msg_client_connect_request/3}). -v_msg_client_connect_request(#{} = M, Path, - TrUserData) -> - case M of - #{conninfo := F1} -> - v_msg_conn_info(F1, [conninfo | Path], TrUserData); - _ -> ok - end, - case M of - #{props := F2} -> - if is_list(F2) -> - _ = [v_msg_property(Elem, [props | Path], TrUserData) - || Elem <- F2], - ok; - true -> - mk_type_error({invalid_list_of, {msg, property}}, - F2, - [props | Path]) - end; - _ -> ok - end, - lists:foreach(fun (conninfo) -> ok; - (props) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_client_connect_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - client_connect_request}, - M, - Path); -v_msg_client_connect_request(X, Path, _TrUserData) -> - mk_type_error({expected_msg, client_connect_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_client_connack_request/3}). --dialyzer({nowarn_function,v_msg_client_connack_request/3}). -v_msg_client_connack_request(#{} = M, Path, - TrUserData) -> - case M of - #{conninfo := F1} -> - v_msg_conn_info(F1, [conninfo | Path], TrUserData); - _ -> ok - end, - case M of - #{result_code := F2} -> - v_type_string(F2, [result_code | Path], TrUserData); - _ -> ok - end, - case M of - #{props := F3} -> - if is_list(F3) -> - _ = [v_msg_property(Elem, [props | Path], TrUserData) - || Elem <- F3], - ok; - true -> - mk_type_error({invalid_list_of, {msg, property}}, - F3, - [props | Path]) - end; - _ -> ok - end, - lists:foreach(fun (conninfo) -> ok; - (result_code) -> ok; - (props) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_client_connack_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - client_connack_request}, - M, - Path); -v_msg_client_connack_request(X, Path, _TrUserData) -> - mk_type_error({expected_msg, client_connack_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_client_connected_request/3}). --dialyzer({nowarn_function,v_msg_client_connected_request/3}). -v_msg_client_connected_request(#{} = M, Path, - TrUserData) -> - case M of - #{clientinfo := F1} -> - v_msg_client_info(F1, [clientinfo | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (clientinfo) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_client_connected_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - client_connected_request}, - M, - Path); -v_msg_client_connected_request(X, Path, _TrUserData) -> - mk_type_error({expected_msg, client_connected_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_client_disconnected_request/3}). --dialyzer({nowarn_function,v_msg_client_disconnected_request/3}). -v_msg_client_disconnected_request(#{} = M, Path, - TrUserData) -> - case M of - #{clientinfo := F1} -> - v_msg_client_info(F1, [clientinfo | Path], TrUserData); - _ -> ok - end, - case M of - #{reason := F2} -> - v_type_string(F2, [reason | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (clientinfo) -> ok; - (reason) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_client_disconnected_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - client_disconnected_request}, - M, - Path); -v_msg_client_disconnected_request(X, Path, - _TrUserData) -> - mk_type_error({expected_msg, - client_disconnected_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_client_authenticate_request/3}). --dialyzer({nowarn_function,v_msg_client_authenticate_request/3}). -v_msg_client_authenticate_request(#{} = M, Path, - TrUserData) -> - case M of - #{clientinfo := F1} -> - v_msg_client_info(F1, [clientinfo | Path], TrUserData); - _ -> ok - end, - case M of - #{result := F2} -> - v_type_bool(F2, [result | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (clientinfo) -> ok; - (result) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_client_authenticate_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - client_authenticate_request}, - M, - Path); -v_msg_client_authenticate_request(X, Path, - _TrUserData) -> - mk_type_error({expected_msg, - client_authenticate_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_client_check_acl_request/3}). --dialyzer({nowarn_function,v_msg_client_check_acl_request/3}). -v_msg_client_check_acl_request(#{} = M, Path, - TrUserData) -> - case M of - #{clientinfo := F1} -> - v_msg_client_info(F1, [clientinfo | Path], TrUserData); - _ -> ok - end, - case M of - #{type := F2} -> - 'v_enum_client_check_acl_request.AclReqType'(F2, - [type | Path], - TrUserData); - _ -> ok - end, - case M of - #{topic := F3} -> - v_type_string(F3, [topic | Path], TrUserData); - _ -> ok - end, - case M of - #{result := F4} -> - v_type_bool(F4, [result | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (clientinfo) -> ok; - (type) -> ok; - (topic) -> ok; - (result) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_client_check_acl_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - client_check_acl_request}, - M, - Path); -v_msg_client_check_acl_request(X, Path, _TrUserData) -> - mk_type_error({expected_msg, client_check_acl_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_client_subscribe_request/3}). --dialyzer({nowarn_function,v_msg_client_subscribe_request/3}). -v_msg_client_subscribe_request(#{} = M, Path, - TrUserData) -> - case M of - #{clientinfo := F1} -> - v_msg_client_info(F1, [clientinfo | Path], TrUserData); - _ -> ok - end, - case M of - #{props := F2} -> - if is_list(F2) -> - _ = [v_msg_property(Elem, [props | Path], TrUserData) - || Elem <- F2], - ok; - true -> - mk_type_error({invalid_list_of, {msg, property}}, - F2, - [props | Path]) - end; - _ -> ok - end, - case M of - #{topic_filters := F3} -> - if is_list(F3) -> - _ = [v_msg_topic_filter(Elem, - [topic_filters | Path], - TrUserData) - || Elem <- F3], - ok; - true -> - mk_type_error({invalid_list_of, {msg, topic_filter}}, - F3, - [topic_filters | Path]) - end; - _ -> ok - end, - lists:foreach(fun (clientinfo) -> ok; - (props) -> ok; - (topic_filters) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_client_subscribe_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - client_subscribe_request}, - M, - Path); -v_msg_client_subscribe_request(X, Path, _TrUserData) -> - mk_type_error({expected_msg, client_subscribe_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_client_unsubscribe_request/3}). --dialyzer({nowarn_function,v_msg_client_unsubscribe_request/3}). -v_msg_client_unsubscribe_request(#{} = M, Path, - TrUserData) -> - case M of - #{clientinfo := F1} -> - v_msg_client_info(F1, [clientinfo | Path], TrUserData); - _ -> ok - end, - case M of - #{props := F2} -> - if is_list(F2) -> - _ = [v_msg_property(Elem, [props | Path], TrUserData) - || Elem <- F2], - ok; - true -> - mk_type_error({invalid_list_of, {msg, property}}, - F2, - [props | Path]) - end; - _ -> ok - end, - case M of - #{topic_filters := F3} -> - if is_list(F3) -> - _ = [v_msg_topic_filter(Elem, - [topic_filters | Path], - TrUserData) - || Elem <- F3], - ok; - true -> - mk_type_error({invalid_list_of, {msg, topic_filter}}, - F3, - [topic_filters | Path]) - end; - _ -> ok - end, - lists:foreach(fun (clientinfo) -> ok; - (props) -> ok; - (topic_filters) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_client_unsubscribe_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - client_unsubscribe_request}, - M, - Path); -v_msg_client_unsubscribe_request(X, Path, - _TrUserData) -> - mk_type_error({expected_msg, - client_unsubscribe_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_session_created_request/3}). --dialyzer({nowarn_function,v_msg_session_created_request/3}). -v_msg_session_created_request(#{} = M, Path, - TrUserData) -> - case M of - #{clientinfo := F1} -> - v_msg_client_info(F1, [clientinfo | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (clientinfo) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_session_created_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - session_created_request}, - M, - Path); -v_msg_session_created_request(X, Path, _TrUserData) -> - mk_type_error({expected_msg, session_created_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_session_subscribed_request/3}). --dialyzer({nowarn_function,v_msg_session_subscribed_request/3}). -v_msg_session_subscribed_request(#{} = M, Path, - TrUserData) -> - case M of - #{clientinfo := F1} -> - v_msg_client_info(F1, [clientinfo | Path], TrUserData); - _ -> ok - end, - case M of - #{topic := F2} -> - v_type_string(F2, [topic | Path], TrUserData); - _ -> ok - end, - case M of - #{subopts := F3} -> - v_msg_sub_opts(F3, [subopts | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (clientinfo) -> ok; - (topic) -> ok; - (subopts) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_session_subscribed_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - session_subscribed_request}, - M, - Path); -v_msg_session_subscribed_request(X, Path, - _TrUserData) -> - mk_type_error({expected_msg, - session_subscribed_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_session_unsubscribed_request/3}). --dialyzer({nowarn_function,v_msg_session_unsubscribed_request/3}). -v_msg_session_unsubscribed_request(#{} = M, Path, - TrUserData) -> - case M of - #{clientinfo := F1} -> - v_msg_client_info(F1, [clientinfo | Path], TrUserData); - _ -> ok - end, - case M of - #{topic := F2} -> - v_type_string(F2, [topic | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (clientinfo) -> ok; - (topic) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_session_unsubscribed_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - session_unsubscribed_request}, - M, - Path); -v_msg_session_unsubscribed_request(X, Path, - _TrUserData) -> - mk_type_error({expected_msg, - session_unsubscribed_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_session_resumed_request/3}). --dialyzer({nowarn_function,v_msg_session_resumed_request/3}). -v_msg_session_resumed_request(#{} = M, Path, - TrUserData) -> - case M of - #{clientinfo := F1} -> - v_msg_client_info(F1, [clientinfo | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (clientinfo) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_session_resumed_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - session_resumed_request}, - M, - Path); -v_msg_session_resumed_request(X, Path, _TrUserData) -> - mk_type_error({expected_msg, session_resumed_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_session_discarded_request/3}). --dialyzer({nowarn_function,v_msg_session_discarded_request/3}). -v_msg_session_discarded_request(#{} = M, Path, - TrUserData) -> - case M of - #{clientinfo := F1} -> - v_msg_client_info(F1, [clientinfo | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (clientinfo) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_session_discarded_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - session_discarded_request}, - M, - Path); -v_msg_session_discarded_request(X, Path, _TrUserData) -> - mk_type_error({expected_msg, session_discarded_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_session_takeovered_request/3}). --dialyzer({nowarn_function,v_msg_session_takeovered_request/3}). -v_msg_session_takeovered_request(#{} = M, Path, - TrUserData) -> - case M of - #{clientinfo := F1} -> - v_msg_client_info(F1, [clientinfo | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (clientinfo) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_session_takeovered_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - session_takeovered_request}, - M, - Path); -v_msg_session_takeovered_request(X, Path, - _TrUserData) -> - mk_type_error({expected_msg, - session_takeovered_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_session_terminated_request/3}). --dialyzer({nowarn_function,v_msg_session_terminated_request/3}). -v_msg_session_terminated_request(#{} = M, Path, - TrUserData) -> - case M of - #{clientinfo := F1} -> - v_msg_client_info(F1, [clientinfo | Path], TrUserData); - _ -> ok - end, - case M of - #{reason := F2} -> - v_type_string(F2, [reason | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (clientinfo) -> ok; - (reason) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_session_terminated_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - session_terminated_request}, - M, - Path); -v_msg_session_terminated_request(X, Path, - _TrUserData) -> - mk_type_error({expected_msg, - session_terminated_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_message_publish_request/3}). --dialyzer({nowarn_function,v_msg_message_publish_request/3}). -v_msg_message_publish_request(#{} = M, Path, - TrUserData) -> - case M of - #{message := F1} -> - v_msg_message(F1, [message | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (message) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_message_publish_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - message_publish_request}, - M, - Path); -v_msg_message_publish_request(X, Path, _TrUserData) -> - mk_type_error({expected_msg, message_publish_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_message_delivered_request/3}). --dialyzer({nowarn_function,v_msg_message_delivered_request/3}). -v_msg_message_delivered_request(#{} = M, Path, - TrUserData) -> - case M of - #{clientinfo := F1} -> - v_msg_client_info(F1, [clientinfo | Path], TrUserData); - _ -> ok - end, - case M of - #{message := F2} -> - v_msg_message(F2, [message | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (clientinfo) -> ok; - (message) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_message_delivered_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - message_delivered_request}, - M, - Path); -v_msg_message_delivered_request(X, Path, _TrUserData) -> - mk_type_error({expected_msg, message_delivered_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_message_dropped_request/3}). --dialyzer({nowarn_function,v_msg_message_dropped_request/3}). -v_msg_message_dropped_request(#{} = M, Path, - TrUserData) -> - case M of - #{message := F1} -> - v_msg_message(F1, [message | Path], TrUserData); - _ -> ok - end, - case M of - #{reason := F2} -> - v_type_string(F2, [reason | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (message) -> ok; - (reason) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_message_dropped_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - message_dropped_request}, - M, - Path); -v_msg_message_dropped_request(X, Path, _TrUserData) -> - mk_type_error({expected_msg, message_dropped_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_message_acked_request/3}). --dialyzer({nowarn_function,v_msg_message_acked_request/3}). -v_msg_message_acked_request(#{} = M, Path, - TrUserData) -> - case M of - #{clientinfo := F1} -> - v_msg_client_info(F1, [clientinfo | Path], TrUserData); - _ -> ok - end, - case M of - #{message := F2} -> - v_msg_message(F2, [message | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (clientinfo) -> ok; - (message) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_message_acked_request(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - message_acked_request}, - M, - Path); -v_msg_message_acked_request(X, Path, _TrUserData) -> - mk_type_error({expected_msg, message_acked_request}, - X, - Path). - --compile({nowarn_unused_function,v_msg_empty_success/3}). --dialyzer({nowarn_function,v_msg_empty_success/3}). -v_msg_empty_success(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_empty_success(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - empty_success}, - M, - Path); -v_msg_empty_success(X, Path, _TrUserData) -> - mk_type_error({expected_msg, empty_success}, X, Path). - --compile({nowarn_unused_function,v_msg_valued_response/3}). --dialyzer({nowarn_function,v_msg_valued_response/3}). -v_msg_valued_response(#{} = M, Path, TrUserData) -> - case M of - #{type := F1} -> - 'v_enum_valued_response.ResponsedType'(F1, - [type | Path], - TrUserData); - _ -> ok - end, - case M of - #{value := {bool_result, OF2}} -> - v_type_bool(OF2, - [bool_result, value | Path], - TrUserData); - #{value := {message, OF2}} -> - v_msg_message(OF2, [message, value | Path], TrUserData); - #{value := F2} -> - mk_type_error(invalid_oneof, F2, [value | Path]); - _ -> ok - end, - lists:foreach(fun (type) -> ok; - (value) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_valued_response(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - valued_response}, - M, - Path); -v_msg_valued_response(X, Path, _TrUserData) -> - mk_type_error({expected_msg, valued_response}, X, Path). - --compile({nowarn_unused_function,v_msg_broker_info/3}). --dialyzer({nowarn_function,v_msg_broker_info/3}). -v_msg_broker_info(#{} = M, Path, TrUserData) -> - case M of - #{version := F1} -> - v_type_string(F1, [version | Path], TrUserData); - _ -> ok - end, - case M of - #{sysdescr := F2} -> - v_type_string(F2, [sysdescr | Path], TrUserData); - _ -> ok - end, - case M of - #{uptime := F3} -> - v_type_string(F3, [uptime | Path], TrUserData); - _ -> ok - end, - case M of - #{datetime := F4} -> - v_type_string(F4, [datetime | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (version) -> ok; - (sysdescr) -> ok; - (uptime) -> ok; - (datetime) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_broker_info(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - broker_info}, - M, - Path); -v_msg_broker_info(X, Path, _TrUserData) -> - mk_type_error({expected_msg, broker_info}, X, Path). - --compile({nowarn_unused_function,v_msg_hook_spec/3}). --dialyzer({nowarn_function,v_msg_hook_spec/3}). -v_msg_hook_spec(#{} = M, Path, TrUserData) -> - case M of - #{name := F1} -> - v_type_string(F1, [name | Path], TrUserData); - _ -> ok - end, - case M of - #{topics := F2} -> - if is_list(F2) -> - _ = [v_type_string(Elem, [topics | Path], TrUserData) - || Elem <- F2], - ok; - true -> - mk_type_error({invalid_list_of, string}, - F2, - [topics | Path]) - end; - _ -> ok - end, - lists:foreach(fun (name) -> ok; - (topics) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_hook_spec(M, Path, _TrUserData) when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - hook_spec}, - M, - Path); -v_msg_hook_spec(X, Path, _TrUserData) -> - mk_type_error({expected_msg, hook_spec}, X, Path). - --compile({nowarn_unused_function,v_msg_conn_info/3}). --dialyzer({nowarn_function,v_msg_conn_info/3}). -v_msg_conn_info(#{} = M, Path, TrUserData) -> - case M of - #{node := F1} -> - v_type_string(F1, [node | Path], TrUserData); - _ -> ok - end, - case M of - #{clientid := F2} -> - v_type_string(F2, [clientid | Path], TrUserData); - _ -> ok - end, - case M of - #{username := F3} -> - v_type_string(F3, [username | Path], TrUserData); - _ -> ok - end, - case M of - #{peerhost := F4} -> - v_type_string(F4, [peerhost | Path], TrUserData); - _ -> ok - end, - case M of - #{sockport := F5} -> - v_type_uint32(F5, [sockport | Path], TrUserData); - _ -> ok - end, - case M of - #{proto_name := F6} -> - v_type_string(F6, [proto_name | Path], TrUserData); - _ -> ok - end, - case M of - #{proto_ver := F7} -> - v_type_string(F7, [proto_ver | Path], TrUserData); - _ -> ok - end, - case M of - #{keepalive := F8} -> - v_type_uint32(F8, [keepalive | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (node) -> ok; - (clientid) -> ok; - (username) -> ok; - (peerhost) -> ok; - (sockport) -> ok; - (proto_name) -> ok; - (proto_ver) -> ok; - (keepalive) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_conn_info(M, Path, _TrUserData) when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - conn_info}, - M, - Path); -v_msg_conn_info(X, Path, _TrUserData) -> - mk_type_error({expected_msg, conn_info}, X, Path). - --compile({nowarn_unused_function,v_msg_client_info/3}). --dialyzer({nowarn_function,v_msg_client_info/3}). -v_msg_client_info(#{} = M, Path, TrUserData) -> - case M of - #{node := F1} -> - v_type_string(F1, [node | Path], TrUserData); - _ -> ok - end, - case M of - #{clientid := F2} -> - v_type_string(F2, [clientid | Path], TrUserData); - _ -> ok - end, - case M of - #{username := F3} -> - v_type_string(F3, [username | Path], TrUserData); - _ -> ok - end, - case M of - #{password := F4} -> - v_type_string(F4, [password | Path], TrUserData); - _ -> ok - end, - case M of - #{peerhost := F5} -> - v_type_string(F5, [peerhost | Path], TrUserData); - _ -> ok - end, - case M of - #{sockport := F6} -> - v_type_uint32(F6, [sockport | Path], TrUserData); - _ -> ok - end, - case M of - #{protocol := F7} -> - v_type_string(F7, [protocol | Path], TrUserData); - _ -> ok - end, - case M of - #{mountpoint := F8} -> - v_type_string(F8, [mountpoint | Path], TrUserData); - _ -> ok - end, - case M of - #{is_superuser := F9} -> - v_type_bool(F9, [is_superuser | Path], TrUserData); - _ -> ok - end, - case M of - #{anonymous := F10} -> - v_type_bool(F10, [anonymous | Path], TrUserData); - _ -> ok - end, - case M of - #{cn := F11} -> - v_type_string(F11, [cn | Path], TrUserData); - _ -> ok - end, - case M of - #{dn := F12} -> - v_type_string(F12, [dn | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (node) -> ok; - (clientid) -> ok; - (username) -> ok; - (password) -> ok; - (peerhost) -> ok; - (sockport) -> ok; - (protocol) -> ok; - (mountpoint) -> ok; - (is_superuser) -> ok; - (anonymous) -> ok; - (cn) -> ok; - (dn) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_client_info(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - client_info}, - M, - Path); -v_msg_client_info(X, Path, _TrUserData) -> - mk_type_error({expected_msg, client_info}, X, Path). - --compile({nowarn_unused_function,v_msg_message/3}). --dialyzer({nowarn_function,v_msg_message/3}). -v_msg_message(#{} = M, Path, TrUserData) -> - case M of - #{node := F1} -> - v_type_string(F1, [node | Path], TrUserData); - _ -> ok - end, - case M of - #{id := F2} -> - v_type_string(F2, [id | Path], TrUserData); - _ -> ok - end, - case M of - #{qos := F3} -> - v_type_uint32(F3, [qos | Path], TrUserData); - _ -> ok - end, - case M of - #{from := F4} -> - v_type_string(F4, [from | Path], TrUserData); - _ -> ok - end, - case M of - #{topic := F5} -> - v_type_string(F5, [topic | Path], TrUserData); - _ -> ok - end, - case M of - #{payload := F6} -> - v_type_bytes(F6, [payload | Path], TrUserData); - _ -> ok - end, - case M of - #{timestamp := F7} -> - v_type_uint64(F7, [timestamp | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (node) -> ok; - (id) -> ok; - (qos) -> ok; - (from) -> ok; - (topic) -> ok; - (payload) -> ok; - (timestamp) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_message(M, Path, _TrUserData) when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - message}, - M, - Path); -v_msg_message(X, Path, _TrUserData) -> - mk_type_error({expected_msg, message}, X, Path). - --compile({nowarn_unused_function,v_msg_property/3}). --dialyzer({nowarn_function,v_msg_property/3}). -v_msg_property(#{} = M, Path, TrUserData) -> - case M of - #{name := F1} -> - v_type_string(F1, [name | Path], TrUserData); - _ -> ok - end, - case M of - #{value := F2} -> - v_type_string(F2, [value | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (name) -> ok; - (value) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_property(M, Path, _TrUserData) when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - property}, - M, - Path); -v_msg_property(X, Path, _TrUserData) -> - mk_type_error({expected_msg, property}, X, Path). - --compile({nowarn_unused_function,v_msg_topic_filter/3}). --dialyzer({nowarn_function,v_msg_topic_filter/3}). -v_msg_topic_filter(#{} = M, Path, TrUserData) -> - case M of - #{name := F1} -> - v_type_string(F1, [name | Path], TrUserData); - _ -> ok - end, - case M of - #{qos := F2} -> - v_type_uint32(F2, [qos | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (name) -> ok; - (qos) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_topic_filter(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - topic_filter}, - M, - Path); -v_msg_topic_filter(X, Path, _TrUserData) -> - mk_type_error({expected_msg, topic_filter}, X, Path). - --compile({nowarn_unused_function,v_msg_sub_opts/3}). --dialyzer({nowarn_function,v_msg_sub_opts/3}). -v_msg_sub_opts(#{} = M, Path, TrUserData) -> - case M of - #{qos := F1} -> - v_type_uint32(F1, [qos | Path], TrUserData); - _ -> ok - end, - case M of - #{share := F2} -> - v_type_string(F2, [share | Path], TrUserData); - _ -> ok - end, - case M of - #{rh := F3} -> - v_type_uint32(F3, [rh | Path], TrUserData); - _ -> ok - end, - case M of - #{rap := F4} -> - v_type_uint32(F4, [rap | Path], TrUserData); - _ -> ok - end, - case M of - #{nl := F5} -> - v_type_uint32(F5, [nl | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (qos) -> ok; - (share) -> ok; - (rh) -> ok; - (rap) -> ok; - (nl) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_sub_opts(M, Path, _TrUserData) when is_map(M) -> - mk_type_error({missing_fields, - [] -- maps:keys(M), - sub_opts}, - M, - Path); -v_msg_sub_opts(X, Path, _TrUserData) -> - mk_type_error({expected_msg, sub_opts}, X, Path). - --compile({nowarn_unused_function,'v_enum_client_check_acl_request.AclReqType'/3}). --dialyzer({nowarn_function,'v_enum_client_check_acl_request.AclReqType'/3}). -'v_enum_client_check_acl_request.AclReqType'('PUBLISH', - _Path, _TrUserData) -> - ok; -'v_enum_client_check_acl_request.AclReqType'('SUBSCRIBE', - _Path, _TrUserData) -> - ok; -'v_enum_client_check_acl_request.AclReqType'(V, Path, - TrUserData) - when is_integer(V) -> - v_type_sint32(V, Path, TrUserData); -'v_enum_client_check_acl_request.AclReqType'(X, Path, - _TrUserData) -> - mk_type_error({invalid_enum, - 'client_check_acl_request.AclReqType'}, - X, - Path). - --compile({nowarn_unused_function,'v_enum_valued_response.ResponsedType'/3}). --dialyzer({nowarn_function,'v_enum_valued_response.ResponsedType'/3}). -'v_enum_valued_response.ResponsedType'('CONTINUE', - _Path, _TrUserData) -> - ok; -'v_enum_valued_response.ResponsedType'('IGNORE', _Path, - _TrUserData) -> - ok; -'v_enum_valued_response.ResponsedType'('STOP_AND_RETURN', - _Path, _TrUserData) -> - ok; -'v_enum_valued_response.ResponsedType'(V, Path, - TrUserData) - when is_integer(V) -> - v_type_sint32(V, Path, TrUserData); -'v_enum_valued_response.ResponsedType'(X, Path, - _TrUserData) -> - mk_type_error({invalid_enum, - 'valued_response.ResponsedType'}, - X, - Path). - --compile({nowarn_unused_function,v_type_sint32/3}). --dialyzer({nowarn_function,v_type_sint32/3}). -v_type_sint32(N, _Path, _TrUserData) - when -2147483648 =< N, N =< 2147483647 -> - ok; -v_type_sint32(N, Path, _TrUserData) - when is_integer(N) -> - mk_type_error({value_out_of_range, sint32, signed, 32}, - N, - Path); -v_type_sint32(X, Path, _TrUserData) -> - mk_type_error({bad_integer, sint32, signed, 32}, - X, - Path). - --compile({nowarn_unused_function,v_type_uint32/3}). --dialyzer({nowarn_function,v_type_uint32/3}). -v_type_uint32(N, _Path, _TrUserData) - when 0 =< N, N =< 4294967295 -> - ok; -v_type_uint32(N, Path, _TrUserData) - when is_integer(N) -> - mk_type_error({value_out_of_range, - uint32, - unsigned, - 32}, - N, - Path); -v_type_uint32(X, Path, _TrUserData) -> - mk_type_error({bad_integer, uint32, unsigned, 32}, - X, - Path). - --compile({nowarn_unused_function,v_type_uint64/3}). --dialyzer({nowarn_function,v_type_uint64/3}). -v_type_uint64(N, _Path, _TrUserData) - when 0 =< N, N =< 18446744073709551615 -> - ok; -v_type_uint64(N, Path, _TrUserData) - when is_integer(N) -> - mk_type_error({value_out_of_range, - uint64, - unsigned, - 64}, - N, - Path); -v_type_uint64(X, Path, _TrUserData) -> - mk_type_error({bad_integer, uint64, unsigned, 64}, - X, - Path). - --compile({nowarn_unused_function,v_type_bool/3}). --dialyzer({nowarn_function,v_type_bool/3}). -v_type_bool(false, _Path, _TrUserData) -> ok; -v_type_bool(true, _Path, _TrUserData) -> ok; -v_type_bool(0, _Path, _TrUserData) -> ok; -v_type_bool(1, _Path, _TrUserData) -> ok; -v_type_bool(X, Path, _TrUserData) -> - mk_type_error(bad_boolean_value, X, Path). - --compile({nowarn_unused_function,v_type_string/3}). --dialyzer({nowarn_function,v_type_string/3}). -v_type_string(S, Path, _TrUserData) - when is_list(S); is_binary(S) -> - try unicode:characters_to_binary(S) of - B when is_binary(B) -> ok; - {error, _, _} -> - mk_type_error(bad_unicode_string, S, Path) - catch - error:badarg -> - mk_type_error(bad_unicode_string, S, Path) - end; -v_type_string(X, Path, _TrUserData) -> - mk_type_error(bad_unicode_string, X, Path). - --compile({nowarn_unused_function,v_type_bytes/3}). --dialyzer({nowarn_function,v_type_bytes/3}). -v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> - ok; -v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> - ok; -v_type_bytes(X, Path, _TrUserData) -> - mk_type_error(bad_binary_value, X, Path). - --compile({nowarn_unused_function,mk_type_error/3}). --spec mk_type_error(_, _, list()) -> no_return(). -mk_type_error(Error, ValueSeen, Path) -> - Path2 = prettify_path(Path), - erlang:error({gpb_type_error, - {Error, [{value, ValueSeen}, {path, Path2}]}}). - - --compile({nowarn_unused_function,prettify_path/1}). --dialyzer({nowarn_function,prettify_path/1}). -prettify_path([]) -> top_level; -prettify_path(PathR) -> - list_to_atom(lists:append(lists:join(".", - lists:map(fun atom_to_list/1, - lists:reverse(PathR))))). - - --compile({nowarn_unused_function,id/2}). --compile({inline,id/2}). -id(X, _TrUserData) -> X. - --compile({nowarn_unused_function,v_ok/3}). --compile({inline,v_ok/3}). -v_ok(_Value, _Path, _TrUserData) -> ok. - --compile({nowarn_unused_function,m_overwrite/3}). --compile({inline,m_overwrite/3}). -m_overwrite(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,cons/3}). --compile({inline,cons/3}). -cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. - --compile({nowarn_unused_function,lists_reverse/2}). --compile({inline,lists_reverse/2}). -'lists_reverse'(L, _TrUserData) -> lists:reverse(L). --compile({nowarn_unused_function,'erlang_++'/3}). --compile({inline,'erlang_++'/3}). -'erlang_++'(A, B, _TrUserData) -> A ++ B. - - -get_msg_defs() -> - [{{enum, 'client_check_acl_request.AclReqType'}, - [{'PUBLISH', 0}, {'SUBSCRIBE', 1}]}, - {{enum, 'valued_response.ResponsedType'}, - [{'CONTINUE', 0}, - {'IGNORE', 1}, - {'STOP_AND_RETURN', 2}]}, - {{msg, provider_loaded_request}, - [#{name => broker, fnum => 1, rnum => 2, - type => {msg, broker_info}, occurrence => optional, - opts => []}]}, - {{msg, loaded_response}, - [#{name => hooks, fnum => 1, rnum => 2, - type => {msg, hook_spec}, occurrence => repeated, - opts => []}]}, - {{msg, provider_unloaded_request}, []}, - {{msg, client_connect_request}, - [#{name => conninfo, fnum => 1, rnum => 2, - type => {msg, conn_info}, occurrence => optional, - opts => []}, - #{name => props, fnum => 2, rnum => 3, - type => {msg, property}, occurrence => repeated, - opts => []}]}, - {{msg, client_connack_request}, - [#{name => conninfo, fnum => 1, rnum => 2, - type => {msg, conn_info}, occurrence => optional, - opts => []}, - #{name => result_code, fnum => 2, rnum => 3, - type => string, occurrence => optional, opts => []}, - #{name => props, fnum => 3, rnum => 4, - type => {msg, property}, occurrence => repeated, - opts => []}]}, - {{msg, client_connected_request}, - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}]}, - {{msg, client_disconnected_request}, - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => reason, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}]}, - {{msg, client_authenticate_request}, - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => result, fnum => 2, rnum => 3, type => bool, - occurrence => optional, opts => []}]}, - {{msg, client_check_acl_request}, - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => type, fnum => 2, rnum => 3, - type => {enum, 'client_check_acl_request.AclReqType'}, - occurrence => optional, opts => []}, - #{name => topic, fnum => 3, rnum => 4, type => string, - occurrence => optional, opts => []}, - #{name => result, fnum => 4, rnum => 5, type => bool, - occurrence => optional, opts => []}]}, - {{msg, client_subscribe_request}, - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => props, fnum => 2, rnum => 3, - type => {msg, property}, occurrence => repeated, - opts => []}, - #{name => topic_filters, fnum => 3, rnum => 4, - type => {msg, topic_filter}, occurrence => repeated, - opts => []}]}, - {{msg, client_unsubscribe_request}, - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => props, fnum => 2, rnum => 3, - type => {msg, property}, occurrence => repeated, - opts => []}, - #{name => topic_filters, fnum => 3, rnum => 4, - type => {msg, topic_filter}, occurrence => repeated, - opts => []}]}, - {{msg, session_created_request}, - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}]}, - {{msg, session_subscribed_request}, - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => topic, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}, - #{name => subopts, fnum => 3, rnum => 4, - type => {msg, sub_opts}, occurrence => optional, - opts => []}]}, - {{msg, session_unsubscribed_request}, - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => topic, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}]}, - {{msg, session_resumed_request}, - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}]}, - {{msg, session_discarded_request}, - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}]}, - {{msg, session_takeovered_request}, - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}]}, - {{msg, session_terminated_request}, - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => reason, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}]}, - {{msg, message_publish_request}, - [#{name => message, fnum => 1, rnum => 2, - type => {msg, message}, occurrence => optional, - opts => []}]}, - {{msg, message_delivered_request}, - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => message, fnum => 2, rnum => 3, - type => {msg, message}, occurrence => optional, - opts => []}]}, - {{msg, message_dropped_request}, - [#{name => message, fnum => 1, rnum => 2, - type => {msg, message}, occurrence => optional, - opts => []}, - #{name => reason, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}]}, - {{msg, message_acked_request}, - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => message, fnum => 2, rnum => 3, - type => {msg, message}, occurrence => optional, - opts => []}]}, - {{msg, empty_success}, []}, - {{msg, valued_response}, - [#{name => type, fnum => 1, rnum => 2, - type => {enum, 'valued_response.ResponsedType'}, - occurrence => optional, opts => []}, - #{name => value, rnum => 3, - fields => - [#{name => bool_result, fnum => 3, rnum => 3, - type => bool, occurrence => optional, opts => []}, - #{name => message, fnum => 4, rnum => 3, - type => {msg, message}, occurrence => optional, - opts => []}]}]}, - {{msg, broker_info}, - [#{name => version, fnum => 1, rnum => 2, - type => string, occurrence => optional, opts => []}, - #{name => sysdescr, fnum => 2, rnum => 3, - type => string, occurrence => optional, opts => []}, - #{name => uptime, fnum => 3, rnum => 4, type => string, - occurrence => optional, opts => []}, - #{name => datetime, fnum => 4, rnum => 5, - type => string, occurrence => optional, opts => []}]}, - {{msg, hook_spec}, - [#{name => name, fnum => 1, rnum => 2, type => string, - occurrence => optional, opts => []}, - #{name => topics, fnum => 2, rnum => 3, type => string, - occurrence => repeated, opts => []}]}, - {{msg, conn_info}, - [#{name => node, fnum => 1, rnum => 2, type => string, - occurrence => optional, opts => []}, - #{name => clientid, fnum => 2, rnum => 3, - type => string, occurrence => optional, opts => []}, - #{name => username, fnum => 3, rnum => 4, - type => string, occurrence => optional, opts => []}, - #{name => peerhost, fnum => 4, rnum => 5, - type => string, occurrence => optional, opts => []}, - #{name => sockport, fnum => 5, rnum => 6, - type => uint32, occurrence => optional, opts => []}, - #{name => proto_name, fnum => 6, rnum => 7, - type => string, occurrence => optional, opts => []}, - #{name => proto_ver, fnum => 7, rnum => 8, - type => string, occurrence => optional, opts => []}, - #{name => keepalive, fnum => 8, rnum => 9, - type => uint32, occurrence => optional, opts => []}]}, - {{msg, client_info}, - [#{name => node, fnum => 1, rnum => 2, type => string, - occurrence => optional, opts => []}, - #{name => clientid, fnum => 2, rnum => 3, - type => string, occurrence => optional, opts => []}, - #{name => username, fnum => 3, rnum => 4, - type => string, occurrence => optional, opts => []}, - #{name => password, fnum => 4, rnum => 5, - type => string, occurrence => optional, opts => []}, - #{name => peerhost, fnum => 5, rnum => 6, - type => string, occurrence => optional, opts => []}, - #{name => sockport, fnum => 6, rnum => 7, - type => uint32, occurrence => optional, opts => []}, - #{name => protocol, fnum => 7, rnum => 8, - type => string, occurrence => optional, opts => []}, - #{name => mountpoint, fnum => 8, rnum => 9, - type => string, occurrence => optional, opts => []}, - #{name => is_superuser, fnum => 9, rnum => 10, - type => bool, occurrence => optional, opts => []}, - #{name => anonymous, fnum => 10, rnum => 11, - type => bool, occurrence => optional, opts => []}, - #{name => cn, fnum => 11, rnum => 12, type => string, - occurrence => optional, opts => []}, - #{name => dn, fnum => 12, rnum => 13, type => string, - occurrence => optional, opts => []}]}, - {{msg, message}, - [#{name => node, fnum => 1, rnum => 2, type => string, - occurrence => optional, opts => []}, - #{name => id, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}, - #{name => qos, fnum => 3, rnum => 4, type => uint32, - occurrence => optional, opts => []}, - #{name => from, fnum => 4, rnum => 5, type => string, - occurrence => optional, opts => []}, - #{name => topic, fnum => 5, rnum => 6, type => string, - occurrence => optional, opts => []}, - #{name => payload, fnum => 6, rnum => 7, type => bytes, - occurrence => optional, opts => []}, - #{name => timestamp, fnum => 7, rnum => 8, - type => uint64, occurrence => optional, opts => []}]}, - {{msg, property}, - [#{name => name, fnum => 1, rnum => 2, type => string, - occurrence => optional, opts => []}, - #{name => value, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}]}, - {{msg, topic_filter}, - [#{name => name, fnum => 1, rnum => 2, type => string, - occurrence => optional, opts => []}, - #{name => qos, fnum => 2, rnum => 3, type => uint32, - occurrence => optional, opts => []}]}, - {{msg, sub_opts}, - [#{name => qos, fnum => 1, rnum => 2, type => uint32, - occurrence => optional, opts => []}, - #{name => share, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}, - #{name => rh, fnum => 3, rnum => 4, type => uint32, - occurrence => optional, opts => []}, - #{name => rap, fnum => 4, rnum => 5, type => uint32, - occurrence => optional, opts => []}, - #{name => nl, fnum => 5, rnum => 6, type => uint32, - occurrence => optional, opts => []}]}]. - - -get_msg_names() -> - [provider_loaded_request, - loaded_response, - provider_unloaded_request, - client_connect_request, - client_connack_request, - client_connected_request, - client_disconnected_request, - client_authenticate_request, - client_check_acl_request, - client_subscribe_request, - client_unsubscribe_request, - session_created_request, - session_subscribed_request, - session_unsubscribed_request, - session_resumed_request, - session_discarded_request, - session_takeovered_request, - session_terminated_request, - message_publish_request, - message_delivered_request, - message_dropped_request, - message_acked_request, - empty_success, - valued_response, - broker_info, - hook_spec, - conn_info, - client_info, - message, - property, - topic_filter, - sub_opts]. - - -get_group_names() -> []. - - -get_msg_or_group_names() -> - [provider_loaded_request, - loaded_response, - provider_unloaded_request, - client_connect_request, - client_connack_request, - client_connected_request, - client_disconnected_request, - client_authenticate_request, - client_check_acl_request, - client_subscribe_request, - client_unsubscribe_request, - session_created_request, - session_subscribed_request, - session_unsubscribed_request, - session_resumed_request, - session_discarded_request, - session_takeovered_request, - session_terminated_request, - message_publish_request, - message_delivered_request, - message_dropped_request, - message_acked_request, - empty_success, - valued_response, - broker_info, - hook_spec, - conn_info, - client_info, - message, - property, - topic_filter, - sub_opts]. - - -get_enum_names() -> - ['client_check_acl_request.AclReqType', - 'valued_response.ResponsedType']. - - -fetch_msg_def(MsgName) -> - case find_msg_def(MsgName) of - Fs when is_list(Fs) -> Fs; - error -> erlang:error({no_such_msg, MsgName}) - end. - - -fetch_enum_def(EnumName) -> - case find_enum_def(EnumName) of - Es when is_list(Es) -> Es; - error -> erlang:error({no_such_enum, EnumName}) - end. - - -find_msg_def(provider_loaded_request) -> - [#{name => broker, fnum => 1, rnum => 2, - type => {msg, broker_info}, occurrence => optional, - opts => []}]; -find_msg_def(loaded_response) -> - [#{name => hooks, fnum => 1, rnum => 2, - type => {msg, hook_spec}, occurrence => repeated, - opts => []}]; -find_msg_def(provider_unloaded_request) -> []; -find_msg_def(client_connect_request) -> - [#{name => conninfo, fnum => 1, rnum => 2, - type => {msg, conn_info}, occurrence => optional, - opts => []}, - #{name => props, fnum => 2, rnum => 3, - type => {msg, property}, occurrence => repeated, - opts => []}]; -find_msg_def(client_connack_request) -> - [#{name => conninfo, fnum => 1, rnum => 2, - type => {msg, conn_info}, occurrence => optional, - opts => []}, - #{name => result_code, fnum => 2, rnum => 3, - type => string, occurrence => optional, opts => []}, - #{name => props, fnum => 3, rnum => 4, - type => {msg, property}, occurrence => repeated, - opts => []}]; -find_msg_def(client_connected_request) -> - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}]; -find_msg_def(client_disconnected_request) -> - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => reason, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}]; -find_msg_def(client_authenticate_request) -> - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => result, fnum => 2, rnum => 3, type => bool, - occurrence => optional, opts => []}]; -find_msg_def(client_check_acl_request) -> - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => type, fnum => 2, rnum => 3, - type => {enum, 'client_check_acl_request.AclReqType'}, - occurrence => optional, opts => []}, - #{name => topic, fnum => 3, rnum => 4, type => string, - occurrence => optional, opts => []}, - #{name => result, fnum => 4, rnum => 5, type => bool, - occurrence => optional, opts => []}]; -find_msg_def(client_subscribe_request) -> - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => props, fnum => 2, rnum => 3, - type => {msg, property}, occurrence => repeated, - opts => []}, - #{name => topic_filters, fnum => 3, rnum => 4, - type => {msg, topic_filter}, occurrence => repeated, - opts => []}]; -find_msg_def(client_unsubscribe_request) -> - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => props, fnum => 2, rnum => 3, - type => {msg, property}, occurrence => repeated, - opts => []}, - #{name => topic_filters, fnum => 3, rnum => 4, - type => {msg, topic_filter}, occurrence => repeated, - opts => []}]; -find_msg_def(session_created_request) -> - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}]; -find_msg_def(session_subscribed_request) -> - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => topic, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}, - #{name => subopts, fnum => 3, rnum => 4, - type => {msg, sub_opts}, occurrence => optional, - opts => []}]; -find_msg_def(session_unsubscribed_request) -> - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => topic, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}]; -find_msg_def(session_resumed_request) -> - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}]; -find_msg_def(session_discarded_request) -> - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}]; -find_msg_def(session_takeovered_request) -> - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}]; -find_msg_def(session_terminated_request) -> - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => reason, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}]; -find_msg_def(message_publish_request) -> - [#{name => message, fnum => 1, rnum => 2, - type => {msg, message}, occurrence => optional, - opts => []}]; -find_msg_def(message_delivered_request) -> - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => message, fnum => 2, rnum => 3, - type => {msg, message}, occurrence => optional, - opts => []}]; -find_msg_def(message_dropped_request) -> - [#{name => message, fnum => 1, rnum => 2, - type => {msg, message}, occurrence => optional, - opts => []}, - #{name => reason, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}]; -find_msg_def(message_acked_request) -> - [#{name => clientinfo, fnum => 1, rnum => 2, - type => {msg, client_info}, occurrence => optional, - opts => []}, - #{name => message, fnum => 2, rnum => 3, - type => {msg, message}, occurrence => optional, - opts => []}]; -find_msg_def(empty_success) -> []; -find_msg_def(valued_response) -> - [#{name => type, fnum => 1, rnum => 2, - type => {enum, 'valued_response.ResponsedType'}, - occurrence => optional, opts => []}, - #{name => value, rnum => 3, - fields => - [#{name => bool_result, fnum => 3, rnum => 3, - type => bool, occurrence => optional, opts => []}, - #{name => message, fnum => 4, rnum => 3, - type => {msg, message}, occurrence => optional, - opts => []}]}]; -find_msg_def(broker_info) -> - [#{name => version, fnum => 1, rnum => 2, - type => string, occurrence => optional, opts => []}, - #{name => sysdescr, fnum => 2, rnum => 3, - type => string, occurrence => optional, opts => []}, - #{name => uptime, fnum => 3, rnum => 4, type => string, - occurrence => optional, opts => []}, - #{name => datetime, fnum => 4, rnum => 5, - type => string, occurrence => optional, opts => []}]; -find_msg_def(hook_spec) -> - [#{name => name, fnum => 1, rnum => 2, type => string, - occurrence => optional, opts => []}, - #{name => topics, fnum => 2, rnum => 3, type => string, - occurrence => repeated, opts => []}]; -find_msg_def(conn_info) -> - [#{name => node, fnum => 1, rnum => 2, type => string, - occurrence => optional, opts => []}, - #{name => clientid, fnum => 2, rnum => 3, - type => string, occurrence => optional, opts => []}, - #{name => username, fnum => 3, rnum => 4, - type => string, occurrence => optional, opts => []}, - #{name => peerhost, fnum => 4, rnum => 5, - type => string, occurrence => optional, opts => []}, - #{name => sockport, fnum => 5, rnum => 6, - type => uint32, occurrence => optional, opts => []}, - #{name => proto_name, fnum => 6, rnum => 7, - type => string, occurrence => optional, opts => []}, - #{name => proto_ver, fnum => 7, rnum => 8, - type => string, occurrence => optional, opts => []}, - #{name => keepalive, fnum => 8, rnum => 9, - type => uint32, occurrence => optional, opts => []}]; -find_msg_def(client_info) -> - [#{name => node, fnum => 1, rnum => 2, type => string, - occurrence => optional, opts => []}, - #{name => clientid, fnum => 2, rnum => 3, - type => string, occurrence => optional, opts => []}, - #{name => username, fnum => 3, rnum => 4, - type => string, occurrence => optional, opts => []}, - #{name => password, fnum => 4, rnum => 5, - type => string, occurrence => optional, opts => []}, - #{name => peerhost, fnum => 5, rnum => 6, - type => string, occurrence => optional, opts => []}, - #{name => sockport, fnum => 6, rnum => 7, - type => uint32, occurrence => optional, opts => []}, - #{name => protocol, fnum => 7, rnum => 8, - type => string, occurrence => optional, opts => []}, - #{name => mountpoint, fnum => 8, rnum => 9, - type => string, occurrence => optional, opts => []}, - #{name => is_superuser, fnum => 9, rnum => 10, - type => bool, occurrence => optional, opts => []}, - #{name => anonymous, fnum => 10, rnum => 11, - type => bool, occurrence => optional, opts => []}, - #{name => cn, fnum => 11, rnum => 12, type => string, - occurrence => optional, opts => []}, - #{name => dn, fnum => 12, rnum => 13, type => string, - occurrence => optional, opts => []}]; -find_msg_def(message) -> - [#{name => node, fnum => 1, rnum => 2, type => string, - occurrence => optional, opts => []}, - #{name => id, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}, - #{name => qos, fnum => 3, rnum => 4, type => uint32, - occurrence => optional, opts => []}, - #{name => from, fnum => 4, rnum => 5, type => string, - occurrence => optional, opts => []}, - #{name => topic, fnum => 5, rnum => 6, type => string, - occurrence => optional, opts => []}, - #{name => payload, fnum => 6, rnum => 7, type => bytes, - occurrence => optional, opts => []}, - #{name => timestamp, fnum => 7, rnum => 8, - type => uint64, occurrence => optional, opts => []}]; -find_msg_def(property) -> - [#{name => name, fnum => 1, rnum => 2, type => string, - occurrence => optional, opts => []}, - #{name => value, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}]; -find_msg_def(topic_filter) -> - [#{name => name, fnum => 1, rnum => 2, type => string, - occurrence => optional, opts => []}, - #{name => qos, fnum => 2, rnum => 3, type => uint32, - occurrence => optional, opts => []}]; -find_msg_def(sub_opts) -> - [#{name => qos, fnum => 1, rnum => 2, type => uint32, - occurrence => optional, opts => []}, - #{name => share, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}, - #{name => rh, fnum => 3, rnum => 4, type => uint32, - occurrence => optional, opts => []}, - #{name => rap, fnum => 4, rnum => 5, type => uint32, - occurrence => optional, opts => []}, - #{name => nl, fnum => 5, rnum => 6, type => uint32, - occurrence => optional, opts => []}]; -find_msg_def(_) -> error. - - -find_enum_def('client_check_acl_request.AclReqType') -> - [{'PUBLISH', 0}, {'SUBSCRIBE', 1}]; -find_enum_def('valued_response.ResponsedType') -> - [{'CONTINUE', 0}, - {'IGNORE', 1}, - {'STOP_AND_RETURN', 2}]; -find_enum_def(_) -> error. - - -enum_symbol_by_value('client_check_acl_request.AclReqType', - Value) -> - 'enum_symbol_by_value_client_check_acl_request.AclReqType'(Value); -enum_symbol_by_value('valued_response.ResponsedType', - Value) -> - 'enum_symbol_by_value_valued_response.ResponsedType'(Value). - - -enum_value_by_symbol('client_check_acl_request.AclReqType', - Sym) -> - 'enum_value_by_symbol_client_check_acl_request.AclReqType'(Sym); -enum_value_by_symbol('valued_response.ResponsedType', - Sym) -> - 'enum_value_by_symbol_valued_response.ResponsedType'(Sym). - - -'enum_symbol_by_value_client_check_acl_request.AclReqType'(0) -> - 'PUBLISH'; -'enum_symbol_by_value_client_check_acl_request.AclReqType'(1) -> - 'SUBSCRIBE'. - - -'enum_value_by_symbol_client_check_acl_request.AclReqType'('PUBLISH') -> - 0; -'enum_value_by_symbol_client_check_acl_request.AclReqType'('SUBSCRIBE') -> - 1. - -'enum_symbol_by_value_valued_response.ResponsedType'(0) -> - 'CONTINUE'; -'enum_symbol_by_value_valued_response.ResponsedType'(1) -> - 'IGNORE'; -'enum_symbol_by_value_valued_response.ResponsedType'(2) -> - 'STOP_AND_RETURN'. - - -'enum_value_by_symbol_valued_response.ResponsedType'('CONTINUE') -> - 0; -'enum_value_by_symbol_valued_response.ResponsedType'('IGNORE') -> - 1; -'enum_value_by_symbol_valued_response.ResponsedType'('STOP_AND_RETURN') -> - 2. - - -get_service_names() -> ['dgiot.exhook.v1.HookProvider']. - - -get_service_def('dgiot.exhook.v1.HookProvider') -> - {{service, 'dgiot.exhook.v1.HookProvider'}, - [#{name => 'OnProviderLoaded', - input => provider_loaded_request, - output => loaded_response, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnProviderUnloaded', - input => provider_unloaded_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnClientConnect', - input => client_connect_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnClientConnack', - input => client_connack_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnClientConnected', - input => client_connected_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnClientDisconnected', - input => client_disconnected_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnClientAuthenticate', - input => client_authenticate_request, - output => valued_response, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnClientCheckAcl', - input => client_check_acl_request, - output => valued_response, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnClientSubscribe', - input => client_subscribe_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnClientUnsubscribe', - input => client_unsubscribe_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnSessionCreated', - input => session_created_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnSessionSubscribed', - input => session_subscribed_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnSessionUnsubscribed', - input => session_unsubscribed_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnSessionResumed', - input => session_resumed_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnSessionDiscarded', - input => session_discarded_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnSessionTakeovered', - input => session_takeovered_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnSessionTerminated', - input => session_terminated_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnMessagePublish', - input => message_publish_request, - output => valued_response, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnMessageDelivered', - input => message_delivered_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnMessageDropped', - input => message_dropped_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}, - #{name => 'OnMessageAcked', - input => message_acked_request, output => empty_success, - input_stream => false, output_stream => false, - opts => []}]}; -get_service_def(_) -> error. - - -get_rpc_names('dgiot.exhook.v1.HookProvider') -> - ['OnProviderLoaded', - 'OnProviderUnloaded', - 'OnClientConnect', - 'OnClientConnack', - 'OnClientConnected', - 'OnClientDisconnected', - 'OnClientAuthenticate', - 'OnClientCheckAcl', - 'OnClientSubscribe', - 'OnClientUnsubscribe', - 'OnSessionCreated', - 'OnSessionSubscribed', - 'OnSessionUnsubscribed', - 'OnSessionResumed', - 'OnSessionDiscarded', - 'OnSessionTakeovered', - 'OnSessionTerminated', - 'OnMessagePublish', - 'OnMessageDelivered', - 'OnMessageDropped', - 'OnMessageAcked']; -get_rpc_names(_) -> error. - - -find_rpc_def('dgiot.exhook.v1.HookProvider', RpcName) -> - 'find_rpc_def_dgiot.exhook.v1.HookProvider'(RpcName); -find_rpc_def(_, _) -> error. - - -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnProviderLoaded') -> - #{name => 'OnProviderLoaded', - input => provider_loaded_request, - output => loaded_response, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnProviderUnloaded') -> - #{name => 'OnProviderUnloaded', - input => provider_unloaded_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnClientConnect') -> - #{name => 'OnClientConnect', - input => client_connect_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnClientConnack') -> - #{name => 'OnClientConnack', - input => client_connack_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnClientConnected') -> - #{name => 'OnClientConnected', - input => client_connected_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnClientDisconnected') -> - #{name => 'OnClientDisconnected', - input => client_disconnected_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnClientAuthenticate') -> - #{name => 'OnClientAuthenticate', - input => client_authenticate_request, - output => valued_response, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnClientCheckAcl') -> - #{name => 'OnClientCheckAcl', - input => client_check_acl_request, - output => valued_response, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnClientSubscribe') -> - #{name => 'OnClientSubscribe', - input => client_subscribe_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnClientUnsubscribe') -> - #{name => 'OnClientUnsubscribe', - input => client_unsubscribe_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnSessionCreated') -> - #{name => 'OnSessionCreated', - input => session_created_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnSessionSubscribed') -> - #{name => 'OnSessionSubscribed', - input => session_subscribed_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnSessionUnsubscribed') -> - #{name => 'OnSessionUnsubscribed', - input => session_unsubscribed_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnSessionResumed') -> - #{name => 'OnSessionResumed', - input => session_resumed_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnSessionDiscarded') -> - #{name => 'OnSessionDiscarded', - input => session_discarded_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnSessionTakeovered') -> - #{name => 'OnSessionTakeovered', - input => session_takeovered_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnSessionTerminated') -> - #{name => 'OnSessionTerminated', - input => session_terminated_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnMessagePublish') -> - #{name => 'OnMessagePublish', - input => message_publish_request, - output => valued_response, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnMessageDelivered') -> - #{name => 'OnMessageDelivered', - input => message_delivered_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnMessageDropped') -> - #{name => 'OnMessageDropped', - input => message_dropped_request, - output => empty_success, input_stream => false, - output_stream => false, opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'('OnMessageAcked') -> - #{name => 'OnMessageAcked', - input => message_acked_request, output => empty_success, - input_stream => false, output_stream => false, - opts => []}; -'find_rpc_def_dgiot.exhook.v1.HookProvider'(_) -> error. - - -fetch_rpc_def(ServiceName, RpcName) -> - case find_rpc_def(ServiceName, RpcName) of - Def when is_map(Def) -> Def; - error -> - erlang:error({no_such_rpc, ServiceName, RpcName}) - end. - - -%% Convert a a fully qualified (ie with package name) service name -%% as a binary to a service name as an atom. -fqbin_to_service_name(<<"dgiot.exhook.v1.HookProvider">>) -> - 'dgiot.exhook.v1.HookProvider'; -fqbin_to_service_name(X) -> - error({gpb_error, {badservice, X}}). - - -%% Convert a service name as an atom to a fully qualified -%% (ie with package name) name as a binary. -service_name_to_fqbin('dgiot.exhook.v1.HookProvider') -> - <<"dgiot.exhook.v1.HookProvider">>; -service_name_to_fqbin(X) -> - error({gpb_error, {badservice, X}}). - - -%% Convert a a fully qualified (ie with package name) service name -%% and an rpc name, both as binaries to a service name and an rpc -%% name, as atoms. -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnProviderLoaded">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnProviderLoaded'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnProviderUnloaded">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnProviderUnloaded'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnClientConnect">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnClientConnect'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnClientConnack">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnClientConnack'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnClientConnected">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnClientConnected'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnClientDisconnected">>) -> - {'dgiot.exhook.v1.HookProvider', - 'OnClientDisconnected'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnClientAuthenticate">>) -> - {'dgiot.exhook.v1.HookProvider', - 'OnClientAuthenticate'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnClientCheckAcl">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnClientCheckAcl'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnClientSubscribe">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnClientSubscribe'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnClientUnsubscribe">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnClientUnsubscribe'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnSessionCreated">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnSessionCreated'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnSessionSubscribed">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnSessionSubscribed'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnSessionUnsubscribed">>) -> - {'dgiot.exhook.v1.HookProvider', - 'OnSessionUnsubscribed'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnSessionResumed">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnSessionResumed'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnSessionDiscarded">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnSessionDiscarded'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnSessionTakeovered">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnSessionTakeovered'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnSessionTerminated">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnSessionTerminated'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnMessagePublish">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnMessagePublish'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnMessageDelivered">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnMessageDelivered'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnMessageDropped">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnMessageDropped'}; -fqbins_to_service_and_rpc_name(<<"dgiot.exhook.v1.HookProvider">>, <<"OnMessageAcked">>) -> - {'dgiot.exhook.v1.HookProvider', 'OnMessageAcked'}; -fqbins_to_service_and_rpc_name(S, R) -> - error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -%% Convert a service name and an rpc name, both as atoms, -%% to a fully qualified (ie with package name) service name and -%% an rpc name as binaries. -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnProviderLoaded') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnProviderLoaded">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnProviderUnloaded') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnProviderUnloaded">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnClientConnect') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnClientConnect">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnClientConnack') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnClientConnack">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnClientConnected') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnClientConnected">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnClientDisconnected') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnClientDisconnected">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnClientAuthenticate') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnClientAuthenticate">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnClientCheckAcl') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnClientCheckAcl">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnClientSubscribe') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnClientSubscribe">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnClientUnsubscribe') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnClientUnsubscribe">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnSessionCreated') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnSessionCreated">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnSessionSubscribed') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnSessionSubscribed">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnSessionUnsubscribed') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnSessionUnsubscribed">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnSessionResumed') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnSessionResumed">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnSessionDiscarded') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnSessionDiscarded">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnSessionTakeovered') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnSessionTakeovered">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnSessionTerminated') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnSessionTerminated">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnMessagePublish') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnMessagePublish">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnMessageDelivered') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnMessageDelivered">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnMessageDropped') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnMessageDropped">>}; -service_and_rpc_name_to_fqbins('dgiot.exhook.v1.HookProvider', - 'OnMessageAcked') -> - {<<"dgiot.exhook.v1.HookProvider">>, <<"OnMessageAcked">>}; -service_and_rpc_name_to_fqbins(S, R) -> - error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -fqbin_to_msg_name(<<"dgiot.exhook.v1.ProviderLoadedRequest">>) -> provider_loaded_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.LoadedResponse">>) -> loaded_response; -fqbin_to_msg_name(<<"dgiot.exhook.v1.ProviderUnloadedRequest">>) -> provider_unloaded_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.ClientConnectRequest">>) -> client_connect_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.ClientConnackRequest">>) -> client_connack_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.ClientConnectedRequest">>) -> client_connected_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.ClientDisconnectedRequest">>) -> - client_disconnected_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.ClientAuthenticateRequest">>) -> - client_authenticate_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.ClientCheckAclRequest">>) -> client_check_acl_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.ClientSubscribeRequest">>) -> client_subscribe_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.ClientUnsubscribeRequest">>) -> - client_unsubscribe_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.SessionCreatedRequest">>) -> session_created_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.SessionSubscribedRequest">>) -> - session_subscribed_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.SessionUnsubscribedRequest">>) -> - session_unsubscribed_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.SessionResumedRequest">>) -> session_resumed_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.SessionDiscardedRequest">>) -> session_discarded_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.SessionTakeoveredRequest">>) -> - session_takeovered_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.SessionTerminatedRequest">>) -> - session_terminated_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.MessagePublishRequest">>) -> message_publish_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.MessageDeliveredRequest">>) -> message_delivered_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.MessageDroppedRequest">>) -> message_dropped_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.MessageAckedRequest">>) -> message_acked_request; -fqbin_to_msg_name(<<"dgiot.exhook.v1.EmptySuccess">>) -> empty_success; -fqbin_to_msg_name(<<"dgiot.exhook.v1.ValuedResponse">>) -> valued_response; -fqbin_to_msg_name(<<"dgiot.exhook.v1.BrokerInfo">>) -> broker_info; -fqbin_to_msg_name(<<"dgiot.exhook.v1.HookSpec">>) -> hook_spec; -fqbin_to_msg_name(<<"dgiot.exhook.v1.ConnInfo">>) -> conn_info; -fqbin_to_msg_name(<<"dgiot.exhook.v1.ClientInfo">>) -> client_info; -fqbin_to_msg_name(<<"dgiot.exhook.v1.Message">>) -> message; -fqbin_to_msg_name(<<"dgiot.exhook.v1.Property">>) -> property; -fqbin_to_msg_name(<<"dgiot.exhook.v1.TopicFilter">>) -> topic_filter; -fqbin_to_msg_name(<<"dgiot.exhook.v1.SubOpts">>) -> sub_opts; -fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). - - -msg_name_to_fqbin(provider_loaded_request) -> <<"dgiot.exhook.v1.ProviderLoadedRequest">>; -msg_name_to_fqbin(loaded_response) -> <<"dgiot.exhook.v1.LoadedResponse">>; -msg_name_to_fqbin(provider_unloaded_request) -> <<"dgiot.exhook.v1.ProviderUnloadedRequest">>; -msg_name_to_fqbin(client_connect_request) -> <<"dgiot.exhook.v1.ClientConnectRequest">>; -msg_name_to_fqbin(client_connack_request) -> <<"dgiot.exhook.v1.ClientConnackRequest">>; -msg_name_to_fqbin(client_connected_request) -> <<"dgiot.exhook.v1.ClientConnectedRequest">>; -msg_name_to_fqbin(client_disconnected_request) -> - <<"dgiot.exhook.v1.ClientDisconnectedRequest">>; -msg_name_to_fqbin(client_authenticate_request) -> - <<"dgiot.exhook.v1.ClientAuthenticateRequest">>; -msg_name_to_fqbin(client_check_acl_request) -> <<"dgiot.exhook.v1.ClientCheckAclRequest">>; -msg_name_to_fqbin(client_subscribe_request) -> <<"dgiot.exhook.v1.ClientSubscribeRequest">>; -msg_name_to_fqbin(client_unsubscribe_request) -> - <<"dgiot.exhook.v1.ClientUnsubscribeRequest">>; -msg_name_to_fqbin(session_created_request) -> <<"dgiot.exhook.v1.SessionCreatedRequest">>; -msg_name_to_fqbin(session_subscribed_request) -> - <<"dgiot.exhook.v1.SessionSubscribedRequest">>; -msg_name_to_fqbin(session_unsubscribed_request) -> - <<"dgiot.exhook.v1.SessionUnsubscribedRequest">>; -msg_name_to_fqbin(session_resumed_request) -> <<"dgiot.exhook.v1.SessionResumedRequest">>; -msg_name_to_fqbin(session_discarded_request) -> <<"dgiot.exhook.v1.SessionDiscardedRequest">>; -msg_name_to_fqbin(session_takeovered_request) -> - <<"dgiot.exhook.v1.SessionTakeoveredRequest">>; -msg_name_to_fqbin(session_terminated_request) -> - <<"dgiot.exhook.v1.SessionTerminatedRequest">>; -msg_name_to_fqbin(message_publish_request) -> <<"dgiot.exhook.v1.MessagePublishRequest">>; -msg_name_to_fqbin(message_delivered_request) -> <<"dgiot.exhook.v1.MessageDeliveredRequest">>; -msg_name_to_fqbin(message_dropped_request) -> <<"dgiot.exhook.v1.MessageDroppedRequest">>; -msg_name_to_fqbin(message_acked_request) -> <<"dgiot.exhook.v1.MessageAckedRequest">>; -msg_name_to_fqbin(empty_success) -> <<"dgiot.exhook.v1.EmptySuccess">>; -msg_name_to_fqbin(valued_response) -> <<"dgiot.exhook.v1.ValuedResponse">>; -msg_name_to_fqbin(broker_info) -> <<"dgiot.exhook.v1.BrokerInfo">>; -msg_name_to_fqbin(hook_spec) -> <<"dgiot.exhook.v1.HookSpec">>; -msg_name_to_fqbin(conn_info) -> <<"dgiot.exhook.v1.ConnInfo">>; -msg_name_to_fqbin(client_info) -> <<"dgiot.exhook.v1.ClientInfo">>; -msg_name_to_fqbin(message) -> <<"dgiot.exhook.v1.Message">>; -msg_name_to_fqbin(property) -> <<"dgiot.exhook.v1.Property">>; -msg_name_to_fqbin(topic_filter) -> <<"dgiot.exhook.v1.TopicFilter">>; -msg_name_to_fqbin(sub_opts) -> <<"dgiot.exhook.v1.SubOpts">>; -msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). - - -fqbin_to_enum_name(<<"dgiot.exhook.v1.ClientCheckAclRequest.AclReqType">>) -> - 'client_check_acl_request.AclReqType'; -fqbin_to_enum_name(<<"dgiot.exhook.v1.ValuedResponse.ResponsedType">>) -> - 'valued_response.ResponsedType'; -fqbin_to_enum_name(E) -> - error({gpb_error, {badenum, E}}). - - -enum_name_to_fqbin('client_check_acl_request.AclReqType') -> - <<"dgiot.exhook.v1.ClientCheckAclRequest.AclReqType">>; -enum_name_to_fqbin('valued_response.ResponsedType') -> - <<"dgiot.exhook.v1.ValuedResponse.ResponsedType">>; -enum_name_to_fqbin(E) -> - error({gpb_error, {badenum, E}}). - - -get_package_name() -> 'dgiot.exhook.v1'. - - -%% Whether or not the message names -%% are prepended with package name or not. -uses_packages() -> true. - - -source_basename() -> "exhook.proto". - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned with extension, -%% see get_all_proto_names/0 for a version that returns -%% the basenames sans extension -get_all_source_basenames() -> ["exhook.proto"]. - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned sans .proto extension, -%% to make it easier to use them with the various get_xyz_containment -%% functions. -get_all_proto_names() -> ["exhook"]. - - -get_msg_containment("exhook") -> - [broker_info, - client_authenticate_request, - client_check_acl_request, - client_connack_request, - client_connect_request, - client_connected_request, - client_disconnected_request, - client_info, - client_subscribe_request, - client_unsubscribe_request, - conn_info, - empty_success, - hook_spec, - loaded_response, - message, - message_acked_request, - message_delivered_request, - message_dropped_request, - message_publish_request, - property, - provider_loaded_request, - provider_unloaded_request, - session_created_request, - session_discarded_request, - session_resumed_request, - session_subscribed_request, - session_takeovered_request, - session_terminated_request, - session_unsubscribed_request, - sub_opts, - topic_filter, - valued_response]; -get_msg_containment(P) -> - error({gpb_error, {badproto, P}}). - - -get_pkg_containment("exhook") -> 'dgiot.exhook.v1'; -get_pkg_containment(P) -> - error({gpb_error, {badproto, P}}). - - -get_service_containment("exhook") -> - ['dgiot.exhook.v1.HookProvider']; -get_service_containment(P) -> - error({gpb_error, {badproto, P}}). - - -get_rpc_containment("exhook") -> - [{'dgiot.exhook.v1.HookProvider', 'OnProviderLoaded'}, - {'dgiot.exhook.v1.HookProvider', 'OnProviderUnloaded'}, - {'dgiot.exhook.v1.HookProvider', 'OnClientConnect'}, - {'dgiot.exhook.v1.HookProvider', 'OnClientConnack'}, - {'dgiot.exhook.v1.HookProvider', 'OnClientConnected'}, - {'dgiot.exhook.v1.HookProvider', - 'OnClientDisconnected'}, - {'dgiot.exhook.v1.HookProvider', - 'OnClientAuthenticate'}, - {'dgiot.exhook.v1.HookProvider', 'OnClientCheckAcl'}, - {'dgiot.exhook.v1.HookProvider', 'OnClientSubscribe'}, - {'dgiot.exhook.v1.HookProvider', 'OnClientUnsubscribe'}, - {'dgiot.exhook.v1.HookProvider', 'OnSessionCreated'}, - {'dgiot.exhook.v1.HookProvider', 'OnSessionSubscribed'}, - {'dgiot.exhook.v1.HookProvider', - 'OnSessionUnsubscribed'}, - {'dgiot.exhook.v1.HookProvider', 'OnSessionResumed'}, - {'dgiot.exhook.v1.HookProvider', 'OnSessionDiscarded'}, - {'dgiot.exhook.v1.HookProvider', 'OnSessionTakeovered'}, - {'dgiot.exhook.v1.HookProvider', 'OnSessionTerminated'}, - {'dgiot.exhook.v1.HookProvider', 'OnMessagePublish'}, - {'dgiot.exhook.v1.HookProvider', 'OnMessageDelivered'}, - {'dgiot.exhook.v1.HookProvider', 'OnMessageDropped'}, - {'dgiot.exhook.v1.HookProvider', 'OnMessageAcked'}]; -get_rpc_containment(P) -> - error({gpb_error, {badproto, P}}). - - -get_enum_containment("exhook") -> - ['client_check_acl_request.AclReqType', - 'valued_response.ResponsedType']; -get_enum_containment(P) -> - error({gpb_error, {badproto, P}}). - - -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.TopicFilter">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.SubOpts">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.HookSpec">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.EmptySuccess">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.SessionUnsubscribedRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.SessionTerminatedRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.SessionTakeoveredRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.SessionSubscribedRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.SessionResumedRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.SessionDiscardedRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.SessionCreatedRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.ProviderUnloadedRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.ProviderLoadedRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.MessagePublishRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.MessageDroppedRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.MessageDeliveredRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.MessageAckedRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.ClientUnsubscribeRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.ClientSubscribeRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.ClientDisconnectedRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.ClientConnectedRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.ClientConnectRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.ClientConnackRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.ClientCheckAclRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.ClientAuthenticateRequest">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.ValuedResponse">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.Message">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.LoadedResponse">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.Property">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.ConnInfo">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.ClientInfo">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(<<"dgiot.exhook.v1.BrokerInfo">>) -> "exhook"; -get_proto_by_msg_name_as_fqbin(E) -> - error({gpb_error, {badmsg, E}}). - - -get_proto_by_service_name_as_fqbin(<<"dgiot.exhook.v1.HookProvider">>) -> "exhook"; -get_proto_by_service_name_as_fqbin(E) -> - error({gpb_error, {badservice, E}}). - - -get_proto_by_enum_name_as_fqbin(<<"dgiot.exhook.v1.ValuedResponse.ResponsedType">>) -> "exhook"; -get_proto_by_enum_name_as_fqbin(<<"dgiot.exhook.v1.ClientCheckAclRequest.AclReqType">>) -> "exhook"; -get_proto_by_enum_name_as_fqbin(E) -> - error({gpb_error, {badenum, E}}). - - -get_protos_by_pkg_name_as_fqbin(<<"dgiot.exhook.v1">>) -> ["exhook"]; -get_protos_by_pkg_name_as_fqbin(E) -> - error({gpb_error, {badpkg, E}}). - - - -gpb_version_as_string() -> - "4.11.2". - -gpb_version_as_list() -> - [4,11,2]. diff --git a/apps/emqx_exhook/src/emqx_exhook_app.erl b/apps/emqx_exhook/src/emqx_exhook_app.erl index 2988be6d..d2c630a9 100644 --- a/apps/emqx_exhook/src/emqx_exhook_app.erl +++ b/apps/emqx_exhook/src/emqx_exhook_app.erl @@ -24,17 +24,20 @@ -define(CNTER, emqx_exhook_counter). --export([ start/2 - , stop/1 - , prep_stop/1 - ]). +-export([start/2 + , stop/1 + , prep_stop/1 +]). %% Internal export --export([ load_server/2 - , unload_server/1 - , unload_exhooks/0 - , init_hooks_cnter/0 - ]). +-export([ + load_all_servers/0 + , load_server/2 + , unload_all_servers/0 + , unload_server/1 + , unload_exhooks/0 + , init_hooks_cnter/0 +]). %%-------------------------------------------------------------------- %% Application callbacks @@ -47,7 +50,7 @@ start(_StartType, _StartArgs) -> init_hooks_cnter(), %% Load all dirvers - load_all_servers(), +%% load_all_servers(), %% Register CLI emqx_ctl:register_command(exhook, {emqx_exhook_cli, cli}, []), @@ -69,7 +72,7 @@ stop(_State) -> load_all_servers() -> lists:foreach(fun({Name, Options}) -> load_server(Name, Options) - end, application:get_env(?APP, servers, [])). + end, application:get_env(?APP, servers, [])). unload_all_servers() -> emqx_exhook:disable_all(). @@ -82,7 +85,7 @@ unload_server(Name) -> unload_exhooks() -> [emqx:unhook(Name, {M, F}) || - {Name, {M, F, _A}} <- ?ENABLED_HOOKS]. + {Name, {M, F, _A}} <- ?ENABLED_HOOKS]. init_hooks_cnter() -> try diff --git a/data/loaded_plugins.tmpl b/data/loaded_plugins.tmpl index 3295888c..a4ba06a8 100644 --- a/data/loaded_plugins.tmpl +++ b/data/loaded_plugins.tmpl @@ -6,6 +6,7 @@ {emqx_telemetry, {{enable_plugin_emqx_telemetry}}}. {emqx_rule_engine, {{enable_plugin_emqx_rule_engine}}}. {emqx_bridge_mqtt, {{enable_plugin_emqx_bridge_mqtt}}}. +{emqx_exhook, {{enable_plugin_emqx_exhook}}}. {dgiot, {{enable_plugin_dgiot}}}. {dgiot_parse, {{enable_plugin_dgiot_parse}}}. {dgiot_api, {{enable_plugin_dgiot_api}}}. diff --git a/rebar.config.erl b/rebar.config.erl index b5647c21..d52fbdde 100644 --- a/rebar.config.erl +++ b/rebar.config.erl @@ -199,6 +199,7 @@ overlay_vars_rel(RelType) -> , {enable_plugin_emqx_recon, true} , {enable_plugin_emqx_retainer, true} , {enable_plugin_emqx_telemetry, true} + , {enable_plugin_emqx_exhook, true} , {enable_plugin_dgiot, true} , {enable_plugin_dgiot_bridge, true} , {enable_plugin_dgiot_parse, true} @@ -313,6 +314,7 @@ relx_plugin_apps(ReleaseType) -> , emqx_recon , emqx_rule_engine , emqx_sasl + , emqx_exhook ] ++ [emqx_telemetry || not is_enterprise()] ++ relx_plugin_apps_per_rel(ReleaseType)