summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus <mfeuer@jaguarlandrover.com>2014-08-07 16:50:27 -0700
committerMagnus <mfeuer@jaguarlandrover.com>2014-08-07 16:50:27 -0700
commite6121e0f1b97cefa7a29585c80dd44138e6928ad (patch)
tree27af45c78261b4c27e8a01325ff15380696a71d6
parent7117db4ec0a0cfd2f099f1419c947b6931671d85 (diff)
downloadrvi_core-e6121e0f1b97cefa7a29585c80dd44138e6928ad.tar.gz
When a remote message is delivered to a locally connected service, the target element will now reflect the local service name the service registered with, not the fully qualified service name. The register_service JSON-RPC call now returns the fully qualified service name assigned to the registered service
Signed-off-by: Magnus <mfeuer@jaguarlandrover.com>
-rw-r--r--src/service_edge_rpc.erl16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/service_edge_rpc.erl b/src/service_edge_rpc.erl
index e745500..5c2276f 100644
--- a/src/service_edge_rpc.erl
+++ b/src/service_edge_rpc.erl
@@ -36,9 +36,10 @@ register_service(Service, Address) ->
[
{service, Service},
{network_address, Address}
- ]) of
- { ok, JSONStatus, _JSON} ->
- { ok, [ {status, rvi_common:json_rpc_status(JSONStatus)} ] };
+ ], [service]) of
+ { ok, JSONStatus, [ FullSvcName], _JSON} ->
+ { ok, [ {service, FullSvcName},
+ {status, rvi_common:json_rpc_status(JSONStatus)} ] };
Err ->
?debug("service_edge_rpc:register_service() Failed at service_discovery(): ~p",
@@ -139,12 +140,19 @@ handle_remote_message(Target, Timeout, Parameters, Signature, Certificate) ->
[ { service, Target } ],
[ network_address ]) of
{ ok, ok, [ NetworkAddress], _SDJSON } ->
+ SvcName = string:substr(Target,
+ length(rvi_common:local_service_prefix())),
case
+ %% Strip our node prefix from target so that
+ %% the service receiving the JSON rpc call will have
+ %% a target that is identical to the service name
+ %% it registered with.
+
%% Deliver the message to the local service
rvi_common:get_request_result(
rvi_common:send_http_request(NetworkAddress,
"message",
- [ { target, Target },
+ [ { target, SvcName },
{ parameters, Parameters }])) of
%% Request delivered.