From 2e620971aa5ef91cf65a271ea94a3896931688b2 Mon Sep 17 00:00:00 2001 From: Anna Puddles <113144806+annapuddles@users.noreply.github.com> Date: Fri, 13 Jan 2023 19:41:11 -0500 Subject: [PATCH] Update template.lsl --- template.lsl | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/template.lsl b/template.lsl index 3cec396..c57eb33 100644 --- a/template.lsl +++ b/template.lsl @@ -1,22 +1,23 @@ -jsonrpc_link_notification(integer link, string method, string params_type, list params) +string jsonrpc_notification(string method, string params_type, list params) { - llMessageLinked(link, 0, llList2Json(JSON_OBJECT, ["jsonrpc", "2.0", "method", method, "params", llList2Json(params_type, params)]), NULL_KEY); + return llList2Json(JSON_OBJECT, ["jsonrpc", "2.0", "method", method, "params", llList2Json(params_type, params)]); } default { link_message(integer sender, integer num, string str, key id) { - if (llJsonGetValue(str, ["method"]) != "prim-dns:request") + string jsonrpc_method = llJsonGetValue(str, ["method"]); + + if (jsonrpc_method == "prim-dns:request") { - return; + key request_id = (key) llJsonGetValue(str, ["params", "request-id"]); + string method = llJsonGetValue(str, ["params", "method"]); + string headers = llJsonGetValue(str, ["params", "headers"]); + string body = llJsonGetValue(str, ["params", "body"]); + + llMessageLinked(sender, 0, jsonrpc_notification("prim-dns:set-content-type", JSON_OBJECT, ["request-id", request_id, "content-type", CONTENT_TYPE_HTML]), NULL_KEY); + llMessageLinked(sender, 0, jsonrpc_notification("prim-dns:response", JSON_OBJECT, ["request-id", request_id, "status", 200, "body", "Hello, world!"]), NULL_KEY); } - - key request_id = (key) llJsonGetValue(str, ["params", "request-id"]); - string method = llJsonGetValue(str, ["params", "method"]); - string body = llJsonGetValue(str, ["params", "body"]); - - jsonrpc_link_notification(sender, "prim-dns:set-content-type", JSON_OBJECT, ["request-id", request_id, "content-type", CONTENT_TYPE_HTML]); - jsonrpc_link_notification(sender, "prim-dns:response", JSON_OBJECT, ["request-id", request_id, "status", 200, "body", "Hello, world!"]); } }