From d18fbb98b7f51d46eb3e716c59a8e76bc772bad1 Mon Sep 17 00:00:00 2001 From: teravus Date: Sun, 3 Feb 2013 07:44:45 -0500 Subject: Adds the ability to load more then one IClientNetworkServer thereby allowing additional client stacks. Use comma separated values in clientstack_plugin in your config. --- OpenSim/Region/Application/OpenSimBase.cs | 37 ++++++---- OpenSim/Region/ClientStack/ClientStackManager.cs | 83 +++++++++++++--------- .../TCPJSONStream/ClientNetworkContext.cs | 3 + .../TCPJSONStream/TCPJsonWebSocketServer.cs | 2 +- bin/OpenSimDefaults.ini | 2 +- 5 files changed, 78 insertions(+), 49 deletions(-) diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index c3c87e7..f5c06df 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -316,7 +316,7 @@ namespace OpenSim /// /// /// - public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, out IScene scene) + public List CreateRegion(RegionInfo regionInfo, bool portadd_flag, out IScene scene) { return CreateRegion(regionInfo, portadd_flag, false, out scene); } @@ -326,7 +326,7 @@ namespace OpenSim /// /// /// - public IClientNetworkServer CreateRegion(RegionInfo regionInfo, out IScene scene) + public List CreateRegion(RegionInfo regionInfo, out IScene scene) { return CreateRegion(regionInfo, false, true, out scene); } @@ -338,7 +338,7 @@ namespace OpenSim /// /// /// - public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init, out IScene mscene) + public List CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init, out IScene mscene) { int port = regionInfo.InternalEndPoint.Port; @@ -363,8 +363,8 @@ namespace OpenSim Util.XmlRpcCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName); } - IClientNetworkServer clientServer; - Scene scene = SetupScene(regionInfo, proxyOffset, Config, out clientServer); + List clientServers; + Scene scene = SetupScene(regionInfo, proxyOffset, Config, out clientServers); m_log.Info("[MODULES]: Loading Region's modules (old style)"); @@ -414,8 +414,11 @@ namespace OpenSim if (m_autoCreateClientStack) { - m_clientServers.Add(clientServer); - clientServer.Start(); + foreach (IClientNetworkServer clientserver in clientServers) + { + m_clientServers.Add(clientserver); + clientserver.Start(); + } } scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); }; @@ -425,7 +428,7 @@ namespace OpenSim scene.Start(); scene.StartScripts(); - return clientServer; + return clientServers; } /// @@ -641,7 +644,7 @@ namespace OpenSim /// /// /// - protected Scene SetupScene(RegionInfo regionInfo, out IClientNetworkServer clientServer) + protected Scene SetupScene(RegionInfo regionInfo, out List clientServer) { return SetupScene(regionInfo, 0, null, out clientServer); } @@ -655,19 +658,20 @@ namespace OpenSim /// /// protected Scene SetupScene( - RegionInfo regionInfo, int proxyOffset, IConfigSource configSource, out IClientNetworkServer clientServer) + RegionInfo regionInfo, int proxyOffset, IConfigSource configSource, out List clientServer) { + List clientNetworkServers = null; + AgentCircuitManager circuitManager = new AgentCircuitManager(); IPAddress listenIP = regionInfo.InternalEndPoint.Address; //if (!IPAddress.TryParse(regionInfo.InternalEndPoint, out listenIP)) // listenIP = IPAddress.Parse("0.0.0.0"); uint port = (uint) regionInfo.InternalEndPoint.Port; - + IClientNetworkServer clientNetworkServer; if (m_autoCreateClientStack) { - clientServer - = m_clientStackManager.CreateServer( + clientNetworkServers = m_clientStackManager.CreateServers( listenIP, ref port, proxyOffset, regionInfo.m_allow_alternate_ports, configSource, circuitManager); } @@ -682,9 +686,12 @@ namespace OpenSim if (m_autoCreateClientStack) { - clientServer.AddScene(scene); + foreach (IClientNetworkServer clientnetserver in clientNetworkServers) + { + clientnetserver.AddScene(scene); + } } - + clientServer = clientNetworkServers; scene.LoadWorldMap(); scene.PhysicsScene = GetPhysicsScene(scene.RegionInfo.RegionName); diff --git a/OpenSim/Region/ClientStack/ClientStackManager.cs b/OpenSim/Region/ClientStack/ClientStackManager.cs index 84ea0b3..299aabd 100644 --- a/OpenSim/Region/ClientStack/ClientStackManager.cs +++ b/OpenSim/Region/ClientStack/ClientStackManager.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections.Generic; using System.Net; using System.Reflection; using log4net; @@ -38,39 +39,53 @@ namespace OpenSim.Region.ClientStack { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private Type plugin; - private Assembly pluginAssembly; + private List plugin = new List(); + private List pluginAssembly = new List(); - public ClientStackManager(string dllName) + public ClientStackManager(string pDllName) { - m_log.Info("[CLIENTSTACK]: Attempting to load " + dllName); - - try + List clientstacks = new List(); + if (pDllName.Contains(",")) + { + clientstacks = new List(pDllName.Split(',')); + } + else { - plugin = null; - pluginAssembly = Assembly.LoadFrom(dllName); + clientstacks.Add(pDllName); + } + foreach (string dllName in clientstacks) + { + m_log.Info("[CLIENTSTACK]: Attempting to load " + dllName); - foreach (Type pluginType in pluginAssembly.GetTypes()) + try { - if (pluginType.IsPublic) - { - Type typeInterface = pluginType.GetInterface("IClientNetworkServer", true); + //plugin = null; + Assembly itemAssembly = Assembly.LoadFrom(dllName); + pluginAssembly.Add(itemAssembly); - if (typeInterface != null) + foreach (Type pluginType in itemAssembly.GetTypes()) + { + if (pluginType.IsPublic) { - m_log.Info("[CLIENTSTACK]: Added IClientNetworkServer Interface"); - plugin = pluginType; - return; + Type typeInterface = pluginType.GetInterface("IClientNetworkServer", true); + + if (typeInterface != null) + { + m_log.Info("[CLIENTSTACK]: Added IClientNetworkServer Interface"); + plugin.Add(pluginType); + break; + } } } } - } catch (ReflectionTypeLoadException e) - { - foreach (Exception e2 in e.LoaderExceptions) + catch (ReflectionTypeLoadException e) { - m_log.Error(e2.ToString()); + foreach (Exception e2 in e.LoaderExceptions) + { + m_log.Error(e2.ToString()); + } + throw e; } - throw e; } } @@ -84,11 +99,11 @@ namespace OpenSim.Region.ClientStack /// /// /// - public IClientNetworkServer CreateServer( + public List CreateServers( IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, AgentCircuitManager authenticateClass) { - return CreateServer( + return CreateServers( _listenIP, ref port, proxyPortOffset, allow_alternate_port, null, authenticateClass); } @@ -105,20 +120,24 @@ namespace OpenSim.Region.ClientStack /// /// /// - public IClientNetworkServer CreateServer( + public List CreateServers( IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager authenticateClass) { + List servers = new List(); if (plugin != null) { - IClientNetworkServer server = - (IClientNetworkServer)Activator.CreateInstance(pluginAssembly.GetType(plugin.ToString())); - - server.Initialise( - _listenIP, ref port, proxyPortOffset, allow_alternate_port, - configSource, authenticateClass); - - return server; + for (int i = 0; i < plugin.Count; i++) + { + IClientNetworkServer server = + (IClientNetworkServer) Activator.CreateInstance(pluginAssembly[i].GetType(plugin[i].ToString())); + + server.Initialise( + _listenIP, ref port, proxyPortOffset, allow_alternate_port, + configSource, authenticateClass); + servers.Add(server); + } + return servers; } m_log.Error("[CLIENTSTACK]: Couldn't initialize a new server"); diff --git a/OpenSim/Region/ClientStack/TCPJSONStream/ClientNetworkContext.cs b/OpenSim/Region/ClientStack/TCPJSONStream/ClientNetworkContext.cs index 591f817..b077b6a 100644 --- a/OpenSim/Region/ClientStack/TCPJSONStream/ClientNetworkContext.cs +++ b/OpenSim/Region/ClientStack/TCPJSONStream/ClientNetworkContext.cs @@ -55,6 +55,9 @@ namespace OpenSim.Region.ClientStack.TCPJSONStream } } + catch (Exception) + { + } } /// /// send a whole buffer diff --git a/OpenSim/Region/ClientStack/TCPJSONStream/TCPJsonWebSocketServer.cs b/OpenSim/Region/ClientStack/TCPJSONStream/TCPJsonWebSocketServer.cs index 0713bf4..c0f6792 100644 --- a/OpenSim/Region/ClientStack/TCPJSONStream/TCPJsonWebSocketServer.cs +++ b/OpenSim/Region/ClientStack/TCPJSONStream/TCPJsonWebSocketServer.cs @@ -99,7 +99,7 @@ namespace OpenSim.Region.ClientStack.TCPJSONStream } ClientNetworkContext context = new ClientNetworkContext((IPEndPoint) socket.RemoteEndPoint, _port, new NetworkStream(socket), 16384, socket); - HttpRequestParser parser; + //HttpRequestParser parser; context.BeginRead(); } diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index c60579b..cc08094 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -58,7 +58,7 @@ ; ## ; Set this to the DLL containing the client stack to use. - clientstack_plugin="OpenSim.Region.ClientStack.LindenUDP.dll" + clientstack_plugin="OpenSim.Region.ClientStack.LindenUDP.dll,OpenSim.Region.ClientStack.TCPJSONStream.dll" ; ## ; ## REGIONS -- cgit v1.1