From ba99081bbe42efa06f8b7a5bedb5db79afa99445 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 10 Nov 2009 03:36:43 +0000 Subject: Add IScriptModuleComms interface and region module to handle dispatch of script messages to region modules and sending back replies. Hook IScriptModuleComms.OnScriptCommand to see commands and use DispatchReply to reply to the script. It is recommended to pass the "id" parameter from the event as the "k" parameter of the reply. The script will receive the reply as a link message from link -1. --- .../ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 88b6091..d4facdd 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs @@ -26,6 +26,7 @@ */ using System; +using System.Reflection; using System.Collections; using System.Collections.Generic; using System.Runtime.Remoting.Lifetime; @@ -59,6 +60,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api internal uint m_localID; internal UUID m_itemID; internal bool m_MODFunctionsEnabled = false; + internal IScriptModuleComms m_comms = null; public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) { @@ -69,6 +71,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false)) m_MODFunctionsEnabled = true; + + m_comms = m_ScriptEngine.World.RequestModuleInterface(); + if (m_comms == null) + m_MODFunctionsEnabled = false; } public override Object InitializeLifetimeService() @@ -110,12 +116,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); } - public string modSendCommand(string modules, string command, string k) + public string modSendCommand(string module, string command, string k) { if (!m_MODFunctionsEnabled) - return ""; + { + MODShoutError("Module command functions not enabled"); + return UUID.Zero.ToString();; + } + + UUID req = UUID.Random(); + + m_comms.RaiseEvent(m_itemID, req.ToString(), module, command, k); - return ""; + return req.ToString(); } } } -- cgit v1.1