Jump to content

Help passing a list of keys to the dataserver...


Life Camino
 Share

You are about to reply to a thread that has been inactive for 3545 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I'm receiving a list of keys in the http_response event and I need to pass that list of keys, one at a time, to the dataserver to populate a names list generated from the keys.  The problem I am having is that it passes one, maybe two keys to the dataserver, then the rest of the dataserver requests are dropped.

Does anyone have any suggestions of how I should construct the loop to pass these keys to the dataserver so that the requests are not dropped?

Thanks,

Life

Link to comment
Share on other sites

Use a global counter.

Pass the first key to the dataserver.

After that the dataserver event comes back with the data.
Do whatever you want with the data, then, from inside the dataserver event, update the counter and pass the next key.

Rince and repeat.

For instance:

integer count;list keys;default {    state_entry() {        llRequestAgentData(keys, count);    }    dataserver(key queryid, string data) {        // use data        ++count;        llRequestAgentData(keys, count);    }}

 

Link to comment
Share on other sites


Life Camino wrote:

 The problem I am having is that it passes one, maybe two keys to the dataserver, then the rest of the dataserver requests are dropped.

I'm curious what's really going on here. Is it really "one, maybe two" queries before stuff gets dropped?

I'd expected that the list had scores of keys, and the corrsponding queries went out all in a loop, so that by the time the script released control from the http_response handler, a bunch of dataserver events had fallen off the event buffer.

Were that the case, llSleep() would have no benefit, other than to delay getting around to processing the long-since overflowed event buffer.

On the other hand, that would not explain getting only one or two dataserver events into the queue, unless there were other events also flooding the script's buffer.

Link to comment
Share on other sites

Here is an example of how to use a boolean integer as a switch to toggle modes between key list gathering and request agent data.  Here we use a sensor, but you should get the gist and be able to design something similar for your project.  Note the timer discipline where we stop the timer during processing, so we don't get overlap.

 

/*

Sensor and Request Agent Data Processing Script
By Yingzi Xue 08-11-14

An example of how you can use an integer as a toggle switch
for controlling functionality in your scripts. On touch the
script gathers an avatar list with a sensor and then uses
the list to request agent data for each detected avatar.
The returned data is then said to the owner via chat. When
all data is retrieved, the switch is thrown, the avatar list
is cleared and the script goes dormant, waiting for the next
touch.

You may use this script or pieces parts for your projects
as long as you keep this header intact.

*/

key request_id; // Request ID for llRequestAgentDatainteger switch; // Toggle between sensor and request agent datalist avatar_list; // Avatar list generator from sensor eventfloat interval = 0.2; // Timer interval in secondsinteger request_counter; // Avatar list pointerdefault{ touch_end(integer touches) { // Initiate processing if (switch == FALSE) llSetTimerEvent(interval); } timer() { llSetTimerEvent(0); // Stop timer to process if (switch == TRUE) // Request mode { // Done processing requests? if (request_counter == llGetListLength(avatar_list)) { avatar_list = []; request_counter = 0; switch = FALSE; // Flip our switch return; } // Request data request_id = llRequestAgentData(llList2Key(avatar_list,request_counter),DATA_BORN); llSetTimerEvent(interval); } else if (switch == FALSE) // Avatar list mode { // Sense avatars llSensor("","",AGENT_BY_LEGACY_NAME,96.0,PI); } } dataserver(key queryid, string data) { if (request_id == queryid) { // Process requested data llOwnerSay("User: "+llKey2Name(llList2Key(avatar_list,request_counter))+", Date Born: "+data); // Next avatar request_counter++; } } sensor(integer avatars) { if (avatars) { // Gather avatars found into a list of keys integer counter; for(counter = 0; counter < avatars; counter++) { if (llDetectedKey(counter) != llGetOwner()) { avatar_list += llDetectedKey(counter); } } // Start the request process by flipping our switch switch = TRUE; llSetTimerEvent(interval); } }}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3545 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...