Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string MAP_SERVICE = "http://gridurl.appspot.com";
- string MY_UUID = "e0a86ba9-99d8-4aa7-80b9-b04d42e2fec7";
- string persistant_url; // Persistant version of URL
- string url = ""; // Raw LL URL
- key urlQ; // URL Request key
- default {
- state_entry() {
- state requestURL;
- }
- }
- state requestURL {
- state_entry()
- {
- if (url != "")
- llReleaseURL(url);
- llOwnerSay("Requesting url...");
- urlQ = llRequestURL();
- llSetTimerEvent(30);
- }
- http_request(key q,string method,string body) {
- if (q == urlQ) {
- if (method == URL_REQUEST_GRANTED) {
- url = body;
- persistant_url = MAP_SERVICE + "/go/" + MY_UUID;
- llOwnerSay("Grid URL granted. Registering with map service...");
- urlQ = llHTTPRequest(MAP_SERVICE
- +"/reg?service="+MY_UUID
- +"&url="+llEscapeURL(url+"/")
- ,[],"");
- }
- }
- }
- http_response(key q,integer status,list meta,string body) {
- if (q == urlQ) {
- if (status == 200) {
- state ready;
- }
- }
- }
- timer() {
- llOwnerSay("Registation attempt timed out. Retrying...");
- state default;
- }
- }
- state ready {
- state_entry() {
- llSetTimerEvent(0);
- llOwnerSay("Registration complete. my url is "+persistant_url);
- }
- http_request(key q,string method,string body) {
- list msgList = llJson2List(body);
- llOwnerSay("GOT-MESSAGE: ["+llDumpList2String(msgList,", ")+"]");
- llHTTPResponse(q,200,"this is the reply from the server back to the client");
- }
- changed(integer change) {
- if (change & (CHANGED_OWNER|CHANGED_REGION_START|CHANGED_REGION|CHANGED_TELEPORT))
- state default;
- }
- on_rez(integer n) {
- state default;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement