Work on creating a shared generic base GridService server, that can load the modules from User, Grid and Messaging servers.
Started to change the configuration of the Grid server so it uses nini.GenericGridServerConcept
parent
29c4eef1fe
commit
1e015a4cb8
|
@ -26,6 +26,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using Nini.Config;
|
||||||
|
|
||||||
namespace OpenSim.Framework
|
namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
|
@ -49,6 +50,11 @@ namespace OpenSim.Framework
|
||||||
public string UserRecvKey = String.Empty;
|
public string UserRecvKey = String.Empty;
|
||||||
public string UserSendKey = String.Empty;
|
public string UserSendKey = String.Empty;
|
||||||
|
|
||||||
|
public GridConfig()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public GridConfig(string description, string filename)
|
public GridConfig(string description, string filename)
|
||||||
{
|
{
|
||||||
configMember =
|
configMember =
|
||||||
|
@ -56,6 +62,11 @@ namespace OpenSim.Framework
|
||||||
configMember.performConfigurationRetrieve();
|
configMember.performConfigurationRetrieve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LoadConfigurationFromNini(IConfigSource configSource)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void loadConfigurationOptions()
|
public void loadConfigurationOptions()
|
||||||
{
|
{
|
||||||
configMember.addConfigurationOption("default_asset_server",
|
configMember.addConfigurationOption("default_asset_server",
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using Nini.Config;
|
||||||
|
|
||||||
namespace OpenSim.Framework
|
namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
|
@ -91,6 +92,11 @@ namespace OpenSim.Framework
|
||||||
configMember.performConfigurationRetrieve();
|
configMember.performConfigurationRetrieve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LoadConfigurationFromNini(IConfigSource configSource)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void loadConfigurationOptions()
|
public void loadConfigurationOptions()
|
||||||
{
|
{
|
||||||
configMember.addConfigurationOption("default_startup_message",
|
configMember.addConfigurationOption("default_startup_message",
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace OpenSim.Grid.GridServer.Modules
|
||||||
public void Initialise(GridServerBase gridServer)
|
public void Initialise(GridServerBase gridServer)
|
||||||
{
|
{
|
||||||
m_core = gridServer;
|
m_core = gridServer;
|
||||||
m_config = gridServer.Config;
|
m_config = gridServer.GConfig;
|
||||||
m_version = gridServer.Version;
|
m_version = gridServer.Version;
|
||||||
m_console = MainConsole.Instance;
|
m_console = MainConsole.Instance;
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ namespace OpenSim.Grid.GridServer.Modules
|
||||||
{
|
{
|
||||||
// m_log.Info("[DATA]: Connecting to Storage Server");
|
// m_log.Info("[DATA]: Connecting to Storage Server");
|
||||||
m_gridDBService = new GridDBService();
|
m_gridDBService = new GridDBService();
|
||||||
m_gridDBService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect);
|
//m_gridDBService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect);
|
||||||
|
|
||||||
//Register the database access service so modules can fetch it
|
//Register the database access service so modules can fetch it
|
||||||
// RegisterInterface<GridDBService>(m_gridDBService);
|
// RegisterInterface<GridDBService>(m_gridDBService);
|
||||||
|
|
|
@ -0,0 +1,250 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSimulator Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Xml;
|
||||||
|
using log4net;
|
||||||
|
using Nini.Config;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
|
||||||
|
namespace OpenSim.Grid.GridServer
|
||||||
|
{
|
||||||
|
public class GridConfigurationLoader
|
||||||
|
{
|
||||||
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
protected OpenSimConfigSource m_config;
|
||||||
|
|
||||||
|
public GridConfigurationLoader()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenSimConfigSource LoadConfigSettings(IConfigSource configSource)
|
||||||
|
{
|
||||||
|
bool iniFileExists = false;
|
||||||
|
|
||||||
|
IConfig startupConfig = configSource.Configs["Startup"];
|
||||||
|
|
||||||
|
string masterFileName = startupConfig.GetString("inimaster", "");
|
||||||
|
string masterfilePath = Path.Combine(Util.configDir(), masterFileName);
|
||||||
|
|
||||||
|
string iniDirName = startupConfig.GetString("inidirectory", "GridConfig");
|
||||||
|
string iniDirPath = Path.Combine(Util.configDir(), iniDirName);
|
||||||
|
|
||||||
|
string iniFileName = startupConfig.GetString("inifile", "OpenSim.Grid.ini");
|
||||||
|
string iniFilePath = Path.Combine(Util.configDir(), iniFileName);
|
||||||
|
|
||||||
|
string xmlPath = Path.Combine(Util.configDir(), "OpenSim.Grid.xml");
|
||||||
|
|
||||||
|
m_config = new OpenSimConfigSource();
|
||||||
|
m_config.Source = new IniConfigSource();
|
||||||
|
m_config.Source.Merge(DefaultConfig());
|
||||||
|
|
||||||
|
m_log.Info("[CONFIG] Reading configuration settings");
|
||||||
|
|
||||||
|
Uri configUri;
|
||||||
|
|
||||||
|
//check for master .INI file (name passed in command line, no default), or XML over http
|
||||||
|
if (masterFileName.Length > 0) // If a master file name is given ...
|
||||||
|
{
|
||||||
|
m_log.InfoFormat("[CONFIG] Reading config master file {0}", masterfilePath);
|
||||||
|
|
||||||
|
bool isMasterUri = Uri.TryCreate(masterFileName, UriKind.Absolute, out configUri) && configUri.Scheme == Uri.UriSchemeHttp;
|
||||||
|
|
||||||
|
if (!ReadConfig(masterFileName, masterfilePath, m_config, isMasterUri))
|
||||||
|
{
|
||||||
|
m_log.FatalFormat("[CONFIG] Could not open master config file {0}", masterfilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Directory.Exists(iniDirName))
|
||||||
|
{
|
||||||
|
m_log.InfoFormat("Searching folder: {0} , for config ini files", iniDirName);
|
||||||
|
string[] fileEntries = Directory.GetFiles(iniDirName);
|
||||||
|
foreach (string filePath in fileEntries)
|
||||||
|
{
|
||||||
|
// m_log.InfoFormat("reading ini file < {0} > from config dir", filePath);
|
||||||
|
ReadConfig(Path.GetFileName(filePath), filePath, m_config, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for .INI file (either default or name passed on command
|
||||||
|
// line) or XML config source over http
|
||||||
|
bool isIniUri = Uri.TryCreate(iniFileName, UriKind.Absolute, out configUri) && configUri.Scheme == Uri.UriSchemeHttp;
|
||||||
|
iniFileExists = ReadConfig(iniFileName, iniFilePath, m_config, isIniUri);
|
||||||
|
|
||||||
|
if (!iniFileExists)
|
||||||
|
{
|
||||||
|
// check for a xml config file
|
||||||
|
if (File.Exists(xmlPath))
|
||||||
|
{
|
||||||
|
iniFilePath = xmlPath;
|
||||||
|
|
||||||
|
m_log.InfoFormat("Reading XML configuration from {0}", Path.GetFullPath(xmlPath));
|
||||||
|
iniFileExists = true;
|
||||||
|
|
||||||
|
m_config.Source = new XmlConfigSource();
|
||||||
|
m_config.Source.Merge(new XmlConfigSource(iniFilePath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_config.Source.Merge(configSource);
|
||||||
|
|
||||||
|
if (!iniFileExists)
|
||||||
|
{
|
||||||
|
m_log.FatalFormat("[CONFIG] Could not load any configuration");
|
||||||
|
if (!isIniUri)
|
||||||
|
m_log.FatalFormat("[CONFIG] Tried to load {0}, ", Path.GetFullPath(iniFilePath));
|
||||||
|
else
|
||||||
|
m_log.FatalFormat("[CONFIG] Tried to load from URI {0}, ", iniFileName);
|
||||||
|
m_log.FatalFormat("[CONFIG] and XML source {0}", Path.GetFullPath(xmlPath));
|
||||||
|
|
||||||
|
m_log.FatalFormat("[CONFIG] Did you copy the OpenSim.Grid.ini.example file to OpenSim.Grid.ini?");
|
||||||
|
Environment.Exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReadConfigSettings();
|
||||||
|
|
||||||
|
return m_config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provide same ini loader functionality for standard ini and master ini - file system or XML over http
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="iniName">The name of the ini to load</param>
|
||||||
|
/// <param name="iniPath">Full path to the ini</param>
|
||||||
|
/// <param name="m_config">The current configuration source</param>
|
||||||
|
/// <param name="isUri">Boolean representing whether the ini source is a URI path over http or a file on the system</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private bool ReadConfig(string iniName, string iniPath, OpenSimConfigSource m_config, bool isUri)
|
||||||
|
{
|
||||||
|
bool success = false;
|
||||||
|
|
||||||
|
if (!isUri && File.Exists(iniPath))
|
||||||
|
{
|
||||||
|
m_log.InfoFormat("[CONFIG] Reading configuration file {0}", Path.GetFullPath(iniPath));
|
||||||
|
|
||||||
|
// From reading Nini's code, it seems that later merged keys replace earlier ones.
|
||||||
|
m_config.Source.Merge(new IniConfigSource(iniPath));
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (isUri)
|
||||||
|
{
|
||||||
|
m_log.InfoFormat("[CONFIG] {0} is a http:// URI, fetching ...", iniName);
|
||||||
|
|
||||||
|
// The ini file path is a http URI
|
||||||
|
// Try to read it
|
||||||
|
try
|
||||||
|
{
|
||||||
|
XmlReader r = XmlReader.Create(iniName);
|
||||||
|
XmlConfigSource cs = new XmlConfigSource(r);
|
||||||
|
m_config.Source.Merge(cs);
|
||||||
|
|
||||||
|
success = true;
|
||||||
|
m_log.InfoFormat("[CONFIG] Loaded config from {0}", iniName);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.FatalFormat("[CONFIG] Exception reading config from URI {0}\n" + e.ToString(), iniName);
|
||||||
|
Environment.Exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Setup a default config values in case they aren't present in the ini file
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IConfigSource DefaultConfig()
|
||||||
|
{
|
||||||
|
IConfigSource defaultConfig = new IniConfigSource();
|
||||||
|
|
||||||
|
{
|
||||||
|
IConfig config = defaultConfig.Configs["Startup"];
|
||||||
|
|
||||||
|
if (null == config)
|
||||||
|
config = defaultConfig.AddConfig("Startup");
|
||||||
|
|
||||||
|
config.Set("LoadPlugins", "GridServerPlugin;UserServerPlugin");
|
||||||
|
config.Set("HttpPort", "8051");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
IConfig config = defaultConfig.Configs["GridServices"];
|
||||||
|
|
||||||
|
if (null == config)
|
||||||
|
config = defaultConfig.AddConfig("GridServices");
|
||||||
|
|
||||||
|
config.Set("enable", false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void ReadConfigSettings()
|
||||||
|
{
|
||||||
|
IConfig startupConfig = m_config.Source.Configs["Startup"];
|
||||||
|
if (startupConfig != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
IConfig standaloneConfig = m_config.Source.Configs["StandAlone"];
|
||||||
|
if (standaloneConfig != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OpenSimConfigSource
|
||||||
|
{
|
||||||
|
public IConfigSource Source;
|
||||||
|
|
||||||
|
public void Save(string path)
|
||||||
|
{
|
||||||
|
if (Source is IniConfigSource)
|
||||||
|
{
|
||||||
|
IniConfigSource iniCon = (IniConfigSource)Source;
|
||||||
|
iniCon.Save(path);
|
||||||
|
}
|
||||||
|
else if (Source is XmlConfigSource)
|
||||||
|
{
|
||||||
|
XmlConfigSource xmlCon = (XmlConfigSource)Source;
|
||||||
|
xmlCon.Save(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,6 +31,7 @@ using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
using Nini.Config;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Framework.Servers;
|
using OpenSim.Framework.Servers;
|
||||||
|
@ -44,11 +45,25 @@ namespace OpenSim.Grid.GridServer
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
protected GridConfig m_config;
|
protected GridConfig m_gconfig;
|
||||||
|
protected UserConfig m_uconfig;
|
||||||
|
|
||||||
public GridConfig Config
|
protected GridConfigurationLoader m_configLoader;
|
||||||
|
protected OpenSimConfigSource m_configSource;
|
||||||
|
|
||||||
|
public OpenSimConfigSource ConfigSource
|
||||||
{
|
{
|
||||||
get { return m_config; }
|
get { return m_configSource; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public GridConfig GConfig
|
||||||
|
{
|
||||||
|
get { return m_gconfig; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserConfig UConfig
|
||||||
|
{
|
||||||
|
get { return m_uconfig; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Version
|
public string Version
|
||||||
|
@ -68,18 +83,31 @@ namespace OpenSim.Grid.GridServer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GridServerBase()
|
public GridServerBase(IConfigSource configSource)
|
||||||
{
|
{
|
||||||
m_console = new ConsoleBase("Grid");
|
m_console = new ConsoleBase("Grid");
|
||||||
MainConsole.Instance = m_console;
|
MainConsole.Instance = m_console;
|
||||||
|
|
||||||
|
m_configLoader = new GridConfigurationLoader();
|
||||||
|
m_configSource = m_configLoader.LoadConfigSettings(configSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void StartupSpecific()
|
protected override void StartupSpecific()
|
||||||
{
|
{
|
||||||
m_config = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), "GridServer_Config.xml")));
|
uint httpPort = 8051;
|
||||||
|
|
||||||
|
m_gconfig = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), "GridServer_Config.xml")));
|
||||||
|
|
||||||
|
m_uconfig = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml")));
|
||||||
|
|
||||||
|
IConfig startupConfig = m_configSource.Source.Configs["Startup"];
|
||||||
|
if (startupConfig != null)
|
||||||
|
{
|
||||||
|
Convert.ToUInt32(startupConfig.GetString("HttpPort", "8051"));
|
||||||
|
}
|
||||||
|
|
||||||
m_log.Info("[GRID]: Starting HTTP process");
|
m_log.Info("[GRID]: Starting HTTP process");
|
||||||
m_httpServer = new BaseHttpServer(m_config.HttpPort);
|
m_httpServer = new BaseHttpServer(httpPort);
|
||||||
|
|
||||||
LoadPlugins();
|
LoadPlugins();
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using log4net.Config;
|
using log4net.Config;
|
||||||
|
using Nini.Config;
|
||||||
|
|
||||||
namespace OpenSim.Grid.GridServer
|
namespace OpenSim.Grid.GridServer
|
||||||
{
|
{
|
||||||
|
@ -35,7 +36,18 @@ namespace OpenSim.Grid.GridServer
|
||||||
{
|
{
|
||||||
XmlConfigurator.Configure();
|
XmlConfigurator.Configure();
|
||||||
|
|
||||||
GridServerBase app = new GridServerBase();
|
ArgvConfigSource configSource = new ArgvConfigSource(args);
|
||||||
|
|
||||||
|
configSource.Alias.AddAlias("On", true);
|
||||||
|
configSource.Alias.AddAlias("Off", false);
|
||||||
|
configSource.Alias.AddAlias("True", true);
|
||||||
|
configSource.Alias.AddAlias("False", false);
|
||||||
|
|
||||||
|
configSource.AddSwitch("Startup", "inifile");
|
||||||
|
configSource.AddSwitch("Startup", "inimaster");
|
||||||
|
configSource.AddSwitch("Startup", "inidirectory");
|
||||||
|
|
||||||
|
GridServerBase app = new GridServerBase(configSource);
|
||||||
|
|
||||||
// if (args.Length > 0 && args[0] == "-setuponly")
|
// if (args.Length > 0 && args[0] == "-setuponly")
|
||||||
// {
|
// {
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<Addin id="OpenSim.Grid.UserServer.Modules" version="0.1">
|
||||||
|
<Runtime>
|
||||||
|
<Import assembly="OpenSim.Grid.UserServer.Modules.dll"/>
|
||||||
|
</Runtime>
|
||||||
|
<Dependencies>
|
||||||
|
<Addin id="OpenSim.Grid.GridServer" version="0.5" />
|
||||||
|
</Dependencies>
|
||||||
|
<Extension path = "/OpenSim/GridServer">
|
||||||
|
<Plugin id="UserServerPlugin" type="OpenSim.Grid.UserServer.Modules.UserServerPlugin" />
|
||||||
|
</Extension>
|
||||||
|
</Addin>
|
|
@ -1,374 +1,373 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using log4net;
|
using log4net;
|
||||||
using log4net.Config;
|
using log4net.Config;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Data;
|
using OpenSim.Data;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Communications;
|
using OpenSim.Framework.Communications;
|
||||||
using OpenSim.Framework.Communications.Cache;
|
using OpenSim.Framework.Communications.Cache;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Framework.Servers;
|
using OpenSim.Framework.Servers;
|
||||||
using OpenSim.Framework.Statistics;
|
using OpenSim.Framework.Statistics;
|
||||||
using OpenSim.Grid.Communications.OGS1;
|
using OpenSim.Grid.Communications.OGS1;
|
||||||
using OpenSim.Grid.Framework;
|
using OpenSim.Grid.Framework;
|
||||||
using OpenSim.Grid.UserServer.Modules;
|
|
||||||
|
namespace OpenSim.Grid.UserServer.Modules
|
||||||
namespace OpenSim.Grid.UserServer
|
{
|
||||||
{
|
public class UserServerCommandModule
|
||||||
public class UserServerCommandModule
|
{
|
||||||
{
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
protected ConsoleBase m_console;
|
||||||
protected ConsoleBase m_console;
|
protected UserConfig m_cfg;
|
||||||
protected UserConfig m_cfg;
|
|
||||||
|
protected UserDataBaseService m_userDataBaseService;
|
||||||
protected UserDataBaseService m_userDataBaseService;
|
protected UserLoginService m_loginService;
|
||||||
protected UserLoginService m_loginService;
|
|
||||||
|
protected UUID m_lastCreatedUser = UUID.Random();
|
||||||
protected UUID m_lastCreatedUser = UUID.Random();
|
|
||||||
|
protected IGridServiceCore m_core;
|
||||||
protected IGridServiceCore m_core;
|
|
||||||
|
public UserServerCommandModule()
|
||||||
public UserServerCommandModule()
|
{
|
||||||
{
|
}
|
||||||
}
|
|
||||||
|
public void Initialise(IGridServiceCore core)
|
||||||
public void Initialise(IGridServiceCore core)
|
{
|
||||||
{
|
m_core = core;
|
||||||
m_core = core;
|
}
|
||||||
}
|
|
||||||
|
public void PostInitialise()
|
||||||
public void PostInitialise()
|
{
|
||||||
{
|
UserConfig cfg;
|
||||||
UserConfig cfg;
|
if (m_core.TryGet<UserConfig>(out cfg))
|
||||||
if (m_core.TryGet<UserConfig>(out cfg))
|
{
|
||||||
{
|
m_cfg = cfg;
|
||||||
m_cfg = cfg;
|
}
|
||||||
}
|
|
||||||
|
UserDataBaseService userDBservice;
|
||||||
UserDataBaseService userDBservice;
|
if (m_core.TryGet<UserDataBaseService>(out userDBservice))
|
||||||
if (m_core.TryGet<UserDataBaseService>(out userDBservice))
|
{
|
||||||
{
|
m_userDataBaseService = userDBservice;
|
||||||
m_userDataBaseService = userDBservice;
|
}
|
||||||
}
|
|
||||||
|
UserLoginService loginService;
|
||||||
UserLoginService loginService;
|
if (m_core.TryGet<UserLoginService>(out loginService))
|
||||||
if (m_core.TryGet<UserLoginService>(out loginService))
|
{
|
||||||
{
|
m_loginService = loginService;
|
||||||
m_loginService = loginService;
|
}
|
||||||
}
|
|
||||||
|
ConsoleBase console;
|
||||||
ConsoleBase console;
|
if ((m_core.TryGet<ConsoleBase>(out console)) && (m_cfg != null)
|
||||||
if ((m_core.TryGet<ConsoleBase>(out console)) && (m_cfg != null)
|
&& (m_userDataBaseService != null) && (m_loginService != null))
|
||||||
&& (m_userDataBaseService != null) && (m_loginService != null))
|
{
|
||||||
{
|
RegisterConsoleCommands(console);
|
||||||
RegisterConsoleCommands(console);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void RegisterHandlers(BaseHttpServer httpServer)
|
||||||
public void RegisterHandlers(BaseHttpServer httpServer)
|
{
|
||||||
{
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
private void RegisterConsoleCommands(ConsoleBase console)
|
||||||
private void RegisterConsoleCommands(ConsoleBase console)
|
{
|
||||||
{
|
m_console = console;
|
||||||
m_console = console;
|
m_console.Commands.AddCommand("userserver", false, "create user",
|
||||||
m_console.Commands.AddCommand("userserver", false, "create user",
|
"create user [<first> [<last> [<x> <y> [email]]]]",
|
||||||
"create user [<first> [<last> [<x> <y> [email]]]]",
|
"Create a new user account", RunCommand);
|
||||||
"Create a new user account", RunCommand);
|
|
||||||
|
m_console.Commands.AddCommand("userserver", false, "reset user password",
|
||||||
m_console.Commands.AddCommand("userserver", false, "reset user password",
|
"reset user password [<first> [<last> [<new password>]]]",
|
||||||
"reset user password [<first> [<last> [<new password>]]]",
|
"Reset a user's password", RunCommand);
|
||||||
"Reset a user's password", RunCommand);
|
|
||||||
|
m_console.Commands.AddCommand("userserver", false, "login level",
|
||||||
m_console.Commands.AddCommand("userserver", false, "login level",
|
"login level <level>",
|
||||||
"login level <level>",
|
"Set the minimum user level to log in", HandleLoginCommand);
|
||||||
"Set the minimum user level to log in", HandleLoginCommand);
|
|
||||||
|
m_console.Commands.AddCommand("userserver", false, "login reset",
|
||||||
m_console.Commands.AddCommand("userserver", false, "login reset",
|
"login reset",
|
||||||
"login reset",
|
"Reset the login level to allow all users",
|
||||||
"Reset the login level to allow all users",
|
HandleLoginCommand);
|
||||||
HandleLoginCommand);
|
|
||||||
|
m_console.Commands.AddCommand("userserver", false, "login text",
|
||||||
m_console.Commands.AddCommand("userserver", false, "login text",
|
"login text <text>",
|
||||||
"login text <text>",
|
"Set the text users will see on login", HandleLoginCommand);
|
||||||
"Set the text users will see on login", HandleLoginCommand);
|
|
||||||
|
m_console.Commands.AddCommand("userserver", false, "test-inventory",
|
||||||
m_console.Commands.AddCommand("userserver", false, "test-inventory",
|
"test-inventory",
|
||||||
"test-inventory",
|
"Perform a test inventory transaction", RunCommand);
|
||||||
"Perform a test inventory transaction", RunCommand);
|
|
||||||
|
m_console.Commands.AddCommand("userserver", false, "logoff-user",
|
||||||
m_console.Commands.AddCommand("userserver", false, "logoff-user",
|
"logoff-user <first> <last> <message>",
|
||||||
"logoff-user <first> <last> <message>",
|
"Log off a named user", RunCommand);
|
||||||
"Log off a named user", RunCommand);
|
}
|
||||||
}
|
|
||||||
|
#region Console Command Handlers
|
||||||
#region Console Command Handlers
|
public void do_create(string[] args)
|
||||||
public void do_create(string[] args)
|
{
|
||||||
{
|
switch (args[0])
|
||||||
switch (args[0])
|
{
|
||||||
{
|
case "user":
|
||||||
case "user":
|
CreateUser(args);
|
||||||
CreateUser(args);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
/// <summary>
|
/// Execute switch for some of the reset commands
|
||||||
/// Execute switch for some of the reset commands
|
/// </summary>
|
||||||
/// </summary>
|
/// <param name="args"></param>
|
||||||
/// <param name="args"></param>
|
protected void Reset(string[] args)
|
||||||
protected void Reset(string[] args)
|
{
|
||||||
{
|
if (args.Length == 0)
|
||||||
if (args.Length == 0)
|
return;
|
||||||
return;
|
|
||||||
|
switch (args[0])
|
||||||
switch (args[0])
|
{
|
||||||
{
|
case "user":
|
||||||
case "user":
|
|
||||||
|
switch (args[1])
|
||||||
switch (args[1])
|
{
|
||||||
{
|
case "password":
|
||||||
case "password":
|
ResetUserPassword(args);
|
||||||
ResetUserPassword(args);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
/// <summary>
|
/// Create a new user
|
||||||
/// Create a new user
|
/// </summary>
|
||||||
/// </summary>
|
/// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
|
||||||
/// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
|
protected void CreateUser(string[] cmdparams)
|
||||||
protected void CreateUser(string[] cmdparams)
|
{
|
||||||
{
|
string firstName;
|
||||||
string firstName;
|
string lastName;
|
||||||
string lastName;
|
string password;
|
||||||
string password;
|
string email;
|
||||||
string email;
|
uint regX = 1000;
|
||||||
uint regX = 1000;
|
uint regY = 1000;
|
||||||
uint regY = 1000;
|
|
||||||
|
if (cmdparams.Length < 2)
|
||||||
if (cmdparams.Length < 2)
|
firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
|
||||||
firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
|
else firstName = cmdparams[1];
|
||||||
else firstName = cmdparams[1];
|
|
||||||
|
if (cmdparams.Length < 3)
|
||||||
if (cmdparams.Length < 3)
|
lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
|
||||||
lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
|
else lastName = cmdparams[2];
|
||||||
else lastName = cmdparams[2];
|
|
||||||
|
if (cmdparams.Length < 4)
|
||||||
if (cmdparams.Length < 4)
|
password = MainConsole.Instance.PasswdPrompt("Password");
|
||||||
password = MainConsole.Instance.PasswdPrompt("Password");
|
else password = cmdparams[3];
|
||||||
else password = cmdparams[3];
|
|
||||||
|
if (cmdparams.Length < 5)
|
||||||
if (cmdparams.Length < 5)
|
regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
|
||||||
regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
|
else regX = Convert.ToUInt32(cmdparams[4]);
|
||||||
else regX = Convert.ToUInt32(cmdparams[4]);
|
|
||||||
|
if (cmdparams.Length < 6)
|
||||||
if (cmdparams.Length < 6)
|
regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
|
||||||
regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
|
else regY = Convert.ToUInt32(cmdparams[5]);
|
||||||
else regY = Convert.ToUInt32(cmdparams[5]);
|
|
||||||
|
if (cmdparams.Length < 7)
|
||||||
if (cmdparams.Length < 7)
|
email = MainConsole.Instance.CmdPrompt("Email", "");
|
||||||
email = MainConsole.Instance.CmdPrompt("Email", "");
|
else email = cmdparams[6];
|
||||||
else email = cmdparams[6];
|
|
||||||
|
if (null == m_userDataBaseService.GetUserProfile(firstName, lastName))
|
||||||
if (null == m_userDataBaseService.GetUserProfile(firstName, lastName))
|
{
|
||||||
{
|
m_lastCreatedUser = m_userDataBaseService.AddUser(firstName, lastName, password, email, regX, regY);
|
||||||
m_lastCreatedUser = m_userDataBaseService.AddUser(firstName, lastName, password, email, regX, regY);
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", firstName, lastName);
|
||||||
m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", firstName, lastName);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
/// <summary>
|
/// Reset a user password.
|
||||||
/// Reset a user password.
|
/// </summary>
|
||||||
/// </summary>
|
/// <param name="cmdparams"></param>
|
||||||
/// <param name="cmdparams"></param>
|
private void ResetUserPassword(string[] cmdparams)
|
||||||
private void ResetUserPassword(string[] cmdparams)
|
{
|
||||||
{
|
string firstName;
|
||||||
string firstName;
|
string lastName;
|
||||||
string lastName;
|
string newPassword;
|
||||||
string newPassword;
|
|
||||||
|
if (cmdparams.Length < 3)
|
||||||
if (cmdparams.Length < 3)
|
firstName = MainConsole.Instance.CmdPrompt("First name");
|
||||||
firstName = MainConsole.Instance.CmdPrompt("First name");
|
else firstName = cmdparams[2];
|
||||||
else firstName = cmdparams[2];
|
|
||||||
|
if (cmdparams.Length < 4)
|
||||||
if (cmdparams.Length < 4)
|
lastName = MainConsole.Instance.CmdPrompt("Last name");
|
||||||
lastName = MainConsole.Instance.CmdPrompt("Last name");
|
else lastName = cmdparams[3];
|
||||||
else lastName = cmdparams[3];
|
|
||||||
|
if (cmdparams.Length < 5)
|
||||||
if (cmdparams.Length < 5)
|
newPassword = MainConsole.Instance.PasswdPrompt("New password");
|
||||||
newPassword = MainConsole.Instance.PasswdPrompt("New password");
|
else newPassword = cmdparams[4];
|
||||||
else newPassword = cmdparams[4];
|
|
||||||
|
m_userDataBaseService.ResetUserPassword(firstName, lastName, newPassword);
|
||||||
m_userDataBaseService.ResetUserPassword(firstName, lastName, newPassword);
|
}
|
||||||
}
|
|
||||||
|
/*
|
||||||
/*
|
private void HandleTestCommand(string module, string[] cmd)
|
||||||
private void HandleTestCommand(string module, string[] cmd)
|
{
|
||||||
{
|
m_log.Info("test command received");
|
||||||
m_log.Info("test command received");
|
}
|
||||||
}
|
*/
|
||||||
*/
|
|
||||||
|
private void HandleLoginCommand(string module, string[] cmd)
|
||||||
private void HandleLoginCommand(string module, string[] cmd)
|
{
|
||||||
{
|
string subcommand = cmd[1];
|
||||||
string subcommand = cmd[1];
|
|
||||||
|
switch (subcommand)
|
||||||
switch (subcommand)
|
{
|
||||||
{
|
case "level":
|
||||||
case "level":
|
// Set the minimal level to allow login
|
||||||
// Set the minimal level to allow login
|
// Useful to allow grid update without worrying about users.
|
||||||
// Useful to allow grid update without worrying about users.
|
// or fixing critical issues
|
||||||
// or fixing critical issues
|
//
|
||||||
//
|
if (cmd.Length > 2)
|
||||||
if (cmd.Length > 2)
|
{
|
||||||
{
|
int level = Convert.ToInt32(cmd[2]);
|
||||||
int level = Convert.ToInt32(cmd[2]);
|
m_loginService.setloginlevel(level);
|
||||||
m_loginService.setloginlevel(level);
|
}
|
||||||
}
|
break;
|
||||||
break;
|
case "reset":
|
||||||
case "reset":
|
m_loginService.setloginlevel(0);
|
||||||
m_loginService.setloginlevel(0);
|
break;
|
||||||
break;
|
case "text":
|
||||||
case "text":
|
if (cmd.Length > 2)
|
||||||
if (cmd.Length > 2)
|
{
|
||||||
{
|
m_loginService.setwelcometext(cmd[2]);
|
||||||
m_loginService.setwelcometext(cmd[2]);
|
}
|
||||||
}
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void RunCommand(string module, string[] cmd)
|
||||||
public void RunCommand(string module, string[] cmd)
|
{
|
||||||
{
|
List<string> args = new List<string>(cmd);
|
||||||
List<string> args = new List<string>(cmd);
|
string command = cmd[0];
|
||||||
string command = cmd[0];
|
|
||||||
|
args.RemoveAt(0);
|
||||||
args.RemoveAt(0);
|
|
||||||
|
string[] cmdparams = args.ToArray();
|
||||||
string[] cmdparams = args.ToArray();
|
|
||||||
|
switch (command)
|
||||||
switch (command)
|
{
|
||||||
{
|
case "create":
|
||||||
case "create":
|
do_create(cmdparams);
|
||||||
do_create(cmdparams);
|
break;
|
||||||
break;
|
|
||||||
|
case "reset":
|
||||||
case "reset":
|
Reset(cmdparams);
|
||||||
Reset(cmdparams);
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
|
case "test-inventory":
|
||||||
case "test-inventory":
|
// RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
|
||||||
// RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
|
// requester.ReturnResponseVal = TestResponse;
|
||||||
// requester.ReturnResponseVal = TestResponse;
|
// requester.BeginPostObject<UUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
|
||||||
// requester.BeginPostObject<UUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
|
SynchronousRestObjectPoster.BeginPostObject<UUID, List<InventoryFolderBase>>(
|
||||||
SynchronousRestObjectPoster.BeginPostObject<UUID, List<InventoryFolderBase>>(
|
"POST", m_cfg.InventoryUrl + "RootFolders/", m_lastCreatedUser);
|
||||||
"POST", m_cfg.InventoryUrl + "RootFolders/", m_lastCreatedUser);
|
break;
|
||||||
break;
|
|
||||||
|
case "logoff-user":
|
||||||
case "logoff-user":
|
if (cmdparams.Length >= 3)
|
||||||
if (cmdparams.Length >= 3)
|
{
|
||||||
{
|
string firstname = cmdparams[0];
|
||||||
string firstname = cmdparams[0];
|
string lastname = cmdparams[1];
|
||||||
string lastname = cmdparams[1];
|
string message = "";
|
||||||
string message = "";
|
|
||||||
|
for (int i = 2; i < cmdparams.Length; i++)
|
||||||
for (int i = 2; i < cmdparams.Length; i++)
|
message += " " + cmdparams[i];
|
||||||
message += " " + cmdparams[i];
|
|
||||||
|
UserProfileData theUser = null;
|
||||||
UserProfileData theUser = null;
|
try
|
||||||
try
|
{
|
||||||
{
|
theUser = m_loginService.GetTheUser(firstname, lastname);
|
||||||
theUser = m_loginService.GetTheUser(firstname, lastname);
|
}
|
||||||
}
|
catch (Exception)
|
||||||
catch (Exception)
|
{
|
||||||
{
|
m_log.Error("[LOGOFF]: Error getting user data from the database.");
|
||||||
m_log.Error("[LOGOFF]: Error getting user data from the database.");
|
}
|
||||||
}
|
|
||||||
|
if (theUser != null)
|
||||||
if (theUser != null)
|
{
|
||||||
{
|
if (theUser.CurrentAgent != null)
|
||||||
if (theUser.CurrentAgent != null)
|
{
|
||||||
{
|
if (theUser.CurrentAgent.AgentOnline)
|
||||||
if (theUser.CurrentAgent.AgentOnline)
|
{
|
||||||
{
|
m_log.Info("[LOGOFF]: Logging off requested user!");
|
||||||
m_log.Info("[LOGOFF]: Logging off requested user!");
|
m_loginService.LogOffUser(theUser, message);
|
||||||
m_loginService.LogOffUser(theUser, message);
|
|
||||||
|
theUser.CurrentAgent.AgentOnline = false;
|
||||||
theUser.CurrentAgent.AgentOnline = false;
|
|
||||||
|
m_loginService.CommitAgent(ref theUser);
|
||||||
m_loginService.CommitAgent(ref theUser);
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
m_log.Info(
|
||||||
m_log.Info(
|
"[LOGOFF]: User Doesn't appear to be online, sending the logoff message anyway.");
|
||||||
"[LOGOFF]: User Doesn't appear to be online, sending the logoff message anyway.");
|
m_loginService.LogOffUser(theUser, message);
|
||||||
m_loginService.LogOffUser(theUser, message);
|
|
||||||
|
theUser.CurrentAgent.AgentOnline = false;
|
||||||
theUser.CurrentAgent.AgentOnline = false;
|
|
||||||
|
m_loginService.CommitAgent(ref theUser);
|
||||||
m_loginService.CommitAgent(ref theUser);
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
m_log.Error(
|
||||||
m_log.Error(
|
"[LOGOFF]: Unable to logoff-user. User doesn't have an agent record so I can't find the simulator to notify");
|
||||||
"[LOGOFF]: Unable to logoff-user. User doesn't have an agent record so I can't find the simulator to notify");
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
m_log.Info("[LOGOFF]: User doesn't exist in the database");
|
||||||
m_log.Info("[LOGOFF]: User doesn't exist in the database");
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
m_log.Error(
|
||||||
m_log.Error(
|
"[LOGOFF]: Invalid amount of parameters. logoff-user takes at least three. Firstname, Lastname, and message");
|
||||||
"[LOGOFF]: Invalid amount of parameters. logoff-user takes at least three. Firstname, Lastname, and message");
|
}
|
||||||
}
|
|
||||||
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
#endregion
|
||||||
#endregion
|
}
|
||||||
}
|
|
|
@ -1,141 +1,140 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using log4net;
|
using log4net;
|
||||||
using log4net.Config;
|
using log4net.Config;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Data;
|
using OpenSim.Data;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Communications;
|
using OpenSim.Framework.Communications;
|
||||||
using OpenSim.Framework.Communications.Cache;
|
using OpenSim.Framework.Communications.Cache;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Framework.Servers;
|
using OpenSim.Framework.Servers;
|
||||||
using OpenSim.Framework.Statistics;
|
using OpenSim.Framework.Statistics;
|
||||||
using OpenSim.Grid.Communications.OGS1;
|
using OpenSim.Grid.Communications.OGS1;
|
||||||
using OpenSim.Grid.Framework;
|
using OpenSim.Grid.Framework;
|
||||||
using OpenSim.Grid.UserServer.Modules;
|
|
||||||
|
namespace OpenSim.Grid.UserServer.Modules
|
||||||
namespace OpenSim.Grid.UserServer
|
{
|
||||||
{
|
//Do we actually need these event dispatchers?
|
||||||
//Do we actually need these event dispatchers?
|
//shouldn't the other modules just directly register event handlers to each other?
|
||||||
//shouldn't the other modules just directly register event handlers to each other?
|
public class UserServerEventDispatchModule
|
||||||
public class UserServerEventDispatchModule
|
{
|
||||||
{
|
protected UserManager m_userManager;
|
||||||
protected UserManager m_userManager;
|
protected MessageServersConnector m_messagesService;
|
||||||
protected MessageServersConnector m_messagesService;
|
protected UserLoginService m_loginService;
|
||||||
protected UserLoginService m_loginService;
|
|
||||||
|
public UserServerEventDispatchModule(UserManager userManager, MessageServersConnector messagesService, UserLoginService loginService)
|
||||||
public UserServerEventDispatchModule(UserManager userManager, MessageServersConnector messagesService, UserLoginService loginService)
|
{
|
||||||
{
|
m_userManager = userManager;
|
||||||
m_userManager = userManager;
|
m_messagesService = messagesService;
|
||||||
m_messagesService = messagesService;
|
m_loginService = loginService;
|
||||||
m_loginService = loginService;
|
}
|
||||||
}
|
|
||||||
|
public void Initialise(IGridServiceCore core)
|
||||||
public void Initialise(IGridServiceCore core)
|
{
|
||||||
{
|
}
|
||||||
}
|
|
||||||
|
public void PostInitialise()
|
||||||
public void PostInitialise()
|
{
|
||||||
{
|
m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation;
|
||||||
m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation;
|
m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff;
|
||||||
m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff;
|
|
||||||
|
m_messagesService.OnAgentLocation += HandleAgentLocation;
|
||||||
m_messagesService.OnAgentLocation += HandleAgentLocation;
|
m_messagesService.OnAgentLeaving += HandleAgentLeaving;
|
||||||
m_messagesService.OnAgentLeaving += HandleAgentLeaving;
|
m_messagesService.OnRegionStartup += HandleRegionStartup;
|
||||||
m_messagesService.OnRegionStartup += HandleRegionStartup;
|
m_messagesService.OnRegionShutdown += HandleRegionShutdown;
|
||||||
m_messagesService.OnRegionShutdown += HandleRegionShutdown;
|
}
|
||||||
}
|
|
||||||
|
public void RegisterHandlers(BaseHttpServer httpServer)
|
||||||
public void RegisterHandlers(BaseHttpServer httpServer)
|
{
|
||||||
{
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
public void Close()
|
||||||
public void Close()
|
{
|
||||||
{
|
m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
|
||||||
m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
|
}
|
||||||
}
|
|
||||||
|
#region Event Handlers
|
||||||
#region Event Handlers
|
public void NotifyMessageServersUserLoggOff(UUID agentID)
|
||||||
public void NotifyMessageServersUserLoggOff(UUID agentID)
|
{
|
||||||
{
|
m_messagesService.TellMessageServersAboutUserLogoff(agentID);
|
||||||
m_messagesService.TellMessageServersAboutUserLogoff(agentID);
|
}
|
||||||
}
|
|
||||||
|
public void NotifyMessageServersUserLoggedInToLocation(UUID agentID, UUID sessionID, UUID RegionID,
|
||||||
public void NotifyMessageServersUserLoggedInToLocation(UUID agentID, UUID sessionID, UUID RegionID,
|
ulong regionhandle, float positionX, float positionY,
|
||||||
ulong regionhandle, float positionX, float positionY,
|
float positionZ, string firstname, string lastname)
|
||||||
float positionZ, string firstname, string lastname)
|
{
|
||||||
{
|
m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, positionX,
|
||||||
m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, positionX,
|
positionY, positionZ, firstname, lastname);
|
||||||
positionY, positionZ, firstname, lastname);
|
}
|
||||||
}
|
|
||||||
|
public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle)
|
||||||
public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle)
|
{
|
||||||
{
|
m_userManager.HandleAgentLocation(agentID, regionID, regionHandle);
|
||||||
m_userManager.HandleAgentLocation(agentID, regionID, regionHandle);
|
}
|
||||||
}
|
|
||||||
|
public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle)
|
||||||
public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle)
|
{
|
||||||
{
|
m_userManager.HandleAgentLeaving(agentID, regionID, regionHandle);
|
||||||
m_userManager.HandleAgentLeaving(agentID, regionID, regionHandle);
|
}
|
||||||
}
|
|
||||||
|
public void HandleRegionStartup(UUID regionID)
|
||||||
public void HandleRegionStartup(UUID regionID)
|
{
|
||||||
{
|
// This might seem strange, that we send this back to the
|
||||||
// This might seem strange, that we send this back to the
|
// server it came from. But there is method to the madness.
|
||||||
// server it came from. But there is method to the madness.
|
// There can be multiple user servers on the same database,
|
||||||
// There can be multiple user servers on the same database,
|
// and each can have multiple messaging servers. So, we send
|
||||||
// and each can have multiple messaging servers. So, we send
|
// it to all known user servers, who send it to all known
|
||||||
// it to all known user servers, who send it to all known
|
// message servers. That way, we should be able to finally
|
||||||
// message servers. That way, we should be able to finally
|
// update presence to all regions and thereby all friends
|
||||||
// update presence to all regions and thereby all friends
|
//
|
||||||
//
|
m_userManager.HandleRegionStartup(regionID);
|
||||||
m_userManager.HandleRegionStartup(regionID);
|
m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
|
||||||
m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
|
}
|
||||||
}
|
|
||||||
|
public void HandleRegionShutdown(UUID regionID)
|
||||||
public void HandleRegionShutdown(UUID regionID)
|
{
|
||||||
{
|
// This might seem strange, that we send this back to the
|
||||||
// This might seem strange, that we send this back to the
|
// server it came from. But there is method to the madness.
|
||||||
// server it came from. But there is method to the madness.
|
// There can be multiple user servers on the same database,
|
||||||
// There can be multiple user servers on the same database,
|
// and each can have multiple messaging servers. So, we send
|
||||||
// and each can have multiple messaging servers. So, we send
|
// it to all known user servers, who send it to all known
|
||||||
// it to all known user servers, who send it to all known
|
// message servers. That way, we should be able to finally
|
||||||
// message servers. That way, we should be able to finally
|
// update presence to all regions and thereby all friends
|
||||||
// update presence to all regions and thereby all friends
|
//
|
||||||
//
|
m_userManager.HandleRegionShutdown(regionID);
|
||||||
m_userManager.HandleRegionShutdown(regionID);
|
m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
|
||||||
m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
|
}
|
||||||
}
|
#endregion
|
||||||
#endregion
|
}
|
||||||
}
|
}
|
||||||
}
|
|
|
@ -0,0 +1,231 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using log4net;
|
||||||
|
using log4net.Config;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using OpenSim.Data;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Framework.Communications;
|
||||||
|
using OpenSim.Framework.Communications.Cache;
|
||||||
|
using OpenSim.Framework.Console;
|
||||||
|
using OpenSim.Framework.Servers;
|
||||||
|
using OpenSim.Framework.Statistics;
|
||||||
|
using OpenSim.Grid.Communications.OGS1;
|
||||||
|
using OpenSim.Grid.Framework;
|
||||||
|
using OpenSim.Grid.GridServer;
|
||||||
|
|
||||||
|
namespace OpenSim.Grid.UserServer.Modules
|
||||||
|
{
|
||||||
|
public class UserServerPlugin : IGridPlugin
|
||||||
|
{
|
||||||
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
protected UserConfig m_cfg;
|
||||||
|
|
||||||
|
protected UserDataBaseService m_userDataBaseService;
|
||||||
|
|
||||||
|
public UserManager m_userManager;
|
||||||
|
|
||||||
|
protected UserServerAvatarAppearanceModule m_avatarAppearanceModule;
|
||||||
|
protected UserServerFriendsModule m_friendsModule;
|
||||||
|
|
||||||
|
public UserLoginService m_loginService;
|
||||||
|
public MessageServersConnector m_messagesService;
|
||||||
|
|
||||||
|
protected GridInfoServiceModule m_gridInfoService;
|
||||||
|
|
||||||
|
protected UserServerCommandModule m_consoleCommandModule;
|
||||||
|
protected UserServerEventDispatchModule m_eventDispatcher;
|
||||||
|
|
||||||
|
protected BaseHttpServer m_httpServer;
|
||||||
|
|
||||||
|
protected IGridServiceCore m_core;
|
||||||
|
|
||||||
|
protected ConsoleBase m_console;
|
||||||
|
|
||||||
|
|
||||||
|
public UserServerPlugin()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IGridPlugin Members
|
||||||
|
|
||||||
|
public void Initialise(GridServerBase gridServer)
|
||||||
|
{
|
||||||
|
Initialise(gridServer.HttpServer, gridServer, gridServer.UConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public void Initialise(BaseHttpServer httpServer, IGridServiceCore core, UserConfig config)
|
||||||
|
{
|
||||||
|
m_httpServer = httpServer;
|
||||||
|
m_core = core;
|
||||||
|
m_cfg = config;
|
||||||
|
m_console = MainConsole.Instance;
|
||||||
|
|
||||||
|
IInterServiceInventoryServices inventoryService = StartupCoreComponents();
|
||||||
|
|
||||||
|
//setup services/modules
|
||||||
|
StartupUserServerModules();
|
||||||
|
|
||||||
|
StartOtherComponents(inventoryService);
|
||||||
|
|
||||||
|
//PostInitialise the modules
|
||||||
|
PostInitialiseModules();
|
||||||
|
|
||||||
|
RegisterHttpHandlers();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual IInterServiceInventoryServices StartupCoreComponents()
|
||||||
|
{
|
||||||
|
|
||||||
|
m_core.RegisterInterface<ConsoleBase>(m_console);
|
||||||
|
m_core.RegisterInterface<UserConfig>(m_cfg);
|
||||||
|
|
||||||
|
//Should be in modules?
|
||||||
|
IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(m_cfg.InventoryUrl);
|
||||||
|
// IRegionProfileRouter regionProfileService = new RegionProfileServiceProxy();
|
||||||
|
|
||||||
|
m_core.RegisterInterface<IInterServiceInventoryServices>(inventoryService);
|
||||||
|
// RegisterInterface<IRegionProfileRouter>(regionProfileService);
|
||||||
|
|
||||||
|
return inventoryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Start up the user manager
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inventoryService"></param>
|
||||||
|
protected virtual void StartupUserServerModules()
|
||||||
|
{
|
||||||
|
m_log.Info("[STARTUP]: Establishing data connection");
|
||||||
|
//setup database access service, for now this has to be created before the other modules.
|
||||||
|
m_userDataBaseService = new UserDataBaseService();
|
||||||
|
m_userDataBaseService.Initialise(m_core);
|
||||||
|
|
||||||
|
//TODO: change these modules so they fetch the databaseService class in the PostInitialise method
|
||||||
|
m_userManager = new UserManager(m_userDataBaseService);
|
||||||
|
m_userManager.Initialise(m_core);
|
||||||
|
|
||||||
|
m_avatarAppearanceModule = new UserServerAvatarAppearanceModule(m_userDataBaseService);
|
||||||
|
m_avatarAppearanceModule.Initialise(m_core);
|
||||||
|
|
||||||
|
m_friendsModule = new UserServerFriendsModule(m_userDataBaseService);
|
||||||
|
m_friendsModule.Initialise(m_core);
|
||||||
|
|
||||||
|
m_consoleCommandModule = new UserServerCommandModule();
|
||||||
|
m_consoleCommandModule.Initialise(m_core);
|
||||||
|
|
||||||
|
m_messagesService = new MessageServersConnector();
|
||||||
|
m_messagesService.Initialise(m_core);
|
||||||
|
|
||||||
|
m_gridInfoService = new GridInfoServiceModule();
|
||||||
|
m_gridInfoService.Initialise(m_core);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void StartOtherComponents(IInterServiceInventoryServices inventoryService)
|
||||||
|
{
|
||||||
|
StartupLoginService(inventoryService);
|
||||||
|
//
|
||||||
|
// Get the minimum defaultLevel to access to the grid
|
||||||
|
//
|
||||||
|
m_loginService.setloginlevel((int)m_cfg.DefaultUserLevel);
|
||||||
|
|
||||||
|
m_core.RegisterInterface<UserLoginService>(m_loginService); //TODO: should be done in the login service
|
||||||
|
|
||||||
|
m_eventDispatcher = new UserServerEventDispatchModule(m_userManager, m_messagesService, m_loginService);
|
||||||
|
m_eventDispatcher.Initialise(m_core);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Start up the login service
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inventoryService"></param>
|
||||||
|
protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService)
|
||||||
|
{
|
||||||
|
m_loginService = new UserLoginService(
|
||||||
|
m_userDataBaseService, inventoryService, new LibraryRootFolder(m_cfg.LibraryXmlfile), m_cfg, m_cfg.DefaultStartupMsg, new RegionProfileServiceProxy());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void PostInitialiseModules()
|
||||||
|
{
|
||||||
|
m_consoleCommandModule.PostInitialise(); //it will register its Console command handlers in here
|
||||||
|
m_userDataBaseService.PostInitialise();
|
||||||
|
m_messagesService.PostInitialise();
|
||||||
|
m_eventDispatcher.PostInitialise(); //it will register event handlers in here
|
||||||
|
m_gridInfoService.PostInitialise();
|
||||||
|
m_userManager.PostInitialise();
|
||||||
|
m_avatarAppearanceModule.PostInitialise();
|
||||||
|
m_friendsModule.PostInitialise();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void RegisterHttpHandlers()
|
||||||
|
{
|
||||||
|
m_loginService.RegisterHandlers(m_httpServer, m_cfg.EnableLLSDLogin, true);
|
||||||
|
|
||||||
|
m_userManager.RegisterHandlers(m_httpServer);
|
||||||
|
m_friendsModule.RegisterHandlers(m_httpServer);
|
||||||
|
m_avatarAppearanceModule.RegisterHandlers(m_httpServer);
|
||||||
|
m_messagesService.RegisterHandlers(m_httpServer);
|
||||||
|
m_gridInfoService.RegisterHandlers(m_httpServer);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IPlugin Members
|
||||||
|
|
||||||
|
public string Version
|
||||||
|
{
|
||||||
|
get { return "0.0"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return "UserServerPlugin"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialise()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IDisposable Members
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -54,20 +54,7 @@ namespace OpenSim.Grid.UserServer
|
||||||
|
|
||||||
protected UserConfig Cfg;
|
protected UserConfig Cfg;
|
||||||
|
|
||||||
protected UserDataBaseService m_userDataBaseService;
|
protected UserServerPlugin m_serverPlugin;
|
||||||
|
|
||||||
public UserManager m_userManager;
|
|
||||||
|
|
||||||
protected UserServerAvatarAppearanceModule m_avatarAppearanceModule;
|
|
||||||
protected UserServerFriendsModule m_friendsModule;
|
|
||||||
|
|
||||||
public UserLoginService m_loginService;
|
|
||||||
public MessageServersConnector m_messagesService;
|
|
||||||
|
|
||||||
protected GridInfoServiceModule m_gridInfoService;
|
|
||||||
|
|
||||||
protected UserServerCommandModule m_consoleCommandModule;
|
|
||||||
protected UserServerEventDispatchModule m_eventDispatcher;
|
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
@ -99,126 +86,23 @@ namespace OpenSim.Grid.UserServer
|
||||||
|
|
||||||
protected override void StartupSpecific()
|
protected override void StartupSpecific()
|
||||||
{
|
{
|
||||||
IInterServiceInventoryServices inventoryService = StartupCoreComponents();
|
Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml")));
|
||||||
|
|
||||||
m_stats = StatsManager.StartCollectingUserStats();
|
m_stats = StatsManager.StartCollectingUserStats();
|
||||||
|
|
||||||
//setup services/modules
|
m_httpServer = new BaseHttpServer(Cfg.HttpPort);
|
||||||
StartupUserServerModules();
|
|
||||||
|
|
||||||
StartOtherComponents(inventoryService);
|
m_serverPlugin = new UserServerPlugin();
|
||||||
|
m_serverPlugin.Initialise(m_httpServer, this, Cfg);
|
||||||
//PostInitialise the modules
|
|
||||||
PostInitialiseModules();
|
|
||||||
|
|
||||||
//register http handlers and start http server
|
|
||||||
m_log.Info("[STARTUP]: Starting HTTP process");
|
|
||||||
RegisterHttpHandlers();
|
|
||||||
m_httpServer.Start();
|
m_httpServer.Start();
|
||||||
|
|
||||||
base.StartupSpecific();
|
base.StartupSpecific();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual IInterServiceInventoryServices StartupCoreComponents()
|
|
||||||
{
|
|
||||||
Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml")));
|
|
||||||
|
|
||||||
m_httpServer = new BaseHttpServer(Cfg.HttpPort);
|
|
||||||
|
|
||||||
RegisterInterface<ConsoleBase>(m_console);
|
|
||||||
RegisterInterface<UserConfig>(Cfg);
|
|
||||||
|
|
||||||
//Should be in modules?
|
|
||||||
IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl);
|
|
||||||
// IRegionProfileRouter regionProfileService = new RegionProfileServiceProxy();
|
|
||||||
|
|
||||||
RegisterInterface<IInterServiceInventoryServices>(inventoryService);
|
|
||||||
// RegisterInterface<IRegionProfileRouter>(regionProfileService);
|
|
||||||
|
|
||||||
return inventoryService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Start up the user manager
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="inventoryService"></param>
|
|
||||||
protected virtual void StartupUserServerModules()
|
|
||||||
{
|
|
||||||
m_log.Info("[STARTUP]: Establishing data connection");
|
|
||||||
//setup database access service, for now this has to be created before the other modules.
|
|
||||||
m_userDataBaseService = new UserDataBaseService();
|
|
||||||
m_userDataBaseService.Initialise(this);
|
|
||||||
|
|
||||||
//TODO: change these modules so they fetch the databaseService class in the PostInitialise method
|
|
||||||
m_userManager = new UserManager(m_userDataBaseService);
|
|
||||||
m_userManager.Initialise(this);
|
|
||||||
|
|
||||||
m_avatarAppearanceModule = new UserServerAvatarAppearanceModule(m_userDataBaseService);
|
|
||||||
m_avatarAppearanceModule.Initialise(this);
|
|
||||||
|
|
||||||
m_friendsModule = new UserServerFriendsModule(m_userDataBaseService);
|
|
||||||
m_friendsModule.Initialise(this);
|
|
||||||
|
|
||||||
m_consoleCommandModule = new UserServerCommandModule();
|
|
||||||
m_consoleCommandModule.Initialise(this);
|
|
||||||
|
|
||||||
m_messagesService = new MessageServersConnector();
|
|
||||||
m_messagesService.Initialise(this);
|
|
||||||
|
|
||||||
m_gridInfoService = new GridInfoServiceModule();
|
|
||||||
m_gridInfoService.Initialise(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void StartOtherComponents(IInterServiceInventoryServices inventoryService)
|
|
||||||
{
|
|
||||||
StartupLoginService(inventoryService);
|
|
||||||
//
|
|
||||||
// Get the minimum defaultLevel to access to the grid
|
|
||||||
//
|
|
||||||
m_loginService.setloginlevel((int)Cfg.DefaultUserLevel);
|
|
||||||
|
|
||||||
RegisterInterface<UserLoginService>(m_loginService); //TODO: should be done in the login service
|
|
||||||
|
|
||||||
m_eventDispatcher = new UserServerEventDispatchModule(m_userManager, m_messagesService, m_loginService);
|
|
||||||
m_eventDispatcher.Initialise(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Start up the login service
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="inventoryService"></param>
|
|
||||||
protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService)
|
|
||||||
{
|
|
||||||
m_loginService = new UserLoginService(
|
|
||||||
m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void PostInitialiseModules()
|
|
||||||
{
|
|
||||||
m_consoleCommandModule.PostInitialise(); //it will register its Console command handlers in here
|
|
||||||
m_userDataBaseService.PostInitialise();
|
|
||||||
m_messagesService.PostInitialise();
|
|
||||||
m_eventDispatcher.PostInitialise(); //it will register event handlers in here
|
|
||||||
m_gridInfoService.PostInitialise();
|
|
||||||
m_userManager.PostInitialise();
|
|
||||||
m_avatarAppearanceModule.PostInitialise();
|
|
||||||
m_friendsModule.PostInitialise();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void RegisterHttpHandlers()
|
|
||||||
{
|
|
||||||
m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true);
|
|
||||||
|
|
||||||
m_userManager.RegisterHandlers(m_httpServer);
|
|
||||||
m_friendsModule.RegisterHandlers(m_httpServer);
|
|
||||||
m_avatarAppearanceModule.RegisterHandlers(m_httpServer);
|
|
||||||
m_messagesService.RegisterHandlers(m_httpServer);
|
|
||||||
m_gridInfoService.RegisterHandlers(m_httpServer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void ShutdownSpecific()
|
public override void ShutdownSpecific()
|
||||||
{
|
{
|
||||||
m_eventDispatcher.Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IUGAIMCore
|
#region IUGAIMCore
|
||||||
|
@ -262,9 +146,5 @@ namespace OpenSim.Grid.UserServer
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public void TestResponse(List<InventoryFolderBase> resp)
|
|
||||||
{
|
|
||||||
m_console.Notice("response got");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
BIN
bin/AprSharp.pdb
BIN
bin/AprSharp.pdb
Binary file not shown.
BIN
bin/MXP.pdb
BIN
bin/MXP.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,2 @@
|
||||||
|
[Startup]
|
||||||
|
HttpPort=8051
|
Binary file not shown.
BIN
bin/libapr.pdb
BIN
bin/libapr.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -955,6 +955,7 @@
|
||||||
<Reference name="OpenSim.Framework.Statistics"/>
|
<Reference name="OpenSim.Framework.Statistics"/>
|
||||||
<Reference name="OpenSim.Grid.Framework"/>
|
<Reference name="OpenSim.Grid.Framework"/>
|
||||||
<Reference name="OpenSim.Grid.Communications.OGS1"/>
|
<Reference name="OpenSim.Grid.Communications.OGS1"/>
|
||||||
|
<Reference name="OpenSim.Grid.GridServer"/>
|
||||||
<Reference name="OpenMetaverseTypes.dll"/>
|
<Reference name="OpenMetaverseTypes.dll"/>
|
||||||
<Reference name="OpenMetaverse.StructuredData.dll"/>
|
<Reference name="OpenMetaverse.StructuredData.dll"/>
|
||||||
<Reference name="XMLRPC.dll"/>
|
<Reference name="XMLRPC.dll"/>
|
||||||
|
@ -963,6 +964,7 @@
|
||||||
|
|
||||||
<Files>
|
<Files>
|
||||||
<Match pattern="*.cs" recurse="true"/>
|
<Match pattern="*.cs" recurse="true"/>
|
||||||
|
<Match path="Resources" pattern="*.addin.xml" buildAction="EmbeddedResource" recurse="true" />
|
||||||
</Files>
|
</Files>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
|
@ -992,6 +994,7 @@
|
||||||
<Reference name="OpenSim.Framework.Statistics"/>
|
<Reference name="OpenSim.Framework.Statistics"/>
|
||||||
<Reference name="OpenSim.Grid.Communications.OGS1"/>
|
<Reference name="OpenSim.Grid.Communications.OGS1"/>
|
||||||
<Reference name="OpenSim.Grid.Framework"/>
|
<Reference name="OpenSim.Grid.Framework"/>
|
||||||
|
<Reference name="OpenSim.Grid.GridServer"/>
|
||||||
<Reference name="OpenSim.Grid.UserServer.Modules"/>
|
<Reference name="OpenSim.Grid.UserServer.Modules"/>
|
||||||
<Reference name="OpenMetaverseTypes.dll"/>
|
<Reference name="OpenMetaverseTypes.dll"/>
|
||||||
<Reference name="OpenMetaverse.StructuredData.dll"/>
|
<Reference name="OpenMetaverse.StructuredData.dll"/>
|
||||||
|
|
Loading…
Reference in New Issue