// XML-RPC example key gChannel; // my llRemoteData channel DEBUG(list out) { // output debug info llSay(0, llList2CSV(out)); } default { // initialize XML-RPC state_entry() { llOpenRemoteDataChannel(); // create an XML-RPC channel // this will raise remote_data event REMOTE_DATA_CHANNEL when created } remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval) { if (type == REMOTE_DATA_CHANNEL) { // channel created DEBUG(["Channel opened", "REMOTE_DATA_CHANNEL", channel, message_id, sender, ival, sval]); gChannel = channel; llSay(0, "Ready to receive requests on channel \"" + (string)channel +"\""); state go; // start handling requests } else DEBUG(["Unexpected event type", type, channel, message_id, sender, ival, sval]); } } state go { // handle requests remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval) { if (type == REMOTE_DATA_REQUEST) { // handle requests sent to us DEBUG(["Request received", "REMOTE_DATA_REQUEST", channel, message_id, sender, ival, sval]); // handle request if (sval == "How are you?") { // we do something special on that string parameter // send a reply to this request, referencing the senders message id llRemoteDataReply(channel, message_id, "Fine, thanks!", 1); } else { // IMPORTANT: a reply MUST always be sent llRemoteDataReply(channel, message_id, "", 0); } } else DEBUG(["Unexpected event type:", type, channel, message_id, sender, ival, sval]); } state_exit() { llCloseRemoteDataChannel(gChannel); // clean up when you no longer want to handle requests } }