From 96fa40d610bb7fbbe06732357c43df352b5bc7a3 Mon Sep 17 00:00:00 2001 From: Bridget Date: Mon, 13 Apr 2020 14:50:09 +0200 Subject: [PATCH] Refactor --- endpoint.lsl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/endpoint.lsl b/endpoint.lsl index 2e9277c..132d289 100644 --- a/endpoint.lsl +++ b/endpoint.lsl @@ -8,6 +8,15 @@ respond(key id, integer status, string key_, string data) llHTTPResponse(id, status, llList2Json(JSON_OBJECT, [key_, data])); } +broadcast_command(key id, string command) +{ + // Broad the message to other scripts. We expect one script to return + // a link_message in response. We pass the request_id to be able + // to identify the response. + request_id = id; + llMessageLinked(LINK_SET, 0, command, request_id); +} + default { state_entry() @@ -65,9 +74,7 @@ default } else { - // Relay the message to other scripts, we handle the response later - request_id = id; - llMessageLinked(LINK_SET, 0, llJsonGetValue(body, ["command"]), id); + broadcast_command(id, llJsonGetValue(body, ["command"])); } } else