From f773733fcb6ef18ddb70d597cdf6f1e334dcf13e Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 13 Dec 2007 19:50:21 +0000 Subject: [PATCH] From Michael Osias (IBM) This patch makes some enhancements to the llRemoteData functions. The module is now a shared module, and allows remote data channels to be created among multiple regions in the same sim. The port is controlled from the remoteDataPort property under the [Network] section in OpenSim.ini. If this setting is not present or = 0, the module is disabled and no port is opened. llRemoteData commands have not effect when module is disabled. --- .../Region/Environment/Interfaces/IXMLRPC.cs | 1 + OpenSim/Region/Environment/ModuleLoader.cs | 3 ++ .../Environment/Modules/XMLRPCModule.cs | 49 ++++++++++++++----- .../Server_API/LSL_BuiltIn_Commands.cs | 9 ++-- .../DotNetEngine/LSLLongCmdHandler.cs | 6 +-- bin/OpenSim.ini.example | 3 ++ 6 files changed, 54 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/Environment/Interfaces/IXMLRPC.cs b/OpenSim/Region/Environment/Interfaces/IXMLRPC.cs index 6786b8cad0..02b74cbbcc 100644 --- a/OpenSim/Region/Environment/Interfaces/IXMLRPC.cs +++ b/OpenSim/Region/Environment/Interfaces/IXMLRPC.cs @@ -38,5 +38,6 @@ namespace OpenSim.Region.Environment.Interfaces bool hasRequests(); RPCRequestInfo GetNextRequest(); void RemoteDataReply(string channel, string message_id, string sdata, int idata); + bool IsEnabled(); } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs index 1bab2e5aee..6893e3fc2d 100644 --- a/OpenSim/Region/Environment/ModuleLoader.cs +++ b/OpenSim/Region/Environment/ModuleLoader.cs @@ -90,6 +90,9 @@ namespace OpenSim.Region.Environment AvatarFactoryModule avatarFactory = new AvatarFactoryModule(); m_loadedSharedModules.Add(avatarFactory.Name, avatarFactory); + XMLRPCModule xmlRpcMod = new XMLRPCModule(); + m_loadedSharedModules.Add(xmlRpcMod.Name, xmlRpcMod); + //TextureDownloadModule textureModule = new TextureDownloadModule(); //LoadedSharedModules.Add(textureModule.Name, textureModule); } diff --git a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs index 2618b17d5d..f139d64304 100644 --- a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs +++ b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs @@ -26,6 +26,7 @@ * */ +using System; using System.Collections; using System.Collections.Generic; using System.Threading; @@ -35,6 +36,7 @@ using Nwc.XmlRpc; using OpenSim.Framework.Servers; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; +using OpenSim.Framework.Console; /***************************************************** * @@ -77,8 +79,11 @@ namespace OpenSim.Region.Environment.Modules private Queue rpcQueue = new Queue(); private object XMLRPCListLock = new object(); private string m_name = "XMLRPCModule"; - private int RemoteReplyScriptWait = 100; - private int RemoteReplyScriptTimeout = 300; + private int RemoteReplyScriptWait = 300; + private int RemoteReplyScriptTimeout = 900; + private int m_remoteDataPort = 0; + private List m_scenes = new List(); + private LogBase m_log; // private Dictionary m_openChannels; @@ -88,26 +93,43 @@ namespace OpenSim.Region.Environment.Modules public XMLRPCModule() { + m_log = MainLog.Instance; } public void Initialise(Scene scene, IConfigSource config) { - m_scene = scene; + try + { - m_scene.RegisterModuleInterface(this); + m_remoteDataPort = config.Configs["Network"].GetInt("remoteDataPort", m_remoteDataPort); - m_openChannels = new Dictionary(); - m_pendingResponse = new Dictionary(); + } + catch (Exception e) + { + } - // Start http server - // Attach xmlrpc handlers - BaseHttpServer httpServer = new BaseHttpServer(20800); - httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); - httpServer.Start(); + if (!m_scenes.Contains(scene)) + { + m_scenes.Add(scene); + + scene.RegisterModuleInterface(this); + } } public void PostInitialise() { + if ( IsEnabled() ) + { + m_openChannels = new Dictionary(); + m_pendingResponse = new Dictionary(); + + // Start http server + // Attach xmlrpc handlers + m_log.Verbose("REMOTE_DATA", "Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands."); + BaseHttpServer httpServer = new BaseHttpServer((uint)m_remoteDataPort); + httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); + httpServer.Start(); + } } public void Close() @@ -124,6 +146,11 @@ namespace OpenSim.Region.Environment.Modules get { return true; } } + public bool IsEnabled() + { + return (m_remoteDataPort > 0); + } + /********************************************** * OpenXMLRPCChannel * diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs index aaac2940ef..40c6533029 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs @@ -2044,9 +2044,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler public void llOpenRemoteDataChannel() { IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface(); - LLUUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID); - object[] resobj = new object[] {1, channelID.ToString(), LLUUID.Zero.ToString(), "", 0, ""}; - m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(m_localID, m_itemID, "remote_data", resobj); + if (xmlrpcMod.IsEnabled()) + { + LLUUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID); + object[] resobj = new object[] { 1, channelID.ToString(), LLUUID.Zero.ToString(), "", 0, "" }; + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(m_localID, m_itemID, "remote_data", resobj); + } } public string llSendRemoteData(string channel, string dest, int idata, string sdata) diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs index ddc0c620dc..fdd7260c66 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs @@ -213,7 +213,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine while ( httpInfo != null ) { - Console.WriteLine("PICKED HTTP REQ:" + httpInfo.response_body + httpInfo.status); + //Console.WriteLine("PICKED HTTP REQ:" + httpInfo.response_body + httpInfo.status); // Deliver data to prim's remote_data handler // @@ -249,7 +249,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine while (xmlrpc.hasRequests()) { RPCRequestInfo rInfo = xmlrpc.GetNextRequest(); - Console.WriteLine("PICKED REQUEST"); + //Console.WriteLine("PICKED REQUEST"); //Deliver data to prim's remote_data handler object[] resobj = new object[] @@ -284,4 +284,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } } } -} \ No newline at end of file +} diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index f57b70aa9f..ec7147ff13 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -58,6 +58,9 @@ dump_assets_to_file = false http_listener_port = 9000 remoting_listener_port = 8895 +; Uncomment below to enable llRemoteData/remote channels +; remoteDataPort = 20800 + grid_server_url = "http://127.0.0.1:8001" grid_send_key = "null" grid_recv_key = "null"