1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
integer mychannel = -8888;
integer particle_chan = -270510;
string listenfor;
string response;
string detach;
key masterid;
key handle;
key them = NULL_KEY;
string URL = "";
key RequestID;
default
{
state_entry()
{
masterid = llGetOwner();
handle = llGetKey();
listenfor = (string)masterid + "handle";
response = (string)masterid + "handle ok";
detach = (string)masterid + "handle detached";
llListen(mychannel, "", NULL_KEY, listenfor);
llSay(mychannel, response);
}
attach(key id)
{
if (NULL_KEY == id)
llSay(mychannel, detach);
}
listen(integer channel, string name, key id, string message)
{
llSay(mychannel, response);
llSay(particle_chan, handle + "#" + masterid);
if (NULL_KEY == them)
them = llGetOwnerKey(id);
}
dataserver(key id, string data)
{
list input = llParseStringKeepNulls(data, ["|"], []);
string domain = llList2String(input, 0);
if ("URL" == domain)
URL = llList2String(input, 1);
}
http_response(key id, integer status, list metaData, string body)
{
if (id == RequestID)
{
RequestID = NULL_KEY;
if (status != 200)
llOwnerSay("HTTP error code " + status + "\n" + body);
}
else if (id == NULL_KEY)
llOwnerSay("Too many HTTP requests too fast!");
}
on_rez(integer param)
{
llResetScript();
}
touch_start(integer total_number)
{
llSay(particle_chan, handle + "#" + masterid);
}
changed(integer change)
{
if ("" != URL)
{
if (change & CHANGED_REGION)
{
RequestID = llHTTPRequest(URL,
[HTTP_METHOD, "POST", HTTP_VERBOSE_THROTTLE, FALSE, HTTP_BODY_MAXLENGTH, 16384],
llEscapeURL("REGION|" + llGetRegionName() + "|" + (string)llGetPos()));
llOwnerSay("Changed region to " + llGetRegionName() + " - " + (string)llGetPos()
+ "\n Requesting that " + osKey2Name(them) + " join me.");
}
else if (change & CHANGED_TELEPORT)
{
llSleep(1.0);
RequestID = llHTTPRequest(URL,
[HTTP_METHOD, "POST", HTTP_VERBOSE_THROTTLE, FALSE, HTTP_BODY_MAXLENGTH, 16384],
llEscapeURL("TELEPORT|" + llGetRegionName() + "|" + (string)llGetPos()));
llOwnerSay("Teleported to " + llGetRegionName() + " - " + (string)llGetPos()
+ "\n Requesting that " + osKey2Name(them) + " join me.");
}
}
}
}
|