From ea27b95f8e27a9fc20b6ef25cdeea086f03a8fd5 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 4 Nov 2008 20:48:35 +0000 Subject: From: Rob Smart This patch allows an object to directly message another object given its key using the method osMessageObject(key objectUUID,string message). to communicate with an object it must implement the dataserver listener method. The dataserver method is passed the key of the calling object and a string message. --- .../Shared/Api/Implementation/OSSL_Api.cs | 33 ++++++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 7 +++++ .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 7 ++++- 3 files changed, 46 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index ee95342..ead88d5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -31,6 +31,7 @@ using System.Runtime.Remoting.Lifetime; using OpenMetaverse; using Nini.Config; using OpenSim; +using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; @@ -41,6 +42,13 @@ using OpenSim.Region.ScriptEngine.Interfaces; using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; using TPFlags = OpenSim.Framework.Constants.TeleportFlags; +using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; +using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; +using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; +using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; +using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; +using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; +using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; namespace OpenSim.Region.ScriptEngine.Shared.Api { @@ -91,6 +99,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi { internal IEventReceiver m_ScriptEngine; + internal ILSL_Api m_LSL_Api; // get a reference to the LSL API so we can call methods housed there internal SceneObjectPart m_host; internal uint m_localID; internal UUID m_itemID; @@ -106,6 +115,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host = host; m_localID = localID; m_itemID = itemID; + + if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) m_OSFunctionsEnabled = true; @@ -932,5 +943,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return jsondata; } + + // send 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 + public void osMessageObject(LSL_Key objectUUID,string message) + { + CheckThreatLevel(ThreatLevel.Low,"osMessageObject"); + m_host.AddScriptLPS(1); + + + object[] resobj = new object[] { new LSL_Types.LSLString(m_host.UUID.ToString()),new LSL_Types.LSLString(message) }; + + SceneObjectPart sceneOP = World.GetSceneObjectPart(new UUID(objectUUID)); + + m_ScriptEngine.PostObjectEvent( + sceneOP.LocalId, new EventParams( + "dataserver", resobj, + new DetectParams[0])); + + } + } + + } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 92b77a4..b1749f9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -26,6 +26,11 @@ */ using System.Collections; using OpenSim.Region.ScriptEngine.Interfaces; + +using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; +using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; +using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; + namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces { public enum ThreatLevel @@ -89,5 +94,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osSetParcelMediaTime(double time); Hashtable osParseJSON(string JSON); + void osMessageObject(key objectUUID,string message); + } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index d92ae7f..35a8830 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -35,9 +35,9 @@ using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.ScriptEngine.Interfaces; using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; -using key = System.String; using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; +using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { @@ -231,6 +231,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osParseJSON(JSON); } + + public void osMessageObject(key objectUUID,string message) + { + m_OSSL_Functions.osMessageObject(objectUUID,message); + } public OSSLPrim Prim; -- cgit v1.1