Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llHTTPResponse Question

Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
10-22-2008 08:56
Hi All,

I know I could test this myself but due to circumstances I can't get into the beta grid for a while to do so, so I will ask :)

From: http://wiki.secondlife.com/wiki/LSL_http_server/design
Goals

Create an alternative to the XMLRPC server and email gateway for communication with LSL scripts initiated from outside Second Life that is easy to use and scalable. Extra bonus for enabling LSL -> LSL communication at the same time.


Has anyone attempted the LSL -> LSL communication, if so did it work?

Thanks
Travis Lambert
White dog, red collar
Join date: 3 Jun 2004
Posts: 2,819
10-22-2008 10:25
Yes and Yes.

Listener Script:

CODE

default
{
state_entry()
{
llSay(0, "Requesting URL!");
llRequestURL();
}

http_request(key id, string method, string body)
{
if (method == URL_REQUEST_GRANTED)
{
llSay(50, body);
}
if (method == URL_REQUEST_DENIED)
{
llSay(0, "Something went wrong, no url. " + body);
}
if (method == "POST")
{
llHTTPResponse(id,1,"Hi there");
llSay(0,"Oooh - somebody touched me, and they said:" + body);
}


}
}


Broadcaster Script:

CODE

integer handle;
string URL;
key request;

default
{
state_entry()
{
handle = llListen(50,"","","");
}

listen(integer channel, string name, key id, string message)
{
llSay(0,"I heard something on channel 50: " + message);
URL = message;
string str = "This message was sent from an object!";
request = llHTTPRequest(URL, [HTTP_METHOD, "POST", HTTP_MIMETYPE, "text/plain;charset=utf-8"], str);
}
}



Output from listener:

[10:23] HTTPServer: Oooh - somebody touched me, and they said:This message was sent from an object!

Note: The above also works object to object if you llRequestSecureURL :)
_____________________
------------------
The Shelter

The Shelter is a non-profit recreation center for new residents, and supporters of new residents. Our goal is to provide a positive & supportive social environment for those looking for one in our overwhelming world.
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
10-22-2008 10:35
Thanks Travis,

For both the answer and the sample code :)
Now I can go forward with my current design ideas without having to wait for proof of concept.