diff options
author | Ulf Wiger <ulf@feuerlabs.com> | 2015-11-05 17:29:22 +0100 |
---|---|---|
committer | Ulf Wiger <ulf@feuerlabs.com> | 2015-11-20 13:47:02 -0800 |
commit | ca1f0abd9f0f1478da8380bff28cb25aada34c1d (patch) | |
tree | 814c4a3c17b247cc300f62673771dad5a5c6ed77 /components/proto_bert/src | |
parent | 1b44c2448344a10ae63904a796b6211c40a3f212 (diff) | |
download | rvi_core-ca1f0abd9f0f1478da8380bff28cb25aada34c1d.tar.gz |
All tests (incl remote method inv) pass
- No signatures on messages (dlink_tls)
- dlink_bt wasn't actually tested (test case passed erroneously)
- added proto_msgpack component
- fixed sneaky bug in 'setup'
Diffstat (limited to 'components/proto_bert/src')
-rw-r--r-- | components/proto_bert/src/proto_bert_rpc.erl | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/components/proto_bert/src/proto_bert_rpc.erl b/components/proto_bert/src/proto_bert_rpc.erl index cad1708..f1658a3 100644 --- a/components/proto_bert/src/proto_bert_rpc.erl +++ b/components/proto_bert/src/proto_bert_rpc.erl @@ -2,7 +2,7 @@ %% Copyright (C) 2014, Jaguar Land Rover %% %% This program is licensed under the terms and conditions of the -%% Mozilla Public License, version 2.0. The full text of the +%% Mozilla Public License, version 2.0. The full text of the %% Mozilla Public License is at https://www.mozilla.org/MPL/2.0/ %% @@ -20,12 +20,12 @@ -include_lib("lager/include/log.hrl"). -include_lib("rvi_common/include/rvi_common.hrl"). --define(SERVER, ?MODULE). +-define(SERVER, ?MODULE). -export([start_json_server/0]). -export([send_message/8, receive_message/3]). --record(st, { +-record(st, { %% Component specification cs = #component_spec{} }). @@ -42,26 +42,26 @@ start_json_server() -> -send_message(CompSpec, - ServiceName, - Timeout, +send_message(CompSpec, + TID, + ServiceName, + Timeout, ProtoOpts, DataLinkMod, DataLinkOpts, - Parameters, - Signature) -> + Parameters) -> rvi_common:request(protocol, ?MODULE, send_message, - [ { service, ServiceName }, + [ { transaction_id, TID }, + { service, ServiceName }, { timeout, Timeout }, { protocol_opts, ProtoOpts }, { data_link_mod, DataLinkMod }, { data_link_opts, DataLinkOpts }, - { parameters, Parameters }, - { signature, Signature }], + { parameters, Parameters } ], [ status ], CompSpec). receive_message(CompSpec, {IP,Port}, Data) -> - rvi_common:notification(protocol, ?MODULE, receive_message, + rvi_common:notification(protocol, ?MODULE, receive_message, [ {data, Data}, {remote_ip, IP}, {remote_port, Port} ], @@ -71,23 +71,25 @@ receive_message(CompSpec, {IP,Port}, Data) -> %% CAlled by local exo http server handle_rpc("send_message", Args) -> + LogId = rvi_common:get_json_log_id(Args), + {ok, TID} = rvi_common:get_json_element(["transaction_id"], Args), {ok, ServiceName} = rvi_common:get_json_element(["service_name"], Args), {ok, Timeout} = rvi_common:get_json_element(["timeout"], Args), {ok, ProtoOpts} = rvi_common:get_json_element(["protocol_opts"], Args), {ok, DataLinkMod} = rvi_common:get_json_element(["data_link_mod"], Args), {ok, DataLinkOpts} = rvi_common:get_json_element(["data_link_opts"], Args), {ok, Parameters} = rvi_common:get_json_element(["parameters"], Args), - {ok, Signature} = rvi_common:get_json_element(["signature"], Args), - [ ok ] = gen_server:call(?SERVER, { rvi, send_message, - [ServiceName, + [ ok ] = gen_server:call(?SERVER, { rvi, send_message, + [TID, + ServiceName, Timeout, ProtoOpts, DataLinkMod, DataLinkOpts, Parameters, - Signature]}), + LogId]}), {ok, [ {status, rvi_common:json_rpc_status(ok)} ]}; - + handle_rpc(Other, _Args) -> @@ -107,23 +109,22 @@ handle_notification(Other, _Args) -> ok. -handle_call({rvi, send_message, - [ServiceName, +handle_call({rvi, send_message, + [_TID, + ServiceName, Timeout, ProtoOpts, DataLinkMod, DataLinkOpts, - Parameters, - Signature]}, _From, St) -> + Parameters | _LogId]}, _From, St) -> ?debug(" protocol:send(): service name: ~p~n", [ServiceName]), ?debug(" protocol:send(): timeout: ~p~n", [Timeout]), ?debug(" protocol:send(): opts: ~p~n", [ProtoOpts]), ?debug(" protocol:send(): data_link_mod: ~p~n", [DataLinkMod]), ?debug(" protocol:send(): data_link_opts: ~p~n", [DataLinkOpts]), %% ?debug(" protocol:send(): parameters: ~p~n", [Parameters]), - ?debug(" protocol:send(): signature: ~p~n", [Signature]), - - Data = term_to_binary({ ServiceName, Timeout, Parameters, Signature }), + + Data = term_to_binary({ ServiceName, Timeout, Parameters }), Res = DataLinkMod:send_data(St#st.cs, ?MODULE, ServiceName, DataLinkOpts, Data), @@ -149,21 +150,18 @@ handle_cast_({rvi, receive_message, [Data,IP,Port]}, St) when is_list(Data)-> handle_cast({ rvi, receive_message, [list_to_binary(Data),IP,Port] }, St); handle_cast_({rvi, receive_message, [Data, IP, Port]}, St) -> - {ServiceName, - Timeout, - Parameters, - Signature} = binary_to_term(Data), + {ServiceName, + Timeout, + Parameters} = binary_to_term(Data), ?debug(" protocol:rcv(): service name: ~p~n", [ServiceName]), ?debug(" protocol:rcv(): timeout: ~p~n", [Timeout]), %% ?debug(" protocol:rcv(): parameters: ~p~n", [Parameters]), - ?debug(" protocol:rcv(): signature: ~p~n", [Signature]), ?debug(" protocol:rcv(): remote IP/port: ~p~n", [{IP, Port}]), service_edge_rpc:handle_remote_message(St#st.cs, {IP, Port}, ServiceName, Timeout, - Parameters, - Signature), + Parameters), {noreply, St}; handle_cast_(Other, St) -> |