Sample code from Second Life Developer's Wiki - specifically http://www.lslwiki.com/lslwiki/wakka.php?wakka=ExampleBrowserXMLRPC
Getting Started With XML-RPC In Second Life
Ruben Kleiman (SomeScripter) 11/14/06
This page will help you to quickly get started sending and receiving XML requests in Second Life.
Copy the HTML contents of this page into a file in your own computer and run it from there.
Important: This works only in Internet Explorer. Why? For all other parental-guidance-required browsers, I would need to use digital signatures or gruesome hacks that defeat it--which, unfortunately, is a waste of time for me.
The way it works is as follows (detailed instructions here):
First, in Second Life, do the following:
string EXPECTED_REQUEST_STRING_MESSAGE = "hello there";
string BAD_RESPONSE_STRING_MESSAGE = "I do not understand what you said";
string GOOD_RESPONSE_STRING_MESSAGE = "Hi.";
key myChannel;
default {
state_entry() {
llOwnerSay("Touch me to start listening for XML-RPC requests.");
}
touch_start(integer n) {
llOpenRemoteDataChannel();
llOwnerSay("Waiting for channel to open");
}
remote_data(integer type, key channel, key uid, string from, integer integerValue, string stringValue) {
if (type == REMOTE_DATA_CHANNEL) {
myChannel = channel;
llOwnerSay("Channel Open. Channel Key="+(string)channel);
state waiting;
}
}
}
state waiting {
state_entry() {
llOwnerSay("Waiting for XML-RPC Requests...");
}
remote_data(integer type, key channel, key uid, string from, integer integerValue, string stringValue) {
if (type == REMOTE_DATA_REQUEST) {
if (stringValue == EXPECTED_REQUEST_STRING_MESSAGE) {
// uid is the identifier for the request message.
llRemoteDataReply(channel, uid, GOOD_RESPONSE_STRING_MESSAGE, 1);
} else {
llRemoteDataReply(channel, uid, BAD_RESPONSE_STRING_MESSAGE, 0);
}
} else {
// Code would go here to respond to a new open channel, etc...
// Check the options for 'type' in the LSL Wiki.
}
}
touch_start(integer n) {
state default;
}
state_exit() {
llCloseRemoteDataChannel(myChannel);
llOwnerSay("Channel closed. Touch again to start listening on channel.");
}
}
Finally, fill-in the form below:
For more details, read this page's HTML code; in particular, the callRPCScript() script, which sends the message and receives the response.
Important Tidbits (valid 11/14/06):
Channel's Key: | |
String Message: | |
Integer Message: | |