OsMessageObject

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
 
(22 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{| width="100%" style="border: thin solid black"
+
{{osslfunc
| colspan="2" align="center" style=background:orange | '''{{SUBPAGENAME}}'''
+
|threat_level=Low
|- valign="top"
+
|permissions=${OSSL|osslParcelOG}ESTATE_MANAGER,ESTATE_OWNER
|'''Threat Level''' || <Threat Level goes here>
+
|delay=0
 
+
|function_syntax= osMessageObject(key primID, string message)
|- valign="top"
+
|ossl_example=This example consists of a sender script, and a receiver script.
|'''Function Syntax''' || <source lang="lsl">
+
: '''Sender script'''
osMessageObject(key objectUUID, string message);
+
<source lang = "lsl">
 +
// ----------------------------------------------------------------
 +
// Example / Sample Script to show function use.
 +
//
 +
default
 +
{
 +
    state_entry()
 +
    {
 +
        llSay(0, "Touch me to use osMessageObject to message an object");
 +
    }
 +
    touch_end(integer total_num)
 +
    {
 +
        key kTargetObj = "UUID"; //INSERT A VALID Object UUID here
 +
        string sSentence = "This message sent from a Sending object using osMessageObject";
 +
        osMessageObject(kTargetObj,sSentence);
 +
    }
 +
}
 
</source>
 
</source>
|- valign="top"
 
|'''Example(s)''' || <Examples go here (sender script, and reciever script)>
 
  
|}
 
  
Where ''objectUUID'' = the UUID of the object you are messaging.  
+
: '''Receiver script'''
 
+
<source lang = "lsl">
Where ''message'' = The String of data you want to send.
+
// Place this script in the Receiver prim.
 
+
default
Sends a message to to object identified by the given UUID, a script in the object must implement the dataserver function the dataserver function is passed the ID of the calling function and a string message.  
+
{
 +
    state_entry()
 +
    {
 +
        llSay(0, "osMessageObject Receiver Ready\nPlease replace UUID in osMessageObject Script (line 31) kTargetObj = "+(string)llGetKey());
 +
    }
 +
    dataserver(key query_id, string data)
 +
    {
 +
        llSay(0, "RECEIVER: The message received.\n\t query_id = "+(string)query_id+"\n\t msg = "+data);
 +
    }
 +
}
 +
</source>
 +
|description=
 +
''primID'' = the UUID of the prim you are messaging.  
 +
''message'' = The string you want to send.  
  
[[Category:OSSL_Functions]]
+
Sends a message to a prim identified by the given UUID, a script in the prim must implement the dataserver event handler. the dataserver event is passed the UUID of the calling prim and a string message.
[[Category:OSSL_functions_without_example]]
+
<div style="background-color:#FFA500; padding:10px; padding-bottom:5px; border: 1px #FF544F solid">
[[Category:OSSL_functions_without_threat_level]]
+
This is incompatible with the normal use of dataserver event on scripts on the receiving prim.<br>
 +
The dataserver query_id argument should be a unique id of a request. This function just uses it as a sender id. All scripts with dataserver event will receive it with no easy to validate. A normal request may also trigger the event on several scripts of the prim. The target one can compare the query_id and validate it, other scripts can not tell if it is a normal request for other script, or a message.<br>
 +
this unless the prims can know senders UUIDs and filter based on them
 +
</div>
 +
|
 +
}}

Latest revision as of 13:05, 27 October 2021

osMessageObject(key primID, string message)
primID = the UUID of the prim you are messaging.

message = The string you want to send.

Sends a message to a prim identified by the given UUID, a script in the prim must implement the dataserver event handler. the dataserver event is passed the UUID of the calling prim and a string message.

This is incompatible with the normal use of dataserver event on scripts on the receiving prim.
The dataserver query_id argument should be a unique id of a request. This function just uses it as a sender id. All scripts with dataserver event will receive it with no easy to validate. A normal request may also trigger the event on several scripts of the prim. The target one can compare the query_id and validate it, other scripts can not tell if it is a normal request for other script, or a message.
this unless the prims can know senders UUIDs and filter based on them

Threat Level Low
Permissions ${OSSL|osslParcelOG}ESTATE_MANAGER,ESTATE_OWNER
Extra Delay 0 seconds
Example(s)
This example consists of a sender script, and a receiver script.
Sender script
// ----------------------------------------------------------------
// Example / Sample Script to show function use.
//
default
{
    state_entry()
    {
        llSay(0, "Touch me to use osMessageObject to message an object");
    }
    touch_end(integer total_num)
    {
        key kTargetObj = "UUID"; //INSERT A VALID Object UUID here
        string sSentence = "This message sent from a Sending object using osMessageObject";
        osMessageObject(kTargetObj,sSentence);
    }
}


Receiver script
// Place this script in the Receiver prim.
default
{
    state_entry()
    {
        llSay(0, "osMessageObject Receiver Ready\nPlease replace UUID in osMessageObject Script (line 31) kTargetObj = "+(string)llGetKey());
    }
    dataserver(key query_id, string data)
    {
        llSay(0, "RECEIVER: The message received.\n\t query_id = "+(string)query_id+"\n\t msg = "+data);
    }
}
Personal tools
General
About This Wiki