Files
lsl-shell/api.lsl

45 lines
1.2 KiB
Plaintext
Raw Normal View History

2020-04-12 15:51:44 +02:00
integer connected = 0;
2020-04-12 17:44:17 +02:00
key SECRET_KEY = "29731e5170353a8b235098c43cd2099a4e805c55fb4395890e81f437c17334a9";
2020-04-12 15:51:44 +02:00
default
{
state_entry()
{
llRequestSecureURL();
}
http_request(key id, string method, string body)
{
if(method == URL_REQUEST_GRANTED)
{
string url = body;
llOwnerSay(url);
}
else if(method == "POST")
{
2020-04-12 17:44:17 +02:00
llOwnerSay("POST: " + body);
if(llJsonGetValue(body, ["secret_key"]) == SECRET_KEY)
2020-04-12 15:51:44 +02:00
{
2020-04-12 17:44:17 +02:00
if(llJsonGetValue(body, ["command"]) == "init")
{
llHTTPResponse(id, 200, "{\"uuid\": \"" + string(llGetKey()) + "\"}");
connected = 1;
}
else if(llJsonGetValue(body, ["command"]) == "disconnect")
{
2020-04-12 18:24:01 +02:00
llHTTPResponse(id, 200, "{\"result\": \"disconnected\"}");
2020-04-12 17:44:17 +02:00
connected = 0;
}
else
{
2020-04-12 18:24:01 +02:00
llHTTPResponse(id, 200, "{\"result\": \"success\"}");
2020-04-12 17:44:17 +02:00
}
2020-04-12 15:51:44 +02:00
}
else
{
2020-04-12 17:44:17 +02:00
llHTTPResponse(id, 401, "{\"error\": \"Invalid secret key\"}");
2020-04-12 15:51:44 +02:00
}
}
}
}