From 76133d07630d8a1547c034b28585a931f751ad1b Mon Sep 17 00:00:00 2001
From: MW
Date: Tue, 3 Mar 2009 12:51:54 +0000
Subject: Refactoring of CreateCommsManagerPlugin. Plus some general cleanup of
a few other files (deleting excess blank lines etc)
---
.../CreateCommsManager/CreateCommsManagerPlugin.cs | 60 ++++++++++------------
OpenSim/Client/Linden/LLClientStackModule.cs | 7 ++-
OpenSim/Framework/Util.cs | 3 +-
OpenSim/Region/Application/OpenSimBase.cs | 34 ------------
4 files changed, 34 insertions(+), 70 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs
index 94183c3..7323ad7 100644
--- a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs
+++ b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs
@@ -176,10 +176,7 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
LocalBackEndServices backendService = new LocalBackEndServices();
- LocalLoginService loginService =
- new LocalLoginService(
- userService, m_openSim.ConfigurationSettings.StandaloneWelcomeMessage, inventoryService, backendService, m_openSim.NetServersInfo,
- m_openSim.ConfigurationSettings.StandaloneAuthenticate, libraryRootFolder);
+ LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, backendService);
m_commsManager
= new CommunicationsLocal(
@@ -187,20 +184,7 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
inventoryService, backendService, userService,
libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile);
- // set up XMLRPC handler for client's initial login request message
- m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod);
-
- // provides the web form login
- m_httpServer.AddHTTPHandler("login", loginService.ProcessHTMLLogin);
-
- // Provides the LLSD login
- m_httpServer.SetDefaultLLSDHandler(loginService.LLSDLoginMethod);
-
- // provide grid info
- // m_gridInfoService = new GridInfoService(m_config.Source.Configs["Startup"].GetString("inifile", Path.Combine(Util.configDir(), "OpenSim.ini")));
- m_gridInfoService = new GridInfoService(m_openSim.ConfigSource.Source);
- m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod);
- m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", m_gridInfoService.RestGetGridInfoMethod));
+ CreateGridInfoService();
}
protected virtual void InitialiseGridServices(LibraryRootFolder libraryRootFolder)
@@ -226,11 +210,7 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
//LocalBackEndServices backendService = new LocalBackEndServices();
HGGridServicesStandalone gridService = new HGGridServicesStandalone(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, m_openSim.SceneManager);
- LocalLoginService loginService =
- new LocalLoginService(
- userService, m_openSim.ConfigurationSettings.StandaloneWelcomeMessage, inventoryService, gridService.LocalBackend, m_openSim.NetServersInfo,
- m_openSim.ConfigurationSettings.StandaloneAuthenticate, libraryRootFolder);
-
+ LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, gridService.LocalBackend);
m_commsManager = new HGCommunicationsStandalone(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache,
userService, userService, inventoryService, gridService, userService, libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile);
@@ -238,6 +218,26 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
inventoryService.UserProfileCache = m_commsManager.UserProfileCacheService;
HGServices = gridService;
+ CreateGridInfoService();
+ }
+
+
+ protected virtual void InitialiseHGGridServices(LibraryRootFolder libraryRootFolder)
+ {
+ m_commsManager = new HGCommunicationsGridMode(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, m_openSim.SceneManager, libraryRootFolder);
+
+ HGServices = ((HGCommunicationsGridMode)m_commsManager).HGServices;
+
+ m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler());
+ }
+
+ private LocalLoginService CreateLoginService(LibraryRootFolder libraryRootFolder, IInterServiceInventoryServices inventoryService, LocalUserServices userService, LocalBackEndServices backendService)
+ {
+ LocalLoginService loginService =
+ new LocalLoginService(
+ userService, m_openSim.ConfigurationSettings.StandaloneWelcomeMessage, inventoryService, backendService, m_openSim.NetServersInfo,
+ m_openSim.ConfigurationSettings.StandaloneAuthenticate, libraryRootFolder);
+
// set up XMLRPC handler for client's initial login request message
m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod);
@@ -247,20 +247,16 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
// Provides the LLSD login
m_httpServer.SetDefaultLLSDHandler(loginService.LLSDLoginMethod);
+ return loginService;
+ }
+
+ private void CreateGridInfoService()
+ {
// provide grid info
// m_gridInfoService = new GridInfoService(m_config.Source.Configs["Startup"].GetString("inifile", Path.Combine(Util.configDir(), "OpenSim.ini")));
m_gridInfoService = new GridInfoService(m_openSim.ConfigSource.Source);
m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod);
m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", m_gridInfoService.RestGetGridInfoMethod));
}
-
- protected virtual void InitialiseHGGridServices(LibraryRootFolder libraryRootFolder)
- {
- m_commsManager = new HGCommunicationsGridMode(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, m_openSim.SceneManager, libraryRootFolder);
-
- HGServices = ((HGCommunicationsGridMode)m_commsManager).HGServices;
-
- m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler());
- }
}
}
diff --git a/OpenSim/Client/Linden/LLClientStackModule.cs b/OpenSim/Client/Linden/LLClientStackModule.cs
index 57331e5..6b23224 100644
--- a/OpenSim/Client/Linden/LLClientStackModule.cs
+++ b/OpenSim/Client/Linden/LLClientStackModule.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Net;
using System.Reflection;
using System.Text;
using log4net;
@@ -47,11 +48,13 @@ namespace OpenSim.Client.Linden
if ((m_scene != null) && (m_createClientStack))
{
m_log.Info("[LLClientStackModule] Starting up LLClientStack.");
- uint port = (uint)m_scene.RegionInfo.InternalEndPoint.Port;
+ IPEndPoint endPoint = m_scene.RegionInfo.InternalEndPoint;
+
+ uint port = (uint)endPoint.Port;
m_clientStackManager = new ClientStackManager(m_clientStackDll);
m_clientServer
- = m_clientStackManager.CreateServer(m_scene.RegionInfo.InternalEndPoint.Address,
+ = m_clientStackManager.CreateServer(endPoint.Address,
ref port, m_scene.RegionInfo.ProxyOffset, m_scene.RegionInfo.m_allow_alternate_ports, m_source,
m_scene.CommsManager.AssetCache, m_scene.AuthenticateHandler);
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index d978c4c..ba19dc6 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -766,8 +766,7 @@ namespace OpenSim.Framework
}
memory.Position = 0;
- // MemoryStream outStream = new MemoryStream();
-
+
byte[] compressed = new byte[memory.Length];
memory.Read(compressed, 0, compressed.Length);
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 7569502..323d90c 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -206,7 +206,6 @@ namespace OpenSim
}
AddPluginCommands();
-
}
protected virtual void AddPluginCommands()
@@ -269,14 +268,10 @@ namespace OpenSim
protected override void Initialize()
{
- //
// Called from base.StartUp()
- //
m_httpServerPort = m_networkServersInfo.HttpListenerPort;
-
InitialiseAssetCache();
-
m_sceneManager.OnRestartSim += handleRestartRegion;
}
@@ -291,10 +286,8 @@ namespace OpenSim
/// returns an IAssetCache implementation, if possible. This is a virtual
/// method.
///
-
protected virtual void InitialiseAssetCache()
{
-
LegacyAssetClientPluginInitialiser linit = null;
CryptoAssetClientPluginInitialiser cinit = null;
AssetClientPluginInitialiser init = null;
@@ -308,7 +301,6 @@ namespace OpenSim
// If "default" is specified, then the value is adjusted
// according to whether or not the server is running in
// standalone mode.
-
if (mode.ToLower() == "default")
{
if (m_configSettings.Standalone == false)
@@ -319,19 +311,15 @@ namespace OpenSim
switch (mode.ToLower())
{
-
// If grid is specified then the grid server is chose regardless
// of whether the server is standalone.
-
case "grid" :
linit = new LegacyAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL);
assetServer = loadAssetServer("Grid", linit);
break;
-
// If cryptogrid is specified then the cryptogrid server is chose regardless
// of whether the server is standalone.
-
case "cryptogrid" :
cinit = new CryptoAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL,
Environment.CurrentDirectory, true);
@@ -340,7 +328,6 @@ namespace OpenSim
// If cryptogrid_eou is specified then the cryptogrid_eou server is chose regardless
// of whether the server is standalone.
-
case "cryptogrid_eou" :
cinit = new CryptoAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL,
Environment.CurrentDirectory, false);
@@ -349,7 +336,6 @@ namespace OpenSim
// If file is specified then the file server is chose regardless
// of whether the server is standalone.
-
case "file" :
linit = new LegacyAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL);
assetServer = loadAssetServer("File", linit);
@@ -358,14 +344,12 @@ namespace OpenSim
// If local is specified then we're going to use the local SQL server
// implementation. We drop through, because that will be the fallback
// for the following default clause too.
-
case "local" :
break;
// If the asset_database value is none of the previously mentioned strings, then we
// try to load a turnkey plugin that matches this value. If not we drop through to
// a local default.
-
default :
try
{
@@ -376,11 +360,9 @@ namespace OpenSim
catch {}
m_log.Info("[OPENSIMBASE] Default assetserver will be used");
break;
-
}
// Open the local SQL-based database asset server
-
if (assetServer == null)
{
init = new AssetClientPluginInitialiser(m_configSettings);
@@ -391,18 +373,14 @@ namespace OpenSim
// Initialize the asset cache, passing a reference to the selected
// asset server interface.
-
m_assetCache = ResolveAssetCache(assetServer);
-
}
// This method loads the identified asset server, passing an approrpiately
// initialized Initialise wrapper. There should to be exactly one match,
// if not, then the first match is used.
-
private IAssetServer loadAssetServer(string id, PluginInitialiserBase pi)
{
-
if (id != null && id != String.Empty)
{
m_log.DebugFormat("[OPENSIMBASE] Attempting to load asset server id={0}", id);
@@ -424,9 +402,7 @@ namespace OpenSim
m_log.DebugFormat("[OPENSIMBASE] Asset server {0} not loaded ({1})", id, e.Message);
}
}
-
return null;
-
}
///
@@ -439,21 +415,14 @@ namespace OpenSim
/// The AssetCache value is obtained from the
/// [StartUp]/AssetCache value in the configuration file.
///
-
protected virtual IAssetCache ResolveAssetCache(IAssetServer assetServer)
{
-
IAssetCache assetCache = null;
-
-
if (m_configSettings.AssetCache != null && m_configSettings.AssetCache != String.Empty)
{
-
m_log.DebugFormat("[OPENSIMBASE] Attempting to load asset cache id={0}", m_configSettings.AssetCache);
-
try
{
-
PluginInitialiserBase init = new AssetCachePluginInitialiser(m_configSettings, assetServer);
PluginLoader loader = new PluginLoader(init);
loader.AddFilter(PLUGIN_ASSET_CACHE, new PluginProviderFilter(m_configSettings.AssetCache));
@@ -461,7 +430,6 @@ namespace OpenSim
loader.Load(PLUGIN_ASSET_CACHE);
if (loader.Plugins.Count > 0)
assetCache = (IAssetCache) loader.Plugins[0];
-
}
catch (Exception e)
{
@@ -471,9 +439,7 @@ namespace OpenSim
}
// If everything else fails, we force load the built-in asset cache
-
return (IAssetCache) ((assetCache != null) ? assetCache : new AssetCache(assetServer));
-
}
public void ProcessLogin(bool LoginEnabled)
--
cgit v1.1