LlGetFreeURLs: Difference between revisions

From Second Life Wiki
Jump to navigation Jump to search
mNo edit summary
Gwyneth Llewelyn (talk | contribs)
Replaced <source> with <syntaxhighlight>; uniformised spelling of "URL" and "URLs"; replaced "sim" with "region"; cleaned-up code to comply with best practices
 
(2 intermediate revisions by one other user not shown)
Line 4: Line 4:
|func_footnote
|func_footnote
|func_desc
|func_desc
|return_text=that is the number of available URLs.
|return_text=that is the number of available URLs. If attached, return the URLs remaining for the owner. Otherwise, return the available URLs for the region.
|spec
|spec=
|caveats
There is a separate URL limit for the region, and a limit for each agent. The URL limit is the same as the [[Land Impact]] limit:
* Agent: 38
* Openspace Sim: 1,250
* Homestead Sim: 5,000
* Full Sim: 20,000
* Mainland Sim: 22,500
* 30k Sim: 30,000
|caveats=
* If called from an attachment, there is no way to get the number of free URLs in the region; it will always return the URL count remaining for the agent.
|constants
|constants
|examples=
|examples=
This script will say the number of currently available HTTP-In URLs left for the sim.
This script will say the number of currently available HTTP-In URLs left in the region.
<source lang="lsl2">
<syntaxhighlight lang="lsl2">
default
default
{
{
Line 17: Line 25:
         integer numberOfFreeURLs = llGetFreeURLs();
         integer numberOfFreeURLs = llGetFreeURLs();


         if(numberOfFreeURLs)
         if (numberOfFreeURLs)
             llSay(0, "There are " + (string)numberOfFreeURLs + " available HTTP-In URLs left for this sim.");
        {
 
             llSay(0, "There are " + (string)numberOfFreeURLs + " available HTTP-In URLs left in this region.");
        }
         else
         else
        {
             llSay(0, "WARNING: There are no HTTP-In URLs available anymore.");
             llSay(0, "WARNING: There are no HTTP-In URLs available anymore.");
        }
     }
     }
}
}
</source>
</syntaxhighlight>
<source lang="lsl2">
<syntaxhighlight lang="lsl2">
// WARNING:
// WARNING:
//
//
Line 37: Line 48:
//      Deleting the script and/or derezzing the object containing the script,
//      Deleting the script and/or derezzing the object containing the script,
//      will release all previously taken URLs.
//      will release all previously taken URLs.
   
   
default
default
Line 49: Line 59:
     {
     {
         if (method == URL_REQUEST_DENIED)
         if (method == URL_REQUEST_DENIED)
        {
             llSetText("No free URLs!", <1.0, 0.0, 0.0>, 1.0);
             llSetText("No free URLs!", <1.0, 0.0, 0.0>, 1.0);
        }
         else if (method == URL_REQUEST_GRANTED)
         else if (method == URL_REQUEST_GRANTED)
         {
         {
             llSetText( (string)llGetFreeURLs() + " URLs left\n" + body, <1.0, 1.0, 1.0>, 1.0);
             llSetText((string)llGetFreeURLs() + " URLs left\n" + body, <1.0, 1.0, 1.0>, 1.0);
             llRequestURL();
             llRequestURL();
         }
         }
         else if (method == "GET")
         else if (method == "GET")
        {
             llHTTPResponse(id, 200, "Hello there!");
             llHTTPResponse(id, 200, "Hello there!");
        }
     }
     }
}
}
</source>
</syntaxhighlight>
|helpers
|helpers
|also_functions=
|also_functions=

Latest revision as of 05:07, 11 June 2023

Summary

Function: integer llGetFreeURLs( );
0.0 Forced Delay
10.0 Energy

Returns an integer that is the number of available URLs. If attached, return the URLs remaining for the owner. Otherwise, return the available URLs for the region.

Specification

There is a separate URL limit for the region, and a limit for each agent. The URL limit is the same as the Land Impact limit:

  • Agent: 38
  • Openspace Sim: 1,250
  • Homestead Sim: 5,000
  • Full Sim: 20,000
  • Mainland Sim: 22,500
  • 30k Sim: 30,000

Caveats

  • If called from an attachment, there is no way to get the number of free URLs in the region; it will always return the URL count remaining for the agent.

Examples

This script will say the number of currently available HTTP-In URLs left in the region.

default
{
    touch_start(integer num_detected)
    {
        integer numberOfFreeURLs = llGetFreeURLs();

        if (numberOfFreeURLs)
        {
            llSay(0, "There are " + (string)numberOfFreeURLs + " available HTTP-In URLs left in this region.");
        }
        else
        {
            llSay(0, "WARNING: There are no HTTP-In URLs available anymore.");
        }
    }
}
// WARNING:
//
//      This script is only for proof-of-concept (demo purposes).
//      DO NOT use it if you don't have the sim owners and/or
//      estate managers OK to test this script.
//      This script can possibly block HTTP communication from and to the sim.
//      ...bringing down all networked vendors and/or similar machines.
//
//      This script allocates all available URLs.
//      Deleting the script and/or derezzing the object containing the script,
//      will release all previously taken URLs.
 
default
{
    state_entry()
    {
        llRequestURL();
    }
 
    http_request(key request_id, string method, string body)
    {
        if (method == URL_REQUEST_DENIED)
        {
            llSetText("No free URLs!", <1.0, 0.0, 0.0>, 1.0);
        }
        else if (method == URL_REQUEST_GRANTED)
        {
            llSetText((string)llGetFreeURLs() + " URLs left\n" + body, <1.0, 1.0, 1.0>, 1.0);
            llRequestURL();
        }
        else if (method == "GET")
        {
            llHTTPResponse(id, 200, "Hello there!");
        }
    }
}

Notes

URLs are a finite region resource and should be released when no longer needed.

See Also

Functions

•  llRequestURL
•  llRequestSecureURL
•  llReleaseURL
•  llHTTPResponse
•  llGetHTTPHeader

Articles

•  LSL http server

Deep Notes

History

Signature

function integer llGetFreeURLs();