Advertisement
Guest User

Untitled

a guest
Dec 6th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string MAP_SERVICE = "http://gridurl.appspot.com";
  2. string MY_UUID = "e0a86ba9-99d8-4aa7-80b9-b04d42e2fec7";
  3.  
  4. string persistant_url;  // Persistant version of URL
  5. string url = "";        // Raw LL URL
  6. key urlQ;               // URL Request key
  7.  
  8. default {
  9.     state_entry() {
  10.         state requestURL;
  11.     }
  12. }
  13.  
  14. state requestURL {
  15.     state_entry()
  16.     {
  17.         if (url != "")
  18.             llReleaseURL(url);
  19.         llOwnerSay("Requesting url...");
  20.         urlQ = llRequestURL();
  21.         llSetTimerEvent(30);
  22.     }
  23.    
  24.     http_request(key q,string method,string body) {
  25.         if (q == urlQ) {
  26.             if (method == URL_REQUEST_GRANTED) {
  27.                 url = body;
  28.                 persistant_url = MAP_SERVICE + "/go/" + MY_UUID;
  29.                 llOwnerSay("Grid URL granted.  Registering with map service...");
  30.                 urlQ = llHTTPRequest(MAP_SERVICE
  31.                         +"/reg?service="+MY_UUID
  32.                         +"&url="+llEscapeURL(url+"/")
  33.                         ,[],"");
  34.             }
  35.         }
  36.     }
  37.     http_response(key q,integer status,list meta,string body) {
  38.         if (q == urlQ) {
  39.             if (status == 200) {
  40.                 state ready;
  41.             }
  42.         }
  43.     }
  44.     timer() {
  45.         llOwnerSay("Registation attempt timed out.  Retrying...");
  46.         state default;
  47.     }
  48. }
  49.  
  50. state ready {
  51.     state_entry() {
  52.         llSetTimerEvent(0);
  53.         llOwnerSay("Registration complete.  my url is "+persistant_url);
  54.     }
  55.     http_request(key q,string method,string body) {
  56.         list msgList = llJson2List(body);
  57.         llOwnerSay("GOT-MESSAGE: ["+llDumpList2String(msgList,", ")+"]");        
  58.         llHTTPResponse(q,200,"this is the reply from the server back to the client");
  59.     }
  60.     changed(integer change) {
  61.         if (change & (CHANGED_OWNER|CHANGED_REGION_START|CHANGED_REGION|CHANGED_TELEPORT))
  62.             state default;
  63.     }
  64.     on_rez(integer n) {
  65.         state default;
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement