llRequestAgentData needs two calls
|
|
Kirth Hax
Registered User
Join date: 15 Mar 2007
Posts: 10
|
01-14-2008 14:34
Hello,
I have a problem with llRequestAgentData and the dataserver event. I have the following code (all globals):
avatar_name = llList2String( command,i+1 ) + " " + llList2String( command,i+2 ); request_http = llHTTPRequest( "http://w-hat.com/name2key" + "?terse=1&name=" + llEscapeURL( avatar_name ), [], "" ); request_uuid = llRequestAgentData( avatar_uuid, DATA_ONLINE );
llRequestAgentData triggers dataserver as follows:
dataserver(key queryid, string data) { if ( queryid == request_uuid ) { if( data == "1" ) { llOwnerSay(avatar_name + " is Online" ); } else { llOwnerSay(avatar_name + " is Offline" ); } } }
But here is the fishy part - this only works from the 2nd call and on. I made sure all inparameters are correct and found out that the "data" variable in dataserver seem to need two calls to get set correctly after the status it's reflecting has changed. All other parameters are correct already in the first call, including the uuid.
I'm quite new at LSL, so this is beyond me. Anyone seen this before?
|
|
Dytska Vieria
+/- .00004™
Join date: 13 Dec 2006
Posts: 768
|
01-14-2008 14:50
I have the same problem with a scanner I wrote!
When the dataserver is hit the first time, the query uuid is incorrect, I don't know what the uuid is, but it is not NULL. After that first query, everything works well. I do not know where the incorrect uuid is coming from either.
I hope somebody has an answer to this.
_____________________
+/- 0.00004
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
01-14-2008 15:36
It looks like you are getting the resident key via HTTP at the same time you are requesting data with that key. At that point all you have is the name, unless I am missing your context. You'll have to wait for the HTTP response before you have the UUID and can ask whether the resident is online.
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
01-14-2008 15:40
From: Hewee Zetkin It looks like you are getting the resident key via HTTP at the same time you are requesting data with that key. At that point all you have is the name, unless I am missing your context. You'll have to wait for the HTTP response before you have the UUID and can ask whether the resident is online. Yes. Make the llRequestAgentData call once you have obtained the key. You've not posted all of the code involved, so I assume that there is a http_response() event there as well, but it needs to go there.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Dytska Vieria
+/- .00004™
Join date: 13 Dec 2006
Posts: 768
|
01-14-2008 15:55
In my script, I already have built a list of avatar UUID's, so it is not waiting for the http response. When I tested the scanner on myself and my uuid with this: --snippet in a for loop--- AVNotifyKey = (key) llList2String(NotifyListUUID, iLine); //my key 1st in list AVOnlineQuery = llRequestAgentData(AVNotifyKey, DATA_ONLINE);
--snippet---
dataserver(key QueryID, string Data) { if (QueryID == AVOnlineQuery) { if (Data == "1" || IMOffline == TRUE) { llInstantMessage(AVNotifyKey, IMMessage); } iLine++; AVNotifyKey = (key) llList2String(NotifyListUUID,iLine); if ((string) AVNotifyKey != "") { AVOnlineQuery = llRequestAgentData(AVNotifyKey, DATA_ONLINE); } } else { llOwnerSay("Unknown QueryID [" + (string)QueryID + "] Data = [" + Data + "]"); }
The first entry into dataserver always has the wrong QueryID BUT Data is correct! Data being 1 if avatar is online or 0 if not.
_____________________
+/- 0.00004
|
|
Kirth Hax
Registered User
Join date: 15 Mar 2007
Posts: 10
|
01-14-2008 22:04
Thanks for the feedback! There is indeed a http_response as well, where the uuid is obtained. This uuid looks absolutely correct both the 1st and 2nd call, only the data value differ. Furthermore, adding a 10s sleep after the http request does not change the situation a bit. Or does llSleep() shutdown also the event handler? BUT explicitly setting uuid with a fixed value before calling llRequestAgentData, I do not see this problem... I've just got to work here (Norway), so I cannot check on this now, but I'll try a few more things tonite. If I do not find the problem I'll post the code in its entirety.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
01-14-2008 22:28
I suspected there is an http_response handler, but here's the question: do you try to obtain resident online information before that http_response handler is called? If so, it would make sense that only the second and successive attempts would succeed, because the UUID wouldn't have been initialized on the first.
|
|
Beezle Warburton
=o.O=
Join date: 10 Nov 2006
Posts: 1,169
|
01-14-2008 22:31
Dataserver querys don't delay the script, so the rest of the script may run before the data is properly received.
I suggest using "states."
_____________________
Though this be madness, yet there is method in't. -- William Shakespeare Warburton's Whimsies: In SLApez.biz
|
|
Kirth Hax
Registered User
Join date: 15 Mar 2007
Posts: 10
|
01-15-2008 08:56
Thanks again everyone for tips. States would probably be a solution as well, but to be dead sure if it was the event handlers that clashed I tried a different approach. The call to llRequestAgentData is now made last in the http_response handler, thereby syncing these events. And Yes, this solves my problem! This is not always the most elegant solution though, I would be happy to see something like "llSync(eventID);"
|