Add rest console support to the user server. Will ask new questions at

startup. To use, run it normally once, answering the questions, then
run again with -console=rest.
Also now supports -console=basic for a console that reads stdin
This commit is contained in:
Melanie
2009-08-19 04:39:02 +01:00
parent d95d3b949b
commit 99c7a43ffd
4 changed files with 81 additions and 1 deletions

View File

@@ -43,6 +43,7 @@ using OpenSim.Framework.Statistics;
using OpenSim.Grid.Communications.OGS1;
using OpenSim.Grid.Framework;
using OpenSim.Grid.UserServer.Modules;
using Nini.Config;
namespace OpenSim.Grid.UserServer
{
@@ -73,8 +74,22 @@ namespace OpenSim.Grid.UserServer
protected AvatarCreationModule m_appearanceModule;
protected static string m_consoleType = "local";
protected static IConfigSource m_config = null;
public static void Main(string[] args)
{
ArgvConfigSource argvSource = new ArgvConfigSource(args);
argvSource.AddSwitch("Startup", "console", "c");
IConfig startupConfig = argvSource.Configs["Startup"];
if (startupConfig != null)
{
m_consoleType = startupConfig.GetString("console", "local");
}
m_config = argvSource;
XmlConfigurator.Configure();
m_log.Info("Launching UserServer...");
@@ -87,7 +102,18 @@ namespace OpenSim.Grid.UserServer
public OpenUser_Main()
{
m_console = new LocalConsole("User");
switch (m_consoleType)
{
case "rest":
m_console = new RemoteConsole("User");
break;
case "basic":
m_console = new CommandConsole("User");
break;
default:
m_console = new LocalConsole("User");
break;
}
MainConsole.Instance = m_console;
}
@@ -129,6 +155,17 @@ namespace OpenSim.Grid.UserServer
m_httpServer = new BaseHttpServer(Cfg.HttpPort);
if (m_console is RemoteConsole)
{
System.Console.WriteLine("Initialized REST console");
RemoteConsole c = (RemoteConsole)m_console;
c.SetServer(m_httpServer);
IConfig netConfig = m_config.AddConfig("Network");
netConfig.Set("ConsoleUser", Cfg.ConsoleUser);
netConfig.Set("ConsolePass", Cfg.ConsolePass);
c.ReadConfig(m_config);
}
RegisterInterface<CommandConsole>(m_console);
RegisterInterface<UserConfig>(Cfg);