Difference between revisions of "LlGetFreeURLs"

From Second Life Wiki
Jump to navigation Jump to search
(New page: {{LSL_Function |func_id=344|func_sleep=0.0|func_energy=10.0 |func=llGetFreeURLs|return_type=integer |func_footnote |func_desc |return_text=that is the number of available URLs. |spec |cave...)
 
m
(8 intermediate revisions by 6 users not shown)
Line 9: Line 9:
|constants
|constants
|examples=
|examples=
This script will say the number of currently available HTTP-In URLs left for the sim.
<source lang="lsl2">
default
{
    touch_start(integer num_detected)
    {
        integer numberOfFreeURLs = llGetFreeURLs();
        if(numberOfFreeURLs)
            llSay(0,  "There are " + (string)numberOfFreeURLs + " available HTTP-In URLs left for this sim.");
        else
            llSay(0, "WARNING: There are no HTTP-In URLs available anymore.");
    }
}
</source>
<source lang="lsl2">
// 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!");
    }
}
</source>
|helpers
|helpers
|also_functions=
|also_functions=
Line 20: Line 73:
|also_articles=
|also_articles=
{{LSL DefineRow||[[LSL http server]]}}
{{LSL DefineRow||[[LSL http server]]}}
|notes
|notes=
URLs are a finite region resource and should be released when no longer needed.
|deepnotes=
|deepnotes=
|history=
|history=
*{{SVN|1836|rev=112899 |trunk=*|anchor=file15|ver=|ser=}}
*{{SVN|1836|rev=112899 |trunk=*|anchor=file22|ver=|ser=}}
|cat1=HTTP
|cat1=HTTP
|cat2
|cat2

Revision as of 01:54, 22 January 2015

Summary

Function: integer llGetFreeURLs( );

Returns an integer that is the number of available URLs.

Examples

This script will say the number of currently available HTTP-In URLs left for the sim.

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

        if(numberOfFreeURLs)
            llSay(0,  "There are " + (string)numberOfFreeURLs + " available HTTP-In URLs left for this sim.");

        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

Search JIRA for related Issues

Signature

function integer llGetFreeURLs();