Adds the ability to load more then one IClientNetworkServer thereby allowing additional client stacks. Use comma separated values in clientstack_plugin in your config.

user_profiles
teravus 2013-02-03 07:44:45 -05:00
parent 27a0b3ecbd
commit d18fbb98b7
5 changed files with 78 additions and 49 deletions

View File

@ -316,7 +316,7 @@ namespace OpenSim
/// <param name="regionInfo"></param> /// <param name="regionInfo"></param>
/// <param name="portadd_flag"></param> /// <param name="portadd_flag"></param>
/// <returns></returns> /// <returns></returns>
public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, out IScene scene) public List<IClientNetworkServer> CreateRegion(RegionInfo regionInfo, bool portadd_flag, out IScene scene)
{ {
return CreateRegion(regionInfo, portadd_flag, false, out scene); return CreateRegion(regionInfo, portadd_flag, false, out scene);
} }
@ -326,7 +326,7 @@ namespace OpenSim
/// </summary> /// </summary>
/// <param name="regionInfo"></param> /// <param name="regionInfo"></param>
/// <returns></returns> /// <returns></returns>
public IClientNetworkServer CreateRegion(RegionInfo regionInfo, out IScene scene) public List<IClientNetworkServer> CreateRegion(RegionInfo regionInfo, out IScene scene)
{ {
return CreateRegion(regionInfo, false, true, out scene); return CreateRegion(regionInfo, false, true, out scene);
} }
@ -338,7 +338,7 @@ namespace OpenSim
/// <param name="portadd_flag"></param> /// <param name="portadd_flag"></param>
/// <param name="do_post_init"></param> /// <param name="do_post_init"></param>
/// <returns></returns> /// <returns></returns>
public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init, out IScene mscene) public List<IClientNetworkServer> CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init, out IScene mscene)
{ {
int port = regionInfo.InternalEndPoint.Port; int port = regionInfo.InternalEndPoint.Port;
@ -363,8 +363,8 @@ namespace OpenSim
Util.XmlRpcCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName); Util.XmlRpcCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName);
} }
IClientNetworkServer clientServer; List<IClientNetworkServer> clientServers;
Scene scene = SetupScene(regionInfo, proxyOffset, Config, out clientServer); Scene scene = SetupScene(regionInfo, proxyOffset, Config, out clientServers);
m_log.Info("[MODULES]: Loading Region's modules (old style)"); m_log.Info("[MODULES]: Loading Region's modules (old style)");
@ -414,8 +414,11 @@ namespace OpenSim
if (m_autoCreateClientStack) if (m_autoCreateClientStack)
{ {
m_clientServers.Add(clientServer); foreach (IClientNetworkServer clientserver in clientServers)
clientServer.Start(); {
m_clientServers.Add(clientserver);
clientserver.Start();
}
} }
scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); }; scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); };
@ -425,7 +428,7 @@ namespace OpenSim
scene.Start(); scene.Start();
scene.StartScripts(); scene.StartScripts();
return clientServer; return clientServers;
} }
/// <summary> /// <summary>
@ -641,7 +644,7 @@ namespace OpenSim
/// <param name="regionInfo"></param> /// <param name="regionInfo"></param>
/// <param name="clientServer"> </param> /// <param name="clientServer"> </param>
/// <returns></returns> /// <returns></returns>
protected Scene SetupScene(RegionInfo regionInfo, out IClientNetworkServer clientServer) protected Scene SetupScene(RegionInfo regionInfo, out List<IClientNetworkServer> clientServer)
{ {
return SetupScene(regionInfo, 0, null, out clientServer); return SetupScene(regionInfo, 0, null, out clientServer);
} }
@ -655,19 +658,20 @@ namespace OpenSim
/// <param name="clientServer"> </param> /// <param name="clientServer"> </param>
/// <returns></returns> /// <returns></returns>
protected Scene SetupScene( protected Scene SetupScene(
RegionInfo regionInfo, int proxyOffset, IConfigSource configSource, out IClientNetworkServer clientServer) RegionInfo regionInfo, int proxyOffset, IConfigSource configSource, out List<IClientNetworkServer> clientServer)
{ {
List<IClientNetworkServer> clientNetworkServers = null;
AgentCircuitManager circuitManager = new AgentCircuitManager(); AgentCircuitManager circuitManager = new AgentCircuitManager();
IPAddress listenIP = regionInfo.InternalEndPoint.Address; IPAddress listenIP = regionInfo.InternalEndPoint.Address;
//if (!IPAddress.TryParse(regionInfo.InternalEndPoint, out listenIP)) //if (!IPAddress.TryParse(regionInfo.InternalEndPoint, out listenIP))
// listenIP = IPAddress.Parse("0.0.0.0"); // listenIP = IPAddress.Parse("0.0.0.0");
uint port = (uint) regionInfo.InternalEndPoint.Port; uint port = (uint) regionInfo.InternalEndPoint.Port;
IClientNetworkServer clientNetworkServer;
if (m_autoCreateClientStack) if (m_autoCreateClientStack)
{ {
clientServer clientNetworkServers = m_clientStackManager.CreateServers(
= m_clientStackManager.CreateServer(
listenIP, ref port, proxyOffset, regionInfo.m_allow_alternate_ports, configSource, listenIP, ref port, proxyOffset, regionInfo.m_allow_alternate_ports, configSource,
circuitManager); circuitManager);
} }
@ -682,9 +686,12 @@ namespace OpenSim
if (m_autoCreateClientStack) if (m_autoCreateClientStack)
{ {
clientServer.AddScene(scene); foreach (IClientNetworkServer clientnetserver in clientNetworkServers)
{
clientnetserver.AddScene(scene);
} }
}
clientServer = clientNetworkServers;
scene.LoadWorldMap(); scene.LoadWorldMap();
scene.PhysicsScene = GetPhysicsScene(scene.RegionInfo.RegionName); scene.PhysicsScene = GetPhysicsScene(scene.RegionInfo.RegionName);

View File

@ -26,6 +26,7 @@
*/ */
using System; using System;
using System.Collections.Generic;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using log4net; using log4net;
@ -38,19 +39,31 @@ namespace OpenSim.Region.ClientStack
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Type plugin; private List<Type> plugin = new List<Type>();
private Assembly pluginAssembly; private List<Assembly> pluginAssembly = new List<Assembly>();
public ClientStackManager(string dllName) public ClientStackManager(string pDllName)
{
List<string> clientstacks = new List<string>();
if (pDllName.Contains(","))
{
clientstacks = new List<string>(pDllName.Split(','));
}
else
{
clientstacks.Add(pDllName);
}
foreach (string dllName in clientstacks)
{ {
m_log.Info("[CLIENTSTACK]: Attempting to load " + dllName); m_log.Info("[CLIENTSTACK]: Attempting to load " + dllName);
try try
{ {
plugin = null; //plugin = null;
pluginAssembly = Assembly.LoadFrom(dllName); Assembly itemAssembly = Assembly.LoadFrom(dllName);
pluginAssembly.Add(itemAssembly);
foreach (Type pluginType in pluginAssembly.GetTypes()) foreach (Type pluginType in itemAssembly.GetTypes())
{ {
if (pluginType.IsPublic) if (pluginType.IsPublic)
{ {
@ -59,12 +72,13 @@ namespace OpenSim.Region.ClientStack
if (typeInterface != null) if (typeInterface != null)
{ {
m_log.Info("[CLIENTSTACK]: Added IClientNetworkServer Interface"); m_log.Info("[CLIENTSTACK]: Added IClientNetworkServer Interface");
plugin = pluginType; plugin.Add(pluginType);
return; break;
} }
} }
} }
} catch (ReflectionTypeLoadException e) }
catch (ReflectionTypeLoadException e)
{ {
foreach (Exception e2 in e.LoaderExceptions) foreach (Exception e2 in e.LoaderExceptions)
{ {
@ -73,6 +87,7 @@ namespace OpenSim.Region.ClientStack
throw e; throw e;
} }
} }
}
/// <summary> /// <summary>
/// Create a server that can set up sessions for virtual world client <-> server communications /// Create a server that can set up sessions for virtual world client <-> server communications
@ -84,11 +99,11 @@ namespace OpenSim.Region.ClientStack
/// <param name="assetCache"></param> /// <param name="assetCache"></param>
/// <param name="authenticateClass"></param> /// <param name="authenticateClass"></param>
/// <returns></returns> /// <returns></returns>
public IClientNetworkServer CreateServer( public List<IClientNetworkServer> CreateServers(
IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port,
AgentCircuitManager authenticateClass) AgentCircuitManager authenticateClass)
{ {
return CreateServer( return CreateServers(
_listenIP, ref port, proxyPortOffset, allow_alternate_port, null, authenticateClass); _listenIP, ref port, proxyPortOffset, allow_alternate_port, null, authenticateClass);
} }
@ -105,20 +120,24 @@ namespace OpenSim.Region.ClientStack
/// <param name="assetCache"></param> /// <param name="assetCache"></param>
/// <param name="authenticateClass"></param> /// <param name="authenticateClass"></param>
/// <returns></returns> /// <returns></returns>
public IClientNetworkServer CreateServer( public List<IClientNetworkServer> CreateServers(
IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, IConfigSource configSource, IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, IConfigSource configSource,
AgentCircuitManager authenticateClass) AgentCircuitManager authenticateClass)
{ {
List<IClientNetworkServer> servers = new List<IClientNetworkServer>();
if (plugin != null) if (plugin != null)
{
for (int i = 0; i < plugin.Count; i++)
{ {
IClientNetworkServer server = IClientNetworkServer server =
(IClientNetworkServer)Activator.CreateInstance(pluginAssembly.GetType(plugin.ToString())); (IClientNetworkServer) Activator.CreateInstance(pluginAssembly[i].GetType(plugin[i].ToString()));
server.Initialise( server.Initialise(
_listenIP, ref port, proxyPortOffset, allow_alternate_port, _listenIP, ref port, proxyPortOffset, allow_alternate_port,
configSource, authenticateClass); configSource, authenticateClass);
servers.Add(server);
return server; }
return servers;
} }
m_log.Error("[CLIENTSTACK]: Couldn't initialize a new server"); m_log.Error("[CLIENTSTACK]: Couldn't initialize a new server");

View File

@ -55,6 +55,9 @@ namespace OpenSim.Region.ClientStack.TCPJSONStream
} }
} }
catch (Exception)
{
}
} }
/// <summary> /// <summary>
/// send a whole buffer /// send a whole buffer

View File

@ -99,7 +99,7 @@ namespace OpenSim.Region.ClientStack.TCPJSONStream
} }
ClientNetworkContext context = new ClientNetworkContext((IPEndPoint) socket.RemoteEndPoint, _port, ClientNetworkContext context = new ClientNetworkContext((IPEndPoint) socket.RemoteEndPoint, _port,
new NetworkStream(socket), 16384, socket); new NetworkStream(socket), 16384, socket);
HttpRequestParser parser; //HttpRequestParser parser;
context.BeginRead(); context.BeginRead();
} }

View File

@ -58,7 +58,7 @@
; ## ; ##
; Set this to the DLL containing the client stack to use. ; 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 ; ## REGIONS