From ac65085cc36bb4820482bf769b4be44e1c8d58ce Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 3 Dec 2012 20:09:54 -0500 Subject: XmlRpcGridRouter Flesh out XmlRpcGridRouter to reap unused channels from gateway when scripts or objects are removed, or when the llCloseRemoteDataChannel is called. See: http://http://forge.opensimulator.org/gf/project/xmlrpcrouter/ or https://github.com/BlueWall/XmlRpcRouter for php gateway and test code. --- .../Region/Framework/Interfaces/IXmlRpcRouter.cs | 1 + .../XmlRpcRouterModule/XmlRpcGridRouterModule.cs | 82 +++++++++++++++++----- .../XmlRpcRouterModule/XmlRpcRouterModule.cs | 6 ++ .../Shared/Api/Implementation/LSL_Api.cs | 7 ++ 4 files changed, 77 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Interfaces/IXmlRpcRouter.cs b/OpenSim/Region/Framework/Interfaces/IXmlRpcRouter.cs index 6db6674..093d3f0 100644 --- a/OpenSim/Region/Framework/Interfaces/IXmlRpcRouter.cs +++ b/OpenSim/Region/Framework/Interfaces/IXmlRpcRouter.cs @@ -34,5 +34,6 @@ namespace OpenSim.Region.Framework.Interfaces void RegisterNewReceiver(IScriptModule scriptEngine, UUID channelID, UUID objectID, UUID itemID, string url); void ScriptRemoved(UUID itemID); void ObjectRemoved(UUID objectID); + void UnRegisterReceiver(string channelID, UUID itemID); } } diff --git a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs index 6120a81..709d389 100644 --- a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs @@ -46,6 +46,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule { public class XmlRpcInfo { + public UUID item; public UUID channel; public string uri; } @@ -88,6 +89,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule return; scene.RegisterModuleInterface(this); + + IScriptModule scriptEngine = scene.RequestModuleInterface(); + if ( scriptEngine != null ) + { + scriptEngine.OnScriptRemoved += this.ScriptRemoved; + scriptEngine.OnObjectRemoved += this.ObjectRemoved; + + } } public void RegionLoaded(Scene scene) @@ -120,22 +129,36 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) { - if (!m_Channels.ContainsKey(itemID)) - { - XmlRpcInfo info = new XmlRpcInfo(); - info.channel = channel; - info.uri = uri; + if (!m_Enabled) + return; - bool success = SynchronousRestObjectRequester.MakeRequest( - "POST", m_ServerURI+"/RegisterChannel/", info); + m_log.InfoFormat("[XMLRPC GRID ROUTER]: New receiver Obj: {0} Ch: {1} ID: {2} URI: {3}", + objectID.ToString(), channel.ToString(), itemID.ToString(), uri); - if (!success) - { - m_log.Error("[XMLRPC GRID ROUTER] Error contacting server"); - } + XmlRpcInfo info = new XmlRpcInfo(); + info.channel = channel; + info.uri = uri; + info.item = itemID; + + bool success = SynchronousRestObjectRequester.MakeRequest( + "POST", m_ServerURI+"/RegisterChannel/", info); - m_Channels[itemID] = channel; + if (!success) + { + m_log.Error("[XMLRPC GRID ROUTER] Error contacting server"); } + + m_Channels[itemID] = channel; + + } + + public void UnRegisterReceiver(string channelID, UUID itemID) + { + if (!m_Enabled) + return; + + RemoveChannel(itemID); + } public void ScriptRemoved(UUID itemID) @@ -143,10 +166,33 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule if (!m_Enabled) return; - if (m_Channels.ContainsKey(itemID)) + RemoveChannel(itemID); + + } + + public void ObjectRemoved(UUID objectID) + { + // m_log.InfoFormat("[XMLRPC GRID ROUTER]: Object Removed {0}",objectID.ToString()); + } + + private bool RemoveChannel(UUID itemID) + { + if(!m_Channels.ContainsKey(itemID)) + { + m_log.InfoFormat("[XMLRPC GRID ROUTER]: Attempted to unregister non-existing Item: {0}", itemID.ToString()); + return false; + } + + XmlRpcInfo info = new XmlRpcInfo(); + + info.channel = m_Channels[itemID]; + info.item = itemID; + info.uri = "http://0.0.0.0:00"; + + if (info != null) { - bool success = SynchronousRestObjectRequester.MakeRequest( - "POST", m_ServerURI+"/RemoveChannel/", m_Channels[itemID]); + bool success = SynchronousRestObjectRequester.MakeRequest( + "POST", m_ServerURI+"/RemoveChannel/", info); if (!success) { @@ -154,11 +200,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule } m_Channels.Remove(itemID); + return true; } - } - - public void ObjectRemoved(UUID objectID) - { + return false; } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs index 4783f4c..ad0b83d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs @@ -101,12 +101,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule scriptEngine.PostScriptEvent(itemID, "xmlrpc_uri", new Object[] {uri}); } + public void UnRegisterReceiver(string channelID, UUID itemID) + { + } + public void ScriptRemoved(UUID itemID) { + System.Console.WriteLine("TEST Script Removed!"); } public void ObjectRemoved(UUID objectID) { + System.Console.WriteLine("TEST Obj Removed!"); } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index acf4d8c..4108588 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -6856,6 +6856,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llCloseRemoteDataChannel(string channel) { m_host.AddScriptLPS(1); + + IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface(); + if (xmlRpcRouter != null) + { + xmlRpcRouter.UnRegisterReceiver(channel, m_item.ItemID); + } + IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface(); xmlrpcMod.CloseXMLRPCChannel((UUID)channel); ScriptSleep(1000); -- cgit v1.1