Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Strange behavior with XML-RPC

Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
04-21-2005 04:27
Has something changed with XML-RPC (apart from that Integer thing)...?
...this script seems to show some highly suspect behavior.
CODE
// Global constant for the remote channel
key REMOTE_CHANNEL = NULL_KEY;
// A count of the actual number of REMOTE_DATA_REQUEST calls
integer count = 0;

// The test state
default {
//
state_entry() {
llOpenRemoteDataChannel();
}

// Strange behavior as described below...
remote_data(integer event_type, key channel, key message_id, string sender, integer idata, string sdata) {
if (event_type == REMOTE_DATA_CHANNEL) {
// INTENTION: Tell the server what channel to use...
REMOTE_CHANNEL = channel;
llEmail("my.rpc.server@mydomain.com", "channel key", (string)REMOTE_CHANNEL);

} else if (event_type == REMOTE_DATA_REQUEST) {
count++;
if (idata == 0) {
// INTENTION: Tell the server I got the message and then say the message
llRemoteDataReply(channel, message_id, "OK", 0);
llOwnerSay("[" + (string)count + "] " + sdata);
// BROKEN: The server receives the reply only ONCE (expected),
// but the data request is sent TWICE to the script
} else {
// INTENTION: Tell the server I got the message, say the message,
// and then change state...
llRemoteDataReply(channel, message_id, "State change", 1);
llOwnerSay("[" + (string)count + "] " + sdata);
state another;
// BROKEN: The server never receives the remote reply from the script,
// AND the data request is sent TWICE to the script
}
}
}

//
state_exit() {
// I should be able to close the remote channel here
// (...even tho it actually does nothing!)
// But even when commented out, it doesn't stop the reply failure
// llCloseRemoteDataChannel(REMOTE_CHANNEL);
}
}

//
state another {
//
touch_start(integer num) {
llResetScript();
}
}

/esc
_____________________
http://slurl.com/secondlife/Together
Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
04-22-2005 15:57
Just a little sugestion, But use one state, between switching states you can miss data.

the code bellow is from your script, just with every thing un nessisary to make a point.
CODE

integer count = 0;

default
{
state_entry()
{
count++;
if (idata == 0) // this will never run, because 'count' contains the value '1'
{

}
else
{

}
}
}
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
04-23-2005 01:58
Er, thanks... bit two things Kurt:

1. Your proposition that the conditional will not execute is false. It does.

2. Your suggestion that I should put everything into a single state may work for this trivial example, but results in globals mania to replace the required state changes in a more complex script - which is ugly, hard to understand, and bad coding practice.

/esc
_____________________
http://slurl.com/secondlife/Together
Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
04-24-2005 22:54
Well can you tell me when idata == 0 will return TRUE; considering nothing in your script set the value of iData to -1 ?
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
04-25-2005 04:53
From: Kurt Zidane
Well can you tell me when idata == 0 will return TRUE; considering nothing in your script set the value of iData to -1 ?

Sure, Kurt, the idata argument is supplied by the off-world server that is making the RPC call. This is integer data supplied in the hashtable to the "llRemoteData" remote call made from the server.

/esc
_____________________
http://slurl.com/secondlife/Together
Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
04-25-2005 12:58
Well according to your code, that would be sdata.
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
04-25-2005 14:31
From: Kurt Zidane
Well according to your code, that would be sdata.

nope
_____________________
http://slurl.com/secondlife/Together