From 530cc2488461a4ef68a06eaba42698fcdc09f459 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 19 Feb 2008 19:16:21 +0000 Subject: From: Michael Osias This patch implements the llSendRemoteData command and fixes mantis 552, and possibly 586. --- .../Region/ScriptEngine/Common/LSL_BaseClass.cs | 4 + .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 4 +- .../ScriptEngineBase/AsyncLSLCommandManager.cs | 104 ++++++++++++++++----- .../Common/ScriptEngineBase/ScriptManager.cs | 56 ++++++----- 4 files changed, 118 insertions(+), 50 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BaseClass.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BaseClass.cs index 7713490..60a1cb3 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BaseClass.cs @@ -2091,6 +2091,10 @@ namespace OpenSim.Region.ScriptEngine.Common public const int REMOTE_DATA_CHANNEL = 1; public const int REMOTE_DATA_REQUEST = 2; public const int REMOTE_DATA_REPLY = 3; + public const int HTTP_METHOD = 0; + public const int HTTP_MIMETYPE = 1; + public const int HTTP_BODY_MAXLENGTH = 2; + public const int HTTP_VERIFY_CERT = 3; public const int PRIM_MATERIAL = 2; public const int PRIM_PHYSICS = 3; diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index c07f6d7..1ab2a43 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -2880,8 +2880,8 @@ namespace OpenSim.Region.ScriptEngine.Common public string llSendRemoteData(string channel, string dest, int idata, string sdata) { m_host.AddScriptLPS(1); - NotImplemented("llSendRemoteData"); - return String.Empty; + IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface(); + return (xmlrpcMod.SendRemoteData(m_localID, m_itemID, channel, dest, idata, sdata)).ToString(); } public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncLSLCommandManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncLSLCommandManager.cs index 1afe71c..0491612 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncLSLCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncLSLCommandManager.cs @@ -125,8 +125,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase comms.DeleteListener(itemID); IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface(); - xmlrpc.DeleteChannel(itemID); + xmlrpc.DeleteChannels(itemID); + xmlrpc.CancelSRDRequests(itemID); + } #region TIMER @@ -238,24 +240,29 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase // implemented here yet anyway. Should be fixed if/when maxsize // is supported - object[] resobj = new object[] + if (m_ScriptEngine.m_ScriptManager.GetScript(httpInfo.localID, httpInfo.itemID) != null) + { + iHttpReq.RemoveCompletedRequest(httpInfo.reqID); + object[] resobj = new object[] { httpInfo.reqID.ToString(), httpInfo.status, null, httpInfo.response_body }; - m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( - httpInfo.localID, httpInfo.itemID, "http_response", EventQueueManager.llDetectNull, resobj + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( + httpInfo.localID, httpInfo.itemID, "http_response", EventQueueManager.llDetectNull, resobj ); - httpInfo.Stop(); - httpInfo = null; + } httpInfo = iHttpReq.GetNextCompletedRequest(); + } } #endregion + #region Check llRemoteData channels + public void CheckXMLRPCRequests() { if (m_ScriptEngine.World == null) @@ -265,47 +272,96 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase if (xmlrpc != null) { - while (xmlrpc.hasRequests()) + RPCRequestInfo rInfo = xmlrpc.GetNextCompletedRequest(); + + while (rInfo != null) { - RPCRequestInfo rInfo = xmlrpc.GetNextRequest(); - //Console.WriteLine("PICKED REQUEST"); + if (m_ScriptEngine.m_ScriptManager.GetScript(rInfo.GetLocalID(), rInfo.GetItemID()) != null) + { + xmlrpc.RemoveCompletedRequest(rInfo.GetMessageID()); - //Deliver data to prim's remote_data handler - object[] resobj = new object[] + //Deliver data to prim's remote_data handler + object[] resobj = new object[] { 2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), String.Empty, rInfo.GetIntValue(), rInfo.GetStrVal() }; - m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( - rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", EventQueueManager.llDetectNull, resobj + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( + rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", EventQueueManager.llDetectNull, resobj ); + + } + + rInfo = xmlrpc.GetNextCompletedRequest(); + } + + SendRemoteDataRequest srdInfo = xmlrpc.GetNextCompletedSRDRequest(); + + while (srdInfo != null) + { + if (m_ScriptEngine.m_ScriptManager.GetScript(srdInfo.m_localID, srdInfo.m_itemID) != null) + { + xmlrpc.RemoveCompletedSRDRequest(srdInfo.GetReqID()); + + //Deliver data to prim's remote_data handler + object[] resobj = new object[] + { + 3, srdInfo.channel.ToString(), srdInfo.GetReqID().ToString(), String.Empty, + srdInfo.idata, + srdInfo.sdata + }; + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( + srdInfo.m_localID, srdInfo.m_itemID, "remote_data", EventQueueManager.llDetectNull, resobj + ); + + } + + srdInfo = xmlrpc.GetNextCompletedSRDRequest(); + + } + + } } + #endregion + + #region Check llListeners + public void CheckListeners() { if (m_ScriptEngine.World == null) return; IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface(); - while (comms.HasMessages()) + if (comms != null) { - ListenerInfo lInfo = comms.GetNextMessage(); - - //Deliver data to prim's listen handler - object[] resobj = new object[] + while (comms.HasMessages()) + { + if (m_ScriptEngine.m_ScriptManager.GetScript( + comms.PeekNextMessageLocalID(), comms.PeekNextMessageItemID()) != null) { - lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage() - }; + ListenerInfo lInfo = comms.GetNextMessage(); - m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( - lInfo.GetLocalID(), lInfo.GetItemID(), "listen", EventQueueManager.llDetectNull, resobj - ); + //Deliver data to prim's listen handler + object[] resobj = new object[] + { + lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage() + }; + + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( + lInfo.GetLocalID(), lInfo.GetItemID(), "listen", EventQueueManager.llDetectNull, resobj + ); + } + + } } } + #endregion + /// /// If set to true then threads and stuff should try to make a graceful exit /// @@ -317,4 +373,4 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase private bool _PleaseShutdown = false; } -} \ No newline at end of file +} diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs index 641453e..d47cab8 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs @@ -67,6 +67,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase private Queue LUQueue = new Queue(); private static bool PrivateThread; private int LoadUnloadMaxQueueSize; + private Object scriptLock = new Object(); // Load/Unload structure private struct LUStruct @@ -304,7 +305,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase //ScriptBaseInterface Script = (ScriptBaseInterface)GetScript(localID, itemID); IScript Script = GetScript(localID, itemID); if (Script == null) + { return; + } //cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined ///#if DEBUG /// Console.WriteLine("ScriptEngine: Executing event: " + FunctionName); @@ -331,37 +334,42 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase public IScript GetScript(uint localID, LLUUID itemID) { - if (Scripts.ContainsKey(localID) == false) - return null; - - Dictionary Obj; - Scripts.TryGetValue(localID, out Obj); - if (Obj.ContainsKey(itemID) == false) - return null; - - // Get script - IScript Script; - Obj.TryGetValue(itemID, out Script); - - return Script; + lock (scriptLock) + { + if (Scripts.ContainsKey(localID) == false) + return null; + + Dictionary Obj; + Scripts.TryGetValue(localID, out Obj); + if (Obj.ContainsKey(itemID) == false) + return null; + + // Get script + IScript Script; + Obj.TryGetValue(itemID, out Script); + return Script; + } } public void SetScript(uint localID, LLUUID itemID, IScript Script) { - // Create object if it doesn't exist - if (Scripts.ContainsKey(localID) == false) + lock (scriptLock) { - Scripts.Add(localID, new Dictionary()); - } + // Create object if it doesn't exist + if (Scripts.ContainsKey(localID) == false) + { + Scripts.Add(localID, new Dictionary()); + } - // Delete script if it exists - Dictionary Obj; - Scripts.TryGetValue(localID, out Obj); - if (Obj.ContainsKey(itemID) == true) - Obj.Remove(itemID); + // Delete script if it exists + Dictionary Obj; + Scripts.TryGetValue(localID, out Obj); + if (Obj.ContainsKey(itemID) == true) + Obj.Remove(itemID); - // Add to object - Obj.Add(itemID, Script); + // Add to object + Obj.Add(itemID, Script); + } } public void RemoveScript(uint localID, LLUUID itemID) -- cgit v1.1