User:Void Singer/Tea Strainer

From Second Life Wiki
Jump to: navigation, search

Tea Strainer

What is it?

Tea Strainer is a small utility script to debug the messages being passed to and from Teacup.

How Does it Work?

By intercepting the link message traffic in the prim Teacup resides in, it checks for messages that Teacup and it's components are passing back and forth to and outputs them as llOwnerSay messages. All currently known protocols are properly parsed, and unknown messages are labeled and output in condensed format as well.

Code

Tea Strainer


  • Save in a MONO script named "Tea Strainer v0.5"
/*( Tea Strainer v0.5 )*/
 
integer gIntAct; //-- pre-declaration for speed
integer gIntCnt; //-- Allow visual tracking since last reset
 
//-- optimized for speed, NOT size
 
default{
	link_message( integer vIntSrc, integer vIntDta, string vStrDta, key vKeyDta ){
		if (vKeyDta){
			if (~gIntAct = llListFindList( [204, 202, 201, 200, 100, 403, 404, 418], [vIntDta] )){
				if (4 & gIntAct){ if (2 & gIntAct){ if (1 & gIntAct){
					llOwnerSay( (string)(++gIntCnt) + ": ‘" + (string)vKeyDta + "’ Server Query: 418 “" + llGetSubString( vStrDta, 0, 35 ) + llList2String( ["”…", "”"], llStringLength( vStrDta ) < 37 ) );
				}else{
					llOwnerSay( (string)(++gIntCnt) + ": ‘" + (string)vKeyDta + "’ Service Reply: 404 'Not Found'" );
				}}else if (1 & gIntAct){
					llOwnerSay( (string)(++gIntCnt) + ": ‘" + (string)vKeyDta + "’ Service Reply: 403 'Forbidden'" );
				}else{
					llOwnerSay( (string)(++gIntCnt) + ": ‘" + (string)vKeyDta + "’ Service Reply: 100 'Continue'" );
				}}else if (2 & gIntAct){ if (1 & gIntAct){
					llOwnerSay( (string)(++gIntCnt) + ": ‘" + (string)vKeyDta + "’ Service Reply: 200 'Success'" );
				}else{
					llOwnerSay( (string)(++gIntCnt) + ": ‘" + (string)vKeyDta + "’ Service Reply: 201 'Created'" );
				}}else if (1 & gIntAct){
					llOwnerSay( (string)(++gIntCnt) + ": ‘" + (string)vKeyDta + "’ Service Reply: 202 'Accepted'" );
				}else{
					llOwnerSay( (string)(++gIntCnt) + ": ‘" + (string)vKeyDta + "’ Service Reply: 204 'No Content'" );
				}
			}else{
				llOwnerSay( "Received unknown message from link (" + (string)vIntSrc + ")“" +
				  llGetLinkName( vIntSrc ) +"”\n{(" + (string)vIntDta + "), “" + llGetSubString( vStrDta, 0, 35 ) +
				  llList2String( ["”…, ‘", "”, ‘"], llStringLength( vStrDta ) < 37 ) + (string)vKeyDta + "’}" );
			}
		}else if (NULL_KEY == (string)vKeyDta){
			if (~gIntAct = llListFindList( [418, 600, 601], [vIntDta] )){
				if (2 & gIntAct){ /*if (1 & gIntAct){
					//-- unused
				}else*/{
					llOwnerSay( (string)(++gIntCnt) + ": " + "File Service: 601 'File Added' “" + vStrDta + "”" );
				}}else if (1 & gIntAct){
					llOwnerSay( (string)(++gIntCnt) + ": " + "File Service: 600 'File Removed' “" + vStrDta + "”" );
				}else{
					if ("Teacup URL changed" == vStrDta){
						vStrDta += "”\n“ " + llList2String( llGetPrimitiveParams( [PRIM_TEXT] ), 0 ) + " ";
						gIntCnt = 0;
					}
					llOwnerSay( (string)(++gIntCnt) + ": " + "General Advertisement: “" + vStrDta + "”" );
				}
			}else{
				llOwnerSay( "Received unknown message from link (" + (string)vIntSrc + ")“" +
				  llGetLinkName( vIntSrc ) +"”\n{(" + (string)vIntDta + "), “" + llGetSubString( vStrDta, 0, 35 ) +
				  llList2String( ["”…, ‘", "”, ‘"], llStringLength( vStrDta ) < 37 ) + (string)vKeyDta + "’}" );
			}
		}else{
			llOwnerSay( "Received unknown message from link (" +
			  (string)vIntSrc + ")“" + llGetLinkName( vIntSrc ) +"”\n{(" + (string)vIntDta + "), “" +
			  llGetSubString( vStrDta, 0, 35 ) + llList2String( ["”…, ‘", "”, ‘"], llStringLength( vStrDta ) < 37 ) +
			  llGetSubString( vKeyDta, 0, 35 ) + llList2String( ["’…}", "’}"], llStringLength( vKeyDta ) < 37 ) );
		}
	}
}
/*//--                           License Text                           --//*/
/*//  Free to copy, use, modify, distribute, or sell, with attribution.   //*/
/*//    (C)2011 (CC-BY) [ http://creativecommons.org/licenses/by/3.0 ]    //*/
/*//   Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ]  //*/
/*//  All usages must contain a plain text copy of the previous 2 lines.  //*/
/*//--                                                                  --//*/
Return to top

Notes

Compatible Servers, File Systems, and Extensions


  • Teacup - SIP front end
  • Red Tea - A very simple SIP back end File Service for a starting point.
  • Region Stats - A single page Extension that gets live data from the region and refreshes every minute
  • Saucer - Optional Fast 404 Extension for preventing long timeouts for missing/bad pages

Known Bugs


  • None
  • Limitation: only receives messages sent to the prim it's in, may be useful for troubleshooting

Requested Feature Upgrades


  • If you add an extension for Teacup and it has any messages not covered, add a note here and I'll see about adding it. All additions must comply with current protocol limitations as noted for Teacup server

Change Log / Old Versions


Most Recent Changes are at the top, old version links below.

  • Version will be considered stable when it reaches 1.0
  • Tea Strainer v0.5
    • Added 403 recognition
    • version jump to match Teacup
  • Tea Strainer v0.03.1
    • Initial Public Release
Return to top

Questions or Comments?

Feel free to leave me a note on the discussion page.