Jump to content

Time taken to update online status


GloriaGlitter
 Share

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

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

Recommended Posts

I have a script that will display the profile picture of a resident on a prim.  The object also has a linked prim below that will display a texture depending whether the resident is online or not and if online will set both linked prims to bright.  I've used some open source script which I've amended to suit my purpose.

Here is a picture of two of these objects- https://gyazo.com/4cecd0bcd757d662c9eccb55952d4659

My question relates to the time it can take to update the status from offline to online and vice versa - sometimes it can take up to 10 minutes to update but if I manually reset the script then it is pretty much instantaneous.  Is there something I could do to my script such as changing the timer time or something else to speed this up or this slowness due to having many copies of this object, each for a different resident?

Here is the script:
 
key user_key = "5b6e2121-5847-4b84-a260-3dd37f4d0d65";       // Gloria

string url = "http://world.secondlife.com/resident/";
key blank = "d21944ec-cd6d-91de-2701-4080dc90ceb7";  //UID of silhouette image
string name;

key toucher;
string status;
string mainMenuDialog;
list mainMenuButtons = [];
integer dialogChannel;
integer dialogHandle;
 
string profile_key_prefix = "<meta name=\"imageid\" content=\"";
string profile_img_prefix = "<img alt=\"profile image\" src=\"http://secondlife.com/app/image/";
integer profile_key_prefix_length; // calculated from profile_key_prefix in state_entry()
integer profile_img_prefix_length; // calculated from profile_img_prefix in state_entry()
 
 

open_menu(key inputKey, string inputString, list inputList)
{
    dialogChannel = (integer)llFrand(DEBUG_CHANNEL)*-1;
    dialogHandle = llListen(dialogChannel, "", inputKey, "");
    llDialog(inputKey, inputString, inputList, dialogChannel);
    llSetTimerEvent(60.0);
}
 
close_menu()
{
    llSetTimerEvent(0.0);// you can use 0 as well to save memory
    llListenRemove(dialogHandle);
}


string strReplace(string str, string search, string replace){
    return llDumpList2String(llParseStringKeepNulls((str = "") + str, [search], []), replace);
    }
 
default
{
    state_entry()
    {
        profile_key_prefix_length = llStringLength(profile_key_prefix);
        profile_img_prefix_length = llStringLength(profile_img_prefix);
        llSetText("", <1,0,0>, 1.0);
        llSetTexture(blank, ALL_SIDES);
        llRequestAgentData( user_key, DATA_NAME);
            
    }
    dataserver(key queryid, string data)
    {
        name = data;
        name=llToUpper(name);
        name = strReplace(name, "RESIDENT","");
        
       
        llSetObjectName("--- " + name + " ---");
        state show;
    }
}
state show
{   
    state_entry()
    {
        llSetTimerEvent(10);
    }
    timer()
    {
        llHTTPRequest( url + (string)user_key,[HTTP_METHOD,"GET"],"");
        llRequestAgentData( user_key, DATA_ONLINE);  
        close_menu();
       
    }
    on_rez(integer start_param)
    {
        llSetText("", <1,0,0>, 1.0);
        llSetTexture(blank, ALL_SIDES);
    }
    http_response(key request_id,integer status, list metadata, string body)
    {
        string profile_pic;
        integer s1 = llSubStringIndex(body, profile_key_prefix);
        integer s1l = profile_key_prefix_length;
        if(s1 == -1)
        { // second try
            s1 = llSubStringIndex(body, profile_img_prefix);
            s1l = profile_img_prefix_length;
        }
 
        if (s1 == -1)
        { // still no match?
            profile_pic = blank;
        }
        else
        {
            profile_pic = llGetSubString(body,s1 + s1l, s1 + s1l + 35);
            if (profile_pic == (string)NULL_KEY)
            {
                profile_pic = blank;
            }
        }
        llSetTexture(profile_pic, ALL_SIDES);
    }
    dataserver(key queryid, string data)
    {
        if ( data == "1" )
        {
            llSetLinkTexture(2,"0c636dfb-74fa-b375-d145-fde043b5e1d1",ALL_SIDES);
            llSetLinkPrimitiveParamsFast(2,[ PRIM_FULLBRIGHT, ALL_SIDES, TRUE ]);
            llSetLinkPrimitiveParamsFast(1,[ PRIM_FULLBRIGHT, ALL_SIDES, TRUE ]);
        }
        else if (data == "0")
        {
            llSetLinkTexture(2,"18a4e4ac-4126-60e6-17f8-d3cbc320dbd0",ALL_SIDES);
            llSetLinkPrimitiveParamsFast(2,[ PRIM_FULLBRIGHT, ALL_SIDES,FALSE ]);
            llSetLinkPrimitiveParamsFast(1,[ PRIM_FULLBRIGHT, ALL_SIDES,FALSE ]);
        }
 
    }
    touch_start(integer num_detected)
    {
        toucher = llDetectedKey(0);
        close_menu();
        mainMenuDialog = "\nClick link to open profile and/or send IM to secondlife:///app/agent/" + (string)user_key + "/about";
        open_menu(toucher, mainMenuDialog, mainMenuButtons);
    }
}

 

Link to comment
Share on other sites

As written, the timer engages as soon as you get past the initial startup steps.  It triggers the http_response event ten seconds later and then, thanks to the close_menu routine, shuts the timer off completely.  It only checks again if someone clicks the object.  That runs the open_menu routine that keeps a timer open for the next 60 seconds.  Then the close_menu event kills it again.  So, if you want to keep the thing alive longer at any point, you'll have to play with the timer.   Right now, though, it looks pretty good.  The only reason I can imagine for slow response would be lag.

Link to comment
Share on other sites

There is no listen event in that script. The menu will not work then and is completely useless in that state.

The timer has to do 2 tasks: check for online status and remove the listen if the menu times out. (which doesnt work anyways without listen)

So either remove the whole menu thing or make the menu functional and change the timer so it can differentiate if it was triggered by menu timeout or online status update.

Link to comment
Share on other sites

Thanks Rolig.  So, the open and close menu routines are for when someone clicks the object to view the relevant resident's profile - is the close_menu routine in the http_response section superfluous and can I get rid of it and could that help with my problem?

edit  - just saw reply from Nova as I posted this.  Thanks Nova, will look at the menu part.

Edited by GloriaGlitter
Link to comment
Share on other sites

2 minutes ago, Nova Convair said:

There is no listen event in that script. The menu will not work then and is completely useless in that state.

Ooops.  I completely overlooked that myself.  D'uh.  Yeah, it needs a listen event to receive the result from llDialog and use it to get a UUID for the timer event to use in place of user_key.

Link to comment
Share on other sites

Removing the close_menu function and calls to it rather than putting in a listener, looks like it might have solved the problem - an object relating to a resident who came online lit up within a minute now.  I'll place the amended script now in all the objects and monitor this.  Thanks both.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1496 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...