Jump to content

LinkMessage Monitor


LepreKhaun
 Share

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

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

Recommended Posts

While working on a calendar/scheduling application that has (at the moment) three scripts messaging each other, I found a need to monitor the messages to debug the interactions. This is the program I wrote for this and I'm sharing it with the community for others that may have a need for such.

Link messages aren't so much script to script as they are link node to link node. In other words, all scripts within a link node receive a link_message addressed to that link. So a monitor script only has to be placed within the prim(s) you wish to listen in on and then communicate to you what traffic they overhear. That way one can check that the messages are:

  1. Being formatted correctly.
  2. Getting sent when they should.
  3. Arriving in the correct location.
  4. Being acknowledged as needed.

 

I made the usage of LinkMessage Monitor as simple and straightforward as possible. One simply places a monitor script in each prim of the linkset one wishes to eavesdrop on and chat "ON" to have them begin monitoring the traffic. Say "OFF" to quiet them and, when you're finished with the debugging session, chat the word "DONE" and they'll remove themselves.

For advanced usage within multiple prims, one can uncomment the line within default > state_entry > "listenChannel = llGetLinkNumber();" This will make each monitor separately addressable, simply proceed a command with the link number as a channel. As in (addressing a monitor in link #3) "/3 OFF", "/3 ON", "/3 DONE". This allows you to "tune in" as needed to specific parts of the interactions in complex arrangements.

Also, the commands ("ON", "OFF" and "DONE") can be changed if they conflict with your existing application chat commands.

The format of the chatted reports (which also might be easily changed to suit one's needs) is:

  • A timestamp
  • From: link number of originating prim
  • To  : link number of prim message is arriving at
  • INT: integer parameter of Link Message
  • STR: string parameter of Link Message
  • KEY: key parameter of Link Message

 

A sample debugging session, checking on a timing "heartbeat" from a (brain) script in link 2 to a (user interface) script in link 1, which uses it to update a clock/calendar every 60 seconds. The message protocol is: COMMAND string: "T", DATA integer: current_time, MODIFIER key: an alarm key when necessary:

[11:38] LepreKhaun: ON
[11:38] Calendar: LinkMessage Monitor in Link #1 is Now ON
[11:39] Calendar: 2014-01-03T19:39:05.120482Z
From: 2
To  : 1
INT: 1388749145
STR: T
KEY: 

[11:40] Calendar: 2014-01-03T19:40:05.138262Z
From: 2
To  : 1
INT: 1388749205
STR: T
KEY: 

[11:41] Calendar: 2014-01-03T19:41:05.130397Z
From: 2
To  : 1
INT: 1388749265
STR: T
KEY: 

[11:41] LepreKhaun: OFF
[11:41] Calendar: LinkMessage Monitor in Link #1 is Now OFF
[11:41] LepreKhaun: DONE
[11:41] Calendar: LinkMessage Monitor in Link #1 is DONE!

 

The script itself; use, modify, pass on for free as you wish. Leave headers intact, please.

 [ EDIT: Added new function "uSpeak" on 1/4/04. TY Sassy! ]

 

//////////////////////////////////////////////
//                  LinkMessage_Monitor.lsl
//
//      A debugging script for chatting of intercepted Link Messages
//
//              By LepreKhaun Resident - Jan 3, 2014
//      This header must remain intact when copied, modified or used
// VERSION: 0.5 1/4/04 - Added uSpeak function to control output mode
//               (Credited to suggestion made by Sassy Romano)
//
// USAGE: Place a copy of script in each prim of a linkset that you wish
//          to monitor the link message traffic within. Once placed, chat "ON"
//          and the script(s) will begin repeating link messages on chat to the owner.
//          Chat "OFF" to silence and "ON" again for chat reports.
//          Chat "DONE" to end debugging session and script(s) will remove themselves.
//        For multiple prims, each script can be individually addressed with chat commands
//          by uncommenting the line within default > state_entry > "listenChannel = llGetLinkNumber();"
//          and then chatting "/link_number ON/OFF/DONE" where link_number is the integer of the
//          link number containing the script you wish to control.
//////////////////////////////////////////////


// Change these command strings in case of conflict
string ON   = "ON";
string OFF  = "OFF";
string DONE = "DONE";


string owner;

// Defaults to PUBLIC_CHANNEL
integer listenChannel = 0;

// Function to control how information is output
uSpeak(string msg)
{
    // default output method, recommended
    llOwnerSay(msg);
    
    //////////////
    // Custom output method
    //   uncomment the following statements and change to suit
    // Set key to UID of object or avatar you wish to direct the chat to
    // key target = NULL_KEY;
    
    // Change ONLY when speaking to an object with the 
    //   same channel open on their listen handle
    // integer channel = PUBLIC_CHANNEL;
    
    // llRegionSayTo(target, channel, msg);
    //////////////
}

default
{
    state_entry()
    {
        owner = llGetOwner();
        
        // Uncomment next statement if you want to make this script
        // command-able by chatting on the channel of its link number
        // listenChannel = llGetLinkNumber();
        
        // But all scripts initially listen together
        llListen(PUBLIC_CHANNEL, "", owner, "");
    }
    
    listen(integer channel, string name, key id, string message)
    {
        if(message == ON)
            state monitorOn;
    }
}

state monitorOn
{
    state_entry()
    {
        // Listen for commands only from owner
        llListen(listenChannel, "", owner, "");
        uSpeak("LinkMessage Monitor in Link #" + (string)llGetLinkNumber() + " is Now ON");
    }
    
    listen(integer channel, string name, key id, string message)
    {
        if(message == OFF)
            state monitorOff;
        else if(message == DONE)
            {
                uSpeak("LinkMessage Monitor in Link #" + (string)llGetLinkNumber() + " is DONE!");
                llRemoveInventory(llGetScriptName());
            }
    }    
    
    link_message(integer sender_num, integer num, string str, key id)
    {
        uSpeak(
            llGetTimestamp() + "\n" +
            "From: " + (string)sender_num + "\n" +
            "To  : " + (string)llGetLinkNumber() + "\n" +
            "INT: " + (string)num + "\n" +
            "STR: " + str + "\n" +
            "KEY: " + (string)id + "\n"
        );
    }
}

state monitorOff
{
    state_entry()
    {
        // Listen for commands only from owner
        llListen(listenChannel, "", owner, "");
        uSpeak("LinkMessage Monitor in Link #" + (string)llGetLinkNumber() + " is Now OFF");
   }

    listen(integer channel, string name, key id, string message)
    {
        if(message == ON)
            state monitorOn;
        else if(message == DONE)
            {
                uSpeak("LinkMessage Monitor in Link #" + (string)llGetLinkNumber() + " is DONE!");
                llRemoveInventory(llGetScriptName());
            }
    }
}

 

Comments, corrections, suggestions welcome as always.

 

  • Like 2
Link to comment
Share on other sites

Monitoring messages in a linkset is a brilliant idea for debugging purposes

I often use this universal script for it

default{    link_message(integer sender_num, integer num, string msg, key id)    {        llOwnerSay( "num: "+(string)num+", msg: "+msg+", key: "+(string)id);    }}

 It doesn't expect and it doesn't check any rules,
but it shows all link messages send from any script in a prim and all link messages coming to the same prim

This particular version was made to monitor messages between scripts in the root prim, so it doesn't show the number of the sending prim

:smileysurprised::):smileyvery-happy:

  • Like 1
Link to comment
Share on other sites


Dora Gustafson wrote:

Monitoring messages in a linkset is a brilliant idea for debugging purposes

I often use this universal script for it
default{    link_message(integer sender_num, integer num, string msg, key id)    {        llOwnerSay( "num: "+(string)num+", msg: "+msg+", key: "+(string)id);    }}

 It doesn't expect and it doesn't check any rules,

but it shows all link messages send from any script in a prim and all link messages coming to the same prim

This particular version was made to monitor messages between scripts in the root prim, so it doesn't show the number of the sending prim

:smileysurprised:
:)
:smileyvery-happy:

Ahhh, how I envy those of you that need nothing more. Thank you for sharing the minimal approach!

Link to comment
Share on other sites

I have a similar thing that I made into a "kit" such that I could give a debug thing to my customers.  It would then add the sending script to the product they had bought from me via an updater, it would then send the link messages to a HUD that I wore.

At the time, only llSay (and similar) was available so I also went to the trouble of encrypting the data.  RegionSayTo would mitigate this now somewhat.

  • Like 1
Link to comment
Share on other sites

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