Replace the console for all OpenSim apps with a new console featuring command
line editing, context sensitive help (press ? at any time), command line history, a new plugin command system and new appender features thet let you type while the console is scrolling. Seamlessly integrates the ICommander interfaces.0.6.3-post-fixes
parent
4d4402158e
commit
54c6a920ba
|
@ -26,22 +26,250 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Text;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Net;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.RegularExpressions;
|
using System.Diagnostics;
|
||||||
|
using System.Collections.Generic;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
|
||||||
namespace OpenSim.Framework.Console
|
namespace OpenSim.Framework.Console
|
||||||
{
|
{
|
||||||
|
public delegate void CommandDelegate(string module, string[] cmd);
|
||||||
|
|
||||||
|
public class Commands
|
||||||
|
{
|
||||||
|
private class CommandInfo
|
||||||
|
{
|
||||||
|
public string module;
|
||||||
|
public string help_text;
|
||||||
|
public string long_help;
|
||||||
|
public CommandDelegate fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, Object> tree =
|
||||||
|
new Dictionary<string, Object>();
|
||||||
|
|
||||||
|
public List<string> GetHelp()
|
||||||
|
{
|
||||||
|
List<string> help = new List<string>();
|
||||||
|
|
||||||
|
help.AddRange(CollectHelp(tree));
|
||||||
|
|
||||||
|
help.Sort();
|
||||||
|
|
||||||
|
return help;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string> CollectHelp(Dictionary<string, Object> dict)
|
||||||
|
{
|
||||||
|
List<string> result = new List<string>();
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, object> kvp in dict)
|
||||||
|
{
|
||||||
|
if (kvp.Value is Dictionary<string, Object>)
|
||||||
|
{
|
||||||
|
result.AddRange(CollectHelp((Dictionary<string, Object>)kvp.Value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (((CommandInfo)kvp.Value).long_help != String.Empty)
|
||||||
|
result.Add(((CommandInfo)kvp.Value).help_text+" - "+
|
||||||
|
((CommandInfo)kvp.Value).long_help);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddCommand(string module, string command, string help, string longhelp, CommandDelegate fn)
|
||||||
|
{
|
||||||
|
string[] parts = Parser.Parse(command);
|
||||||
|
|
||||||
|
Dictionary<string, Object> current = tree;
|
||||||
|
foreach (string s in parts)
|
||||||
|
{
|
||||||
|
if (current.ContainsKey(s))
|
||||||
|
{
|
||||||
|
if (current[s] is Dictionary<string, Object>)
|
||||||
|
{
|
||||||
|
current = (Dictionary<string, Object>)current[s];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
current[s] = new Dictionary<string, Object>();
|
||||||
|
current = (Dictionary<string, Object>)current[s];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current.ContainsKey(String.Empty))
|
||||||
|
return;
|
||||||
|
CommandInfo info = new CommandInfo();
|
||||||
|
info.module = module;
|
||||||
|
info.help_text = help;
|
||||||
|
info.long_help = longhelp;
|
||||||
|
info.fn = fn;
|
||||||
|
current[String.Empty] = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string[] FindNextOption(string[] cmd, bool term)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> current = tree;
|
||||||
|
|
||||||
|
int remaining = cmd.Length;
|
||||||
|
|
||||||
|
foreach (string s in cmd)
|
||||||
|
{
|
||||||
|
remaining--;
|
||||||
|
|
||||||
|
List<string> found = new List<string>();
|
||||||
|
|
||||||
|
foreach (string opt in current.Keys)
|
||||||
|
{
|
||||||
|
if (opt.StartsWith(s))
|
||||||
|
{
|
||||||
|
found.Add(opt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found.Count == 1 && (remaining != 0 || term))
|
||||||
|
{
|
||||||
|
current = (Dictionary<string, object>)current[found[0]];
|
||||||
|
}
|
||||||
|
else if (found.Count > 0)
|
||||||
|
{
|
||||||
|
return found.ToArray();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
// return new string[] {"<cr>"};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current.Count > 1)
|
||||||
|
{
|
||||||
|
List<string> choices = new List<string>();
|
||||||
|
|
||||||
|
bool addcr = false;
|
||||||
|
foreach (string s in current.Keys)
|
||||||
|
{
|
||||||
|
if (s == String.Empty)
|
||||||
|
{
|
||||||
|
CommandInfo ci = (CommandInfo)current[String.Empty];
|
||||||
|
if (ci.fn != null)
|
||||||
|
addcr = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
choices.Add(s);
|
||||||
|
}
|
||||||
|
if (addcr)
|
||||||
|
choices.Add("<cr>");
|
||||||
|
return choices.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current.ContainsKey(String.Empty))
|
||||||
|
return new string[] { "Command help: "+((CommandInfo)current[String.Empty]).help_text};
|
||||||
|
|
||||||
|
return new string[] { new List<string>(current.Keys)[0] };
|
||||||
|
}
|
||||||
|
|
||||||
|
public string[] Resolve(string[] cmd)
|
||||||
|
{
|
||||||
|
string[] result = cmd;
|
||||||
|
int index = -1;
|
||||||
|
|
||||||
|
Dictionary<string, object> current = tree;
|
||||||
|
|
||||||
|
foreach (string s in cmd)
|
||||||
|
{
|
||||||
|
index++;
|
||||||
|
|
||||||
|
List<string> found = new List<string>();
|
||||||
|
|
||||||
|
foreach (string opt in current.Keys)
|
||||||
|
{
|
||||||
|
if (opt.StartsWith(s))
|
||||||
|
{
|
||||||
|
found.Add(opt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found.Count == 1)
|
||||||
|
{
|
||||||
|
result[index] = found[0];
|
||||||
|
current = (Dictionary<string, object>)current[found[0]];
|
||||||
|
}
|
||||||
|
else if (found.Count > 0)
|
||||||
|
{
|
||||||
|
return new string[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current.ContainsKey(String.Empty))
|
||||||
|
{
|
||||||
|
CommandInfo ci = (CommandInfo)current[String.Empty];
|
||||||
|
if (ci.fn == null)
|
||||||
|
return new string[0];
|
||||||
|
ci.fn(ci.module, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return new string[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Parser
|
||||||
|
{
|
||||||
|
public static string[] Parse(string text)
|
||||||
|
{
|
||||||
|
List<string> result = new List<string>();
|
||||||
|
|
||||||
|
int index;
|
||||||
|
|
||||||
|
string[] unquoted = text.Split(new char[] {'"'});
|
||||||
|
|
||||||
|
for (index = 0 ; index < unquoted.Length ; index++)
|
||||||
|
{
|
||||||
|
if (index % 2 == 0)
|
||||||
|
{
|
||||||
|
string[] words = unquoted[index].Split(new char[] {' '});
|
||||||
|
foreach (string w in words)
|
||||||
|
{
|
||||||
|
if (w != String.Empty)
|
||||||
|
result.Add(w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.Add(unquoted[index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class ConsoleBase
|
public class ConsoleBase
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private readonly object m_syncRoot = new object();
|
private readonly object m_syncRoot = new object();
|
||||||
|
|
||||||
public conscmd_callback m_cmdParser;
|
private int y = -1;
|
||||||
|
private int cp = 0;
|
||||||
|
private int h = 1;
|
||||||
|
private string prompt = "# ";
|
||||||
|
private StringBuilder cmdline = new StringBuilder();
|
||||||
|
public Commands Commands = new Commands();
|
||||||
|
private bool echo = true;
|
||||||
|
private List<string> history = new List<string>();
|
||||||
|
|
||||||
|
public object ConsoleScene = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The default prompt text.
|
/// The default prompt text.
|
||||||
|
@ -53,15 +281,19 @@ namespace OpenSim.Framework.Console
|
||||||
}
|
}
|
||||||
protected string m_defaultPrompt;
|
protected string m_defaultPrompt;
|
||||||
|
|
||||||
/// <summary>
|
public ConsoleBase(string defaultPrompt)
|
||||||
/// Constructor.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="defaultPrompt"></param>
|
|
||||||
/// <param name="cmdparser"></param>
|
|
||||||
public ConsoleBase(string defaultPrompt, conscmd_callback cmdparser)
|
|
||||||
{
|
{
|
||||||
DefaultPrompt = defaultPrompt;
|
DefaultPrompt = defaultPrompt;
|
||||||
m_cmdParser = cmdparser;
|
|
||||||
|
Commands.AddCommand("console", "help", "help", "Get command list", Help);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddToHistory(string text)
|
||||||
|
{
|
||||||
|
while (history.Count >= 100)
|
||||||
|
history.RemoveAt(0);
|
||||||
|
|
||||||
|
history.Add(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -95,8 +327,7 @@ namespace OpenSim.Framework.Console
|
||||||
/// <param name="args">WriteLine-style message arguments</param>
|
/// <param name="args">WriteLine-style message arguments</param>
|
||||||
public void Warn(string sender, string format, params object[] args)
|
public void Warn(string sender, string format, params object[] args)
|
||||||
{
|
{
|
||||||
WritePrefixLine(DeriveColor(sender), sender);
|
WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Yellow, format, args);
|
||||||
WriteNewLine(ConsoleColor.Yellow, format, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -117,10 +348,8 @@ namespace OpenSim.Framework.Console
|
||||||
/// <param name="args">WriteLine-style message arguments</param>
|
/// <param name="args">WriteLine-style message arguments</param>
|
||||||
public void Notice(string sender, string format, params object[] args)
|
public void Notice(string sender, string format, params object[] args)
|
||||||
{
|
{
|
||||||
WritePrefixLine(DeriveColor(sender), sender);
|
WriteNewLine(DeriveColor(sender), sender, ConsoleColor.White, format, args);
|
||||||
WriteNewLine(ConsoleColor.White, format, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends an error to the current console output
|
/// Sends an error to the current console output
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -139,8 +368,7 @@ namespace OpenSim.Framework.Console
|
||||||
/// <param name="args">WriteLine-style message arguments</param>
|
/// <param name="args">WriteLine-style message arguments</param>
|
||||||
public void Error(string sender, string format, params object[] args)
|
public void Error(string sender, string format, params object[] args)
|
||||||
{
|
{
|
||||||
WritePrefixLine(DeriveColor(sender), sender);
|
WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Red, format, args);
|
||||||
Error(format, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -161,8 +389,7 @@ namespace OpenSim.Framework.Console
|
||||||
/// <param name="args">WriteLine-style message arguments</param>
|
/// <param name="args">WriteLine-style message arguments</param>
|
||||||
public void Status(string sender, string format, params object[] args)
|
public void Status(string sender, string format, params object[] args)
|
||||||
{
|
{
|
||||||
WritePrefixLine(DeriveColor(sender), sender);
|
WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Blue, format, args);
|
||||||
WriteNewLine(ConsoleColor.Blue, format, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Conditional("DEBUG")]
|
[Conditional("DEBUG")]
|
||||||
|
@ -174,11 +401,59 @@ namespace OpenSim.Framework.Console
|
||||||
[Conditional("DEBUG")]
|
[Conditional("DEBUG")]
|
||||||
public void Debug(string sender, string format, params object[] args)
|
public void Debug(string sender, string format, params object[] args)
|
||||||
{
|
{
|
||||||
WritePrefixLine(DeriveColor(sender), sender);
|
WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Gray, format, args);
|
||||||
WriteNewLine(ConsoleColor.Gray, format, args);
|
}
|
||||||
|
|
||||||
|
private void WriteNewLine(ConsoleColor senderColor, string sender, ConsoleColor color, string format, params object[] args)
|
||||||
|
{
|
||||||
|
lock (cmdline)
|
||||||
|
{
|
||||||
|
if (y != -1)
|
||||||
|
{
|
||||||
|
System.Console.CursorTop = y;
|
||||||
|
System.Console.CursorLeft = 0;
|
||||||
|
|
||||||
|
int count = cmdline.Length;
|
||||||
|
|
||||||
|
System.Console.Write(" ");
|
||||||
|
while (count-- > 0)
|
||||||
|
System.Console.Write(" ");
|
||||||
|
|
||||||
|
System.Console.CursorTop = y;
|
||||||
|
System.Console.CursorLeft = 0;
|
||||||
|
}
|
||||||
|
WritePrefixLine(senderColor, sender);
|
||||||
|
WriteConsoleLine(color, format, args);
|
||||||
|
if (y != -1)
|
||||||
|
y = System.Console.CursorTop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WriteNewLine(ConsoleColor color, string format, params object[] args)
|
private void WriteNewLine(ConsoleColor color, string format, params object[] args)
|
||||||
|
{
|
||||||
|
lock (cmdline)
|
||||||
|
{
|
||||||
|
if (y != -1)
|
||||||
|
{
|
||||||
|
System.Console.CursorTop = y;
|
||||||
|
System.Console.CursorLeft = 0;
|
||||||
|
|
||||||
|
int count = cmdline.Length;
|
||||||
|
|
||||||
|
System.Console.Write(" ");
|
||||||
|
while (count-- > 0)
|
||||||
|
System.Console.Write(" ");
|
||||||
|
|
||||||
|
System.Console.CursorTop = y;
|
||||||
|
System.Console.CursorLeft = 0;
|
||||||
|
}
|
||||||
|
WriteConsoleLine(color, format, args);
|
||||||
|
if (y != -1)
|
||||||
|
y = System.Console.CursorTop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WriteConsoleLine(ConsoleColor color, string format, params object[] args)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -240,106 +515,148 @@ namespace OpenSim.Framework.Console
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ReadLine()
|
private void Help(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
|
List<string> help = Commands.GetHelp();
|
||||||
|
|
||||||
|
foreach (string s in help)
|
||||||
|
Output(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Show()
|
||||||
|
{
|
||||||
|
lock (cmdline)
|
||||||
|
{
|
||||||
|
if (y == -1 || System.Console.BufferWidth == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int xc = prompt.Length + cp;
|
||||||
|
int new_x = xc % System.Console.BufferWidth;
|
||||||
|
int new_y = y + xc / System.Console.BufferWidth;
|
||||||
|
int end_y = y + (cmdline.Length + prompt.Length) / System.Console.BufferWidth;
|
||||||
|
if (end_y / System.Console.BufferWidth >= h)
|
||||||
|
h++;
|
||||||
|
if (end_y >= System.Console.BufferHeight) // wrap
|
||||||
|
{
|
||||||
|
y--;
|
||||||
|
new_y--;
|
||||||
|
System.Console.CursorLeft = 0;
|
||||||
|
System.Console.CursorTop = System.Console.BufferHeight-1;
|
||||||
|
System.Console.WriteLine(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
System.Console.CursorTop = y;
|
||||||
|
System.Console.CursorLeft = 0;
|
||||||
|
|
||||||
|
if (echo)
|
||||||
|
System.Console.Write("{0}{1}", prompt, cmdline);
|
||||||
|
else
|
||||||
|
System.Console.Write("{0}", prompt);
|
||||||
|
|
||||||
|
System.Console.CursorLeft = new_x;
|
||||||
|
System.Console.CursorTop = new_y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LockOutput()
|
||||||
|
{
|
||||||
|
System.Threading.Monitor.Enter(cmdline);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string line = System.Console.ReadLine();
|
if (y != -1)
|
||||||
|
|
||||||
while (line == null)
|
|
||||||
{
|
{
|
||||||
line = System.Console.ReadLine();
|
System.Console.CursorTop = y;
|
||||||
}
|
System.Console.CursorLeft = 0;
|
||||||
|
|
||||||
|
int count = cmdline.Length + prompt.Length;
|
||||||
|
|
||||||
|
while (count-- > 0)
|
||||||
|
System.Console.Write(" ");
|
||||||
|
|
||||||
|
System.Console.CursorTop = y;
|
||||||
|
System.Console.CursorLeft = 0;
|
||||||
|
|
||||||
return line;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
}
|
||||||
|
catch (Exception)
|
||||||
{
|
{
|
||||||
m_log.Error("[Console]: System.Console.ReadLine exception " + e.ToString());
|
|
||||||
return String.Empty;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Read()
|
public void UnlockOutput()
|
||||||
{
|
{
|
||||||
return System.Console.Read();
|
if (y != -1)
|
||||||
|
{
|
||||||
|
y = System.Console.CursorTop;
|
||||||
|
Show();
|
||||||
|
}
|
||||||
|
System.Threading.Monitor.Exit(cmdline);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPAddress CmdPromptIPAddress(string prompt, string defaultvalue)
|
public void Output(string text)
|
||||||
{
|
{
|
||||||
IPAddress address;
|
lock (cmdline)
|
||||||
string addressStr;
|
{
|
||||||
|
if (y == -1)
|
||||||
|
{
|
||||||
|
System.Console.WriteLine(text);
|
||||||
|
|
||||||
while (true)
|
return;
|
||||||
{
|
|
||||||
addressStr = CmdPrompt(prompt, defaultvalue);
|
|
||||||
if (IPAddress.TryParse(addressStr, out address))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.Console.CursorTop = y;
|
||||||
|
System.Console.CursorLeft = 0;
|
||||||
|
|
||||||
|
int count = cmdline.Length + prompt.Length;
|
||||||
|
|
||||||
|
while (count-- > 0)
|
||||||
|
System.Console.Write(" ");
|
||||||
|
|
||||||
|
System.Console.CursorTop = y;
|
||||||
|
System.Console.CursorLeft = 0;
|
||||||
|
|
||||||
|
System.Console.WriteLine(text);
|
||||||
|
|
||||||
|
y = System.Console.CursorTop;
|
||||||
|
|
||||||
|
Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ContextHelp()
|
||||||
|
{
|
||||||
|
string[] words = Parser.Parse(cmdline.ToString());
|
||||||
|
|
||||||
|
string[] opts = Commands.FindNextOption(words, cmdline.ToString().EndsWith(" "));
|
||||||
|
|
||||||
|
if (opts[0].StartsWith("Command help:"))
|
||||||
|
Output(opts[0]);
|
||||||
else
|
else
|
||||||
|
Output(String.Format("Options: {0}", String.Join(" ", opts)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Prompt()
|
||||||
{
|
{
|
||||||
m_log.Error("Illegal address. Please re-enter.");
|
string line = ReadLine(m_defaultPrompt, true, true);
|
||||||
|
|
||||||
|
if (line != String.Empty)
|
||||||
|
{
|
||||||
|
m_log.Info("Invalid command");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return address;
|
public string CmdPrompt(string p)
|
||||||
|
{
|
||||||
|
return ReadLine(String.Format("{0}: ", p), false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint CmdPromptIPPort(string prompt, string defaultvalue)
|
public string CmdPrompt(string p, string def)
|
||||||
{
|
{
|
||||||
uint port;
|
string ret = ReadLine(String.Format("{0} [{1}]: ", p, def), false, true);
|
||||||
string portStr;
|
if (ret == String.Empty)
|
||||||
|
ret = def;
|
||||||
|
|
||||||
while (true)
|
return ret;
|
||||||
{
|
|
||||||
portStr = CmdPrompt(prompt, defaultvalue);
|
|
||||||
if (uint.TryParse(portStr, out port))
|
|
||||||
{
|
|
||||||
if (port >= IPEndPoint.MinPort && port <= IPEndPoint.MaxPort)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_log.Error("Illegal address. Please re-enter.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Displays a prompt and waits for the user to enter a string, then returns that string
|
|
||||||
// (Done with no echo and suitable for passwords - currently disabled)
|
|
||||||
public string PasswdPrompt(string prompt)
|
|
||||||
{
|
|
||||||
// FIXME: Needs to be better abstracted
|
|
||||||
System.Console.WriteLine(String.Format("{0}: ", prompt));
|
|
||||||
//ConsoleColor oldfg = System.Console.ForegroundColor;
|
|
||||||
//System.Console.ForegroundColor = System.Console.BackgroundColor;
|
|
||||||
string temp = System.Console.ReadLine();
|
|
||||||
//System.Console.ForegroundColor = oldfg;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Displays a command prompt and waits for the user to enter a string, then returns that string
|
|
||||||
public string CmdPrompt(string prompt)
|
|
||||||
{
|
|
||||||
System.Console.WriteLine(String.Format("{0}: ", prompt));
|
|
||||||
return ReadLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Displays a command prompt and returns a default value if the user simply presses enter
|
|
||||||
public string CmdPrompt(string prompt, string defaultresponse)
|
|
||||||
{
|
|
||||||
string temp = CmdPrompt(String.Format("{0} [{1}]", prompt, defaultresponse));
|
|
||||||
if (temp == String.Empty)
|
|
||||||
{
|
|
||||||
return defaultresponse;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Displays a command prompt and returns a default value, user may only enter 1 of 2 options
|
// Displays a command prompt and returns a default value, user may only enter 1 of 2 options
|
||||||
|
@ -362,85 +679,137 @@ namespace OpenSim.Framework.Console
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Runs a command with a number of parameters
|
// Displays a prompt and waits for the user to enter a string, then returns that string
|
||||||
public Object RunCmd(string Cmd, string[] cmdparams)
|
// (Done with no echo and suitable for passwords)
|
||||||
|
public string PasswdPrompt(string p)
|
||||||
{
|
{
|
||||||
m_cmdParser.RunCmd(Cmd, cmdparams);
|
return ReadLine(p, false, false);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shows data about something
|
public void RunCommand(string cmd)
|
||||||
public void ShowCommands(string ShowWhat)
|
|
||||||
{
|
{
|
||||||
m_cmdParser.Show(new string[] { ShowWhat });
|
string[] parts = Parser.Parse(cmd);
|
||||||
|
Commands.Resolve(parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Prompt()
|
public string ReadLine(string p, bool isCommand, bool e)
|
||||||
{
|
{
|
||||||
string tempstr = CmdPrompt(m_defaultPrompt);
|
h = 1;
|
||||||
RunCommand(tempstr);
|
cp = 0;
|
||||||
}
|
prompt = p;
|
||||||
|
echo = e;
|
||||||
|
int historyLine = history.Count;
|
||||||
|
|
||||||
public void RunCommand(string cmdline)
|
System.Console.CursorLeft = 0; // Needed for mono
|
||||||
|
System.Console.Write(" "); // Needed for mono
|
||||||
|
|
||||||
|
y = System.Console.CursorTop;
|
||||||
|
cmdline = new StringBuilder();
|
||||||
|
|
||||||
|
while(true)
|
||||||
{
|
{
|
||||||
Regex Extractor = new Regex(@"(['""][^""]+['""])\s*|([^\s]+)\s*", RegexOptions.Compiled);
|
Show();
|
||||||
char[] delims = {' ', '"'};
|
|
||||||
MatchCollection matches = Extractor.Matches(cmdline);
|
|
||||||
// Get matches
|
|
||||||
|
|
||||||
if (matches.Count == 0)
|
ConsoleKeyInfo key = System.Console.ReadKey(true);
|
||||||
return;
|
char c = key.KeyChar;
|
||||||
|
|
||||||
string cmd = matches[0].Value.Trim(delims);
|
if (!Char.IsControl(c))
|
||||||
string[] cmdparams = new string[matches.Count - 1];
|
|
||||||
|
|
||||||
for (int i = 1; i < matches.Count; i++)
|
|
||||||
{
|
{
|
||||||
cmdparams[i-1] = matches[i].Value.Trim(delims);
|
if (cp >= 318)
|
||||||
}
|
continue;
|
||||||
|
|
||||||
try
|
if (c == '?' && isCommand)
|
||||||
{
|
{
|
||||||
RunCmd(cmd, cmdparams);
|
ContextHelp();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
|
cmdline.Insert(cp, c);
|
||||||
|
cp++;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat("[Console]: Command [{0}] failed with exception {1}", cmdline, e.ToString());
|
switch (key.Key)
|
||||||
m_log.Error(e.StackTrace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string LineInfo
|
|
||||||
{
|
{
|
||||||
get
|
case ConsoleKey.Backspace:
|
||||||
|
if (cp == 0)
|
||||||
|
break;
|
||||||
|
cmdline.Remove(cp-1, 1);
|
||||||
|
cp--;
|
||||||
|
|
||||||
|
System.Console.CursorLeft = 0;
|
||||||
|
System.Console.CursorTop = y;
|
||||||
|
|
||||||
|
System.Console.Write("{0}{1} ", prompt, cmdline);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ConsoleKey.End:
|
||||||
|
cp = cmdline.Length;
|
||||||
|
break;
|
||||||
|
case ConsoleKey.Home:
|
||||||
|
cp = 0;
|
||||||
|
break;
|
||||||
|
case ConsoleKey.UpArrow:
|
||||||
|
if (historyLine < 1)
|
||||||
|
break;
|
||||||
|
historyLine--;
|
||||||
|
LockOutput();
|
||||||
|
cmdline = new StringBuilder(history[historyLine]);
|
||||||
|
cp = cmdline.Length;
|
||||||
|
UnlockOutput();
|
||||||
|
break;
|
||||||
|
case ConsoleKey.DownArrow:
|
||||||
|
if (historyLine >= history.Count)
|
||||||
|
break;
|
||||||
|
historyLine++;
|
||||||
|
LockOutput();
|
||||||
|
if (historyLine == history.Count)
|
||||||
|
cmdline = new StringBuilder();
|
||||||
|
else
|
||||||
|
cmdline = new StringBuilder(history[historyLine]);
|
||||||
|
cp = cmdline.Length;
|
||||||
|
UnlockOutput();
|
||||||
|
break;
|
||||||
|
case ConsoleKey.LeftArrow:
|
||||||
|
if (cp > 0)
|
||||||
|
cp--;
|
||||||
|
break;
|
||||||
|
case ConsoleKey.RightArrow:
|
||||||
|
if (cp < cmdline.Length)
|
||||||
|
cp++;
|
||||||
|
break;
|
||||||
|
case ConsoleKey.Enter:
|
||||||
|
System.Console.CursorLeft = 0;
|
||||||
|
System.Console.CursorTop = y;
|
||||||
|
|
||||||
|
System.Console.WriteLine("{0}{1}", prompt, cmdline);
|
||||||
|
|
||||||
|
y = -1;
|
||||||
|
|
||||||
|
if (isCommand)
|
||||||
{
|
{
|
||||||
string result = String.Empty;
|
string[] cmd = Commands.Resolve(Parser.Parse(cmdline.ToString()));
|
||||||
|
|
||||||
string stacktrace = Environment.StackTrace;
|
if (cmd.Length != 0)
|
||||||
List<string> lines = new List<string>(stacktrace.Split(new string[] {"at "}, StringSplitOptions.None));
|
|
||||||
|
|
||||||
if (lines.Count > 4)
|
|
||||||
{
|
{
|
||||||
lines.RemoveRange(0, 4);
|
int i;
|
||||||
|
|
||||||
string tmpLine = lines[0];
|
for (i=0 ; i < cmd.Length ; i++)
|
||||||
|
|
||||||
int inIndex = tmpLine.IndexOf(" in ");
|
|
||||||
|
|
||||||
if (inIndex > -1)
|
|
||||||
{
|
{
|
||||||
result = tmpLine.Substring(0, inIndex);
|
if (cmd[i].Contains(" "))
|
||||||
|
cmd[i] = "\"" + cmd[i] + "\"";
|
||||||
|
}
|
||||||
|
AddToHistory(String.Join(" ", cmd));
|
||||||
|
return String.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int lineIndex = tmpLine.IndexOf(":line ");
|
AddToHistory(cmdline.ToString());
|
||||||
|
return cmdline.ToString();
|
||||||
if (lineIndex > -1)
|
default:
|
||||||
{
|
break;
|
||||||
lineIndex += 6;
|
}
|
||||||
result += ", line " + tmpLine.Substring(lineIndex, (tmpLine.Length - lineIndex) - 5);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace OpenSim.Framework.Console
|
|
||||||
{
|
|
||||||
public interface conscmd_callback
|
|
||||||
{
|
|
||||||
void RunCmd(string cmd, string[] cmdparams);
|
|
||||||
void Show(string[] showParams);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -37,6 +37,14 @@ namespace OpenSim.Framework.Console
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class OpenSimAppender : AnsiColorTerminalAppender
|
public class OpenSimAppender : AnsiColorTerminalAppender
|
||||||
{
|
{
|
||||||
|
private ConsoleBase m_console = null;
|
||||||
|
|
||||||
|
public ConsoleBase Console
|
||||||
|
{
|
||||||
|
get { return m_console; }
|
||||||
|
set { m_console = value; }
|
||||||
|
}
|
||||||
|
|
||||||
private static readonly ConsoleColor[] Colors = {
|
private static readonly ConsoleColor[] Colors = {
|
||||||
// the dark colors don't seem to be visible on some black background terminals like putty :(
|
// the dark colors don't seem to be visible on some black background terminals like putty :(
|
||||||
//ConsoleColor.DarkBlue,
|
//ConsoleColor.DarkBlue,
|
||||||
|
@ -55,6 +63,9 @@ namespace OpenSim.Framework.Console
|
||||||
|
|
||||||
override protected void Append(LoggingEvent le)
|
override protected void Append(LoggingEvent le)
|
||||||
{
|
{
|
||||||
|
if (m_console != null)
|
||||||
|
m_console.LockOutput();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string loggingMessage = RenderLoggingEvent(le);
|
string loggingMessage = RenderLoggingEvent(le);
|
||||||
|
@ -96,6 +107,11 @@ namespace OpenSim.Framework.Console
|
||||||
{
|
{
|
||||||
System.Console.WriteLine("Couldn't write out log message: {0}", e.ToString());
|
System.Console.WriteLine("Couldn't write out log message: {0}", e.ToString());
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (m_console != null)
|
||||||
|
m_console.UnlockOutput();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WriteColorText(ConsoleColor color, string sender)
|
private void WriteColorText(ConsoleColor color, string sender)
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
using OpenSim.Framework.Console;
|
||||||
|
|
||||||
namespace OpenSim.Framework
|
namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
|
@ -88,5 +89,7 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
T RequestModuleInterface<T>();
|
T RequestModuleInterface<T>();
|
||||||
T[] RequestModuleInterfaces<T>();
|
T[] RequestModuleInterfaces<T>();
|
||||||
|
|
||||||
|
void AddCommand(string module, string command, string shorthelp, string longhelp, CommandDelegate callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,45 @@ namespace OpenSim.Framework.Servers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Must be overriden by child classes for their own server specific startup behaviour.
|
/// Must be overriden by child classes for their own server specific startup behaviour.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract void StartupSpecific();
|
protected virtual void StartupSpecific()
|
||||||
|
{
|
||||||
|
if (m_console != null)
|
||||||
|
{
|
||||||
|
SetConsoleLogLevel(new string[] { "ALL" });
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("base", "quit",
|
||||||
|
"quit",
|
||||||
|
"Quit the application", HandleQuit);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("base", "shutdown",
|
||||||
|
"shutdown",
|
||||||
|
"Quit the application", HandleQuit);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("base", "set log level",
|
||||||
|
"set log level <level>",
|
||||||
|
"Set the console logging level", HandleLogLevel);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("base", "show info",
|
||||||
|
"show info",
|
||||||
|
"Show general information", HandleShow);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("base", "show stats",
|
||||||
|
"show stats",
|
||||||
|
"Show statistics", HandleShow);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("base", "show threads",
|
||||||
|
"show threads",
|
||||||
|
"Show thread status", HandleShow);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("base", "show uptime",
|
||||||
|
"show uptime",
|
||||||
|
"Show server uptime", HandleShow);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("base", "show version",
|
||||||
|
"show version",
|
||||||
|
"Show server version", HandleShow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Should be overriden and referenced by descendents if they need to perform extra shutdown processing
|
/// Should be overriden and referenced by descendents if they need to perform extra shutdown processing
|
||||||
|
@ -212,6 +250,8 @@ namespace OpenSim.Framework.Servers
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
consoleAppender.Console = m_console;
|
||||||
|
|
||||||
if (setParams.Length > 0)
|
if (setParams.Length > 0)
|
||||||
{
|
{
|
||||||
Level consoleLevel = repository.LevelMap[setParams[0]];
|
Level consoleLevel = repository.LevelMap[setParams[0]];
|
||||||
|
@ -261,56 +301,18 @@ namespace OpenSim.Framework.Servers
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private void HandleQuit(string module, string[] args)
|
||||||
/// Runs commands issued by the server console from the operator
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="command">The first argument of the parameter (the command)</param>
|
|
||||||
/// <param name="cmdparams">Additional arguments passed to the command</param>
|
|
||||||
public virtual void RunCmd(string command, string[] cmdparams)
|
|
||||||
{
|
{
|
||||||
switch (command)
|
|
||||||
{
|
|
||||||
case "help":
|
|
||||||
ShowHelp(cmdparams);
|
|
||||||
Notice("");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "set":
|
|
||||||
Set(cmdparams);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "show":
|
|
||||||
if (cmdparams.Length > 0)
|
|
||||||
{
|
|
||||||
Show(cmdparams);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "quit":
|
|
||||||
case "shutdown":
|
|
||||||
Shutdown();
|
Shutdown();
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private void HandleLogLevel(string module, string[] cmd)
|
||||||
/// Set an OpenSim parameter
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="setArgs">
|
|
||||||
/// The arguments given to the set command.
|
|
||||||
/// </param>
|
|
||||||
public virtual void Set(string[] setArgs)
|
|
||||||
{
|
{
|
||||||
// Temporary while we only have one command which takes at least two parameters
|
if (cmd.Length > 3)
|
||||||
if (setArgs.Length < 2)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (setArgs[0] == "log" && setArgs[1] == "level")
|
|
||||||
{
|
{
|
||||||
string[] setParams = new string[setArgs.Length - 2];
|
string level = cmd[3];
|
||||||
Array.Copy(setArgs, 2, setParams, 0, setArgs.Length - 2);
|
|
||||||
|
|
||||||
SetConsoleLogLevel(setParams);
|
SetConsoleLogLevel(new string[] { level });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,18 +326,6 @@ namespace OpenSim.Framework.Servers
|
||||||
|
|
||||||
if (helpArgs.Length == 0)
|
if (helpArgs.Length == 0)
|
||||||
{
|
{
|
||||||
List<string> helpTopics = GetHelpTopics();
|
|
||||||
|
|
||||||
if (helpTopics.Count > 0)
|
|
||||||
{
|
|
||||||
Notice(
|
|
||||||
"As well as the help information below, you can also type help <topic> to get more information on the following areas:");
|
|
||||||
Notice(string.Format(" {0}", string.Join(", ", helpTopics.ToArray())));
|
|
||||||
Notice("");
|
|
||||||
}
|
|
||||||
|
|
||||||
Notice("quit - equivalent to shutdown.");
|
|
||||||
|
|
||||||
Notice("set log level [level] - change the console logging level only. For example, off or debug.");
|
Notice("set log level [level] - change the console logging level only. For example, off or debug.");
|
||||||
Notice("show info - show server information (e.g. startup path).");
|
Notice("show info - show server information (e.g. startup path).");
|
||||||
|
|
||||||
|
@ -345,21 +335,20 @@ namespace OpenSim.Framework.Servers
|
||||||
Notice("show threads - list tracked threads");
|
Notice("show threads - list tracked threads");
|
||||||
Notice("show uptime - show server startup time and uptime.");
|
Notice("show uptime - show server startup time and uptime.");
|
||||||
Notice("show version - show server version.");
|
Notice("show version - show server version.");
|
||||||
Notice("shutdown - shutdown the server.");
|
|
||||||
Notice("");
|
Notice("");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public virtual void HandleShow(string module, string[] cmd)
|
||||||
/// Outputs to the console information about the region
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="showParams">
|
|
||||||
/// What information to display (valid arguments are "uptime", "users", ...)
|
|
||||||
/// </param>
|
|
||||||
public virtual void Show(string[] showParams)
|
|
||||||
{
|
{
|
||||||
|
List<string> args = new List<string>(cmd);
|
||||||
|
|
||||||
|
args.RemoveAt(0);
|
||||||
|
|
||||||
|
string[] showParams = args.ToArray();
|
||||||
|
|
||||||
switch (showParams[0])
|
switch (showParams[0])
|
||||||
{
|
{
|
||||||
case "info":
|
case "info":
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace OpenSim.Grid.AssetServer
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An asset server
|
/// An asset server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class OpenAsset_Main : BaseOpenSimServer, conscmd_callback
|
public class OpenAsset_Main : BaseOpenSimServer
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ namespace OpenSim.Grid.AssetServer
|
||||||
|
|
||||||
public OpenAsset_Main()
|
public OpenAsset_Main()
|
||||||
{
|
{
|
||||||
m_console = new ConsoleBase("Asset", this);
|
m_console = new ConsoleBase("Asset");
|
||||||
|
|
||||||
MainConsole.Instance = m_console;
|
MainConsole.Instance = m_console;
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,8 @@ namespace OpenSim.Grid.AssetServer
|
||||||
AddHttpHandlers();
|
AddHttpHandlers();
|
||||||
|
|
||||||
m_httpServer.Start();
|
m_httpServer.Start();
|
||||||
|
|
||||||
|
base.StartupSpecific();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void AddHttpHandlers()
|
protected void AddHttpHandlers()
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace OpenSim.Grid.GridServer
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GridServerBase : BaseOpenSimServer, conscmd_callback
|
public class GridServerBase : BaseOpenSimServer
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
@ -59,34 +59,27 @@ namespace OpenSim.Grid.GridServer
|
||||||
|
|
||||||
public GridServerBase()
|
public GridServerBase()
|
||||||
{
|
{
|
||||||
m_console = new ConsoleBase("Grid", this);
|
m_console = new ConsoleBase("Grid");
|
||||||
MainConsole.Instance = m_console;
|
MainConsole.Instance = m_console;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void RunCmd(string cmd, string[] cmdparams)
|
private void HandleRegistration(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
base.RunCmd(cmd, cmdparams);
|
switch (cmd[0])
|
||||||
|
|
||||||
switch (cmd)
|
|
||||||
{
|
{
|
||||||
case "disable-reg":
|
case "enable":
|
||||||
m_config.AllowRegionRegistration = false;
|
|
||||||
m_log.Info("Region registration disabled");
|
|
||||||
break;
|
|
||||||
case "enable-reg":
|
|
||||||
m_config.AllowRegionRegistration = true;
|
m_config.AllowRegionRegistration = true;
|
||||||
m_log.Info("Region registration enabled");
|
m_log.Info("Region registration enabled");
|
||||||
break;
|
break;
|
||||||
|
case "disable":
|
||||||
|
m_config.AllowRegionRegistration = false;
|
||||||
|
m_log.Info("Region registration disabled");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Show(string[] showParams)
|
private void HandleShowStatus(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
base.Show(showParams);
|
|
||||||
|
|
||||||
switch (showParams[0])
|
|
||||||
{
|
|
||||||
case "status":
|
|
||||||
if (m_config.AllowRegionRegistration)
|
if (m_config.AllowRegionRegistration)
|
||||||
{
|
{
|
||||||
m_log.Info("Region registration enabled.");
|
m_log.Info("Region registration enabled.");
|
||||||
|
@ -95,8 +88,6 @@ namespace OpenSim.Grid.GridServer
|
||||||
{
|
{
|
||||||
m_log.Info("Region registration disabled.");
|
m_log.Info("Region registration disabled.");
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,6 +111,20 @@ namespace OpenSim.Grid.GridServer
|
||||||
// Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates.
|
// Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates.
|
||||||
// simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims);
|
// simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims);
|
||||||
// simCheckTimer.Enabled = true;
|
// simCheckTimer.Enabled = true;
|
||||||
|
|
||||||
|
base.StartupSpecific();
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("gridserver", "enable registration",
|
||||||
|
"enable registration",
|
||||||
|
"Enable new regions to register", HandleRegistration);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("gridserver", "disable registration",
|
||||||
|
"disable registration",
|
||||||
|
"Disable registering new regions", HandleRegistration);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("gridserver", "show status",
|
||||||
|
"show status",
|
||||||
|
"Show registration status", HandleShowStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void AddHttpHandlers()
|
protected void AddHttpHandlers()
|
||||||
|
|
|
@ -38,7 +38,7 @@ using OpenSim.Framework.Servers;
|
||||||
|
|
||||||
namespace OpenSim.Grid.InventoryServer
|
namespace OpenSim.Grid.InventoryServer
|
||||||
{
|
{
|
||||||
public class OpenInventory_Main : BaseOpenSimServer, conscmd_callback
|
public class OpenInventory_Main : BaseOpenSimServer
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ namespace OpenSim.Grid.InventoryServer
|
||||||
|
|
||||||
public OpenInventory_Main()
|
public OpenInventory_Main()
|
||||||
{
|
{
|
||||||
m_console = new ConsoleBase("Inventory", this);
|
m_console = new ConsoleBase("Inventory");
|
||||||
MainConsole.Instance = m_console;
|
MainConsole.Instance = m_console;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +77,12 @@ namespace OpenSim.Grid.InventoryServer
|
||||||
m_httpServer.Start();
|
m_httpServer.Start();
|
||||||
|
|
||||||
m_log.Info("[" + LogName + "]: Started HTTP server");
|
m_log.Info("[" + LogName + "]: Started HTTP server");
|
||||||
|
|
||||||
|
base.StartupSpecific();
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("inventoryserver", "add user",
|
||||||
|
"add user",
|
||||||
|
"Add a random user inventory", HandleAddUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void AddHttpHandlers()
|
protected void AddHttpHandlers()
|
||||||
|
@ -146,16 +152,9 @@ namespace OpenSim.Grid.InventoryServer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void RunCmd(string cmd, string[] cmdparams)
|
private void HandleAddUser(string module, string[] args)
|
||||||
{
|
{
|
||||||
base.RunCmd(cmd, cmdparams);
|
|
||||||
|
|
||||||
switch (cmd)
|
|
||||||
{
|
|
||||||
case "add-user":
|
|
||||||
m_inventoryService.CreateUsersInventory(UUID.Random().Guid);
|
m_inventoryService.CreateUsersInventory(UUID.Random().Guid);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace OpenSim.Grid.MessagingServer
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class OpenMessage_Main : BaseOpenSimServer, conscmd_callback
|
public class OpenMessage_Main : BaseOpenSimServer
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ namespace OpenSim.Grid.MessagingServer
|
||||||
|
|
||||||
public OpenMessage_Main()
|
public OpenMessage_Main()
|
||||||
{
|
{
|
||||||
m_console = new ConsoleBase("Messaging", this);
|
m_console = new ConsoleBase("Messaging");
|
||||||
MainConsole.Instance = m_console;
|
MainConsole.Instance = m_console;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +124,16 @@ namespace OpenSim.Grid.MessagingServer
|
||||||
registerWithUserServer();
|
registerWithUserServer();
|
||||||
|
|
||||||
m_log.Info("[SERVER]: Messageserver 0.5 - Startup complete");
|
m_log.Info("[SERVER]: Messageserver 0.5 - Startup complete");
|
||||||
|
|
||||||
|
base.StartupSpecific();
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("messageserver", "clear cache",
|
||||||
|
"clear cache",
|
||||||
|
"Clear presence cache", HandleClearCache);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("messageserver", "register",
|
||||||
|
"register",
|
||||||
|
"Re-register with user server(s)", HandleRegister);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void do_create(string what)
|
public void do_create(string what)
|
||||||
|
@ -154,29 +164,17 @@ namespace OpenSim.Grid.MessagingServer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void RunCmd(string cmd, string[] cmdparams)
|
private void HandleClearCache(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
base.RunCmd(cmd, cmdparams);
|
|
||||||
|
|
||||||
switch (cmd)
|
|
||||||
{
|
|
||||||
case "clear-cache":
|
|
||||||
int entries = msgsvc.ClearRegionCache();
|
int entries = msgsvc.ClearRegionCache();
|
||||||
m_console.Notice("Region cache cleared! Cleared " + entries.ToString() + " entries");
|
m_console.Notice("Region cache cleared! Cleared " +
|
||||||
break;
|
entries.ToString() + " entries");
|
||||||
case "register":
|
}
|
||||||
|
|
||||||
|
private void HandleRegister(string module, string[] cmd)
|
||||||
|
{
|
||||||
deregisterFromUserServer();
|
deregisterFromUserServer();
|
||||||
registerWithUserServer();
|
registerWithUserServer();
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void ShowHelp(string[] helpArgs)
|
|
||||||
{
|
|
||||||
base.ShowHelp(helpArgs);
|
|
||||||
|
|
||||||
m_console.Notice("clear-cache - Clears region cache. Should be done when regions change position. The region cache gets stale after a while.");
|
|
||||||
m_console.Notice("register - (Re-)registers with user-server. This might be necessary if the userserver crashed/restarted");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ShutdownSpecific()
|
public override void ShutdownSpecific()
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace OpenSim.Grid.UserServer
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Grid user server main class
|
/// Grid user server main class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class OpenUser_Main : BaseOpenSimServer, conscmd_callback
|
public class OpenUser_Main : BaseOpenSimServer
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ namespace OpenSim.Grid.UserServer
|
||||||
|
|
||||||
public OpenUser_Main()
|
public OpenUser_Main()
|
||||||
{
|
{
|
||||||
m_console = new ConsoleBase("User", this);
|
m_console = new ConsoleBase("User");
|
||||||
MainConsole.Instance = m_console;
|
MainConsole.Instance = m_console;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +119,37 @@ namespace OpenSim.Grid.UserServer
|
||||||
m_httpServer = new BaseHttpServer(Cfg.HttpPort);
|
m_httpServer = new BaseHttpServer(Cfg.HttpPort);
|
||||||
AddHttpHandlers();
|
AddHttpHandlers();
|
||||||
m_httpServer.Start();
|
m_httpServer.Start();
|
||||||
|
|
||||||
|
base.StartupSpecific();
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("userserver", "create user",
|
||||||
|
"create user [<first> [<last> [<x> <y> [email]]]]",
|
||||||
|
"Create a new user account", RunCommand);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("userserver", "reset user password",
|
||||||
|
"reset user password [<first> [<last> [<new password>]]]",
|
||||||
|
"Reset a user's password", RunCommand);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("userserver", "login level",
|
||||||
|
"login level <level>",
|
||||||
|
"Set the minimum user level to log in", HandleLoginCommand);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("userserver", "login reset",
|
||||||
|
"login reset",
|
||||||
|
"Reset the login level to allow all users",
|
||||||
|
HandleLoginCommand);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("userserver", "login text",
|
||||||
|
"login text <text>",
|
||||||
|
"Set the text users will see on login", HandleLoginCommand);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("userserver", "test-inventory",
|
||||||
|
"test-inventory",
|
||||||
|
"Perform a test inventory transaction", RunCommand);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("userserver", "logoff-user",
|
||||||
|
"logoff-user <first> <last> <message>",
|
||||||
|
"Log off a named user", RunCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -301,10 +332,45 @@ namespace OpenSim.Grid.UserServer
|
||||||
m_userManager.ResetUserPassword(firstName, lastName, newPassword);
|
m_userManager.ResetUserPassword(firstName, lastName, newPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void RunCmd(string cmd, string[] cmdparams)
|
private void HandleLoginCommand(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
base.RunCmd(cmd, cmdparams);
|
string subcommand = cmd[1];
|
||||||
switch (cmd)
|
|
||||||
|
switch (subcommand)
|
||||||
|
{
|
||||||
|
case "level":
|
||||||
|
// Set the minimal level to allow login
|
||||||
|
// Useful to allow grid update without worrying about users.
|
||||||
|
// or fixing critical issues
|
||||||
|
//
|
||||||
|
if (cmd.Length > 2)
|
||||||
|
{
|
||||||
|
int level = Convert.ToInt32(cmd[2]);
|
||||||
|
m_loginService.setloginlevel(level);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "reset":
|
||||||
|
m_loginService.setloginlevel(0);
|
||||||
|
break;
|
||||||
|
case "text":
|
||||||
|
if (cmd.Length > 2)
|
||||||
|
{
|
||||||
|
m_loginService.setwelcometext(cmd[2]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RunCommand(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
List<string> args = new List<string>(cmd);
|
||||||
|
string command = cmd[0];
|
||||||
|
|
||||||
|
args.RemoveAt(0);
|
||||||
|
|
||||||
|
string[] cmdparams = args.ToArray();
|
||||||
|
|
||||||
|
switch (command)
|
||||||
{
|
{
|
||||||
case "create":
|
case "create":
|
||||||
do_create(cmdparams);
|
do_create(cmdparams);
|
||||||
|
@ -315,26 +381,6 @@ namespace OpenSim.Grid.UserServer
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case "login-level":
|
|
||||||
// Set the minimal level to allow login
|
|
||||||
// Usefull to allow grid update without worrying about users.
|
|
||||||
// or fixing critical issue
|
|
||||||
if (cmdparams.Length == 1)
|
|
||||||
{
|
|
||||||
int level = Convert.ToInt32(cmdparams[0]);
|
|
||||||
m_loginService.setloginlevel(level);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "login-reset":
|
|
||||||
m_loginService.setloginlevel(0);
|
|
||||||
break;
|
|
||||||
case "login-text":
|
|
||||||
if (cmdparams.Length == 1)
|
|
||||||
{
|
|
||||||
m_loginService.setwelcometext(cmdparams[0]);
|
|
||||||
}
|
|
||||||
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;
|
||||||
|
|
|
@ -34,6 +34,7 @@ using log4net.Config;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
|
using OpenSim.Region.Framework.Scenes;
|
||||||
|
|
||||||
namespace OpenSim
|
namespace OpenSim
|
||||||
{
|
{
|
||||||
|
@ -46,6 +47,8 @@ namespace OpenSim
|
||||||
public static bool m_saveCrashDumps = false;
|
public static bool m_saveCrashDumps = false;
|
||||||
public static string m_crashDir = "crashes";
|
public static string m_crashDir = "crashes";
|
||||||
|
|
||||||
|
protected static OpenSimBase m_sim = null;
|
||||||
|
|
||||||
//could move our main function into OpenSimMain and kill this class
|
//could move our main function into OpenSimMain and kill this class
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
@ -93,18 +96,18 @@ namespace OpenSim
|
||||||
|
|
||||||
if (background)
|
if (background)
|
||||||
{
|
{
|
||||||
OpenSimBase sim = new OpenSimBackground(configSource);
|
m_sim = new OpenSimBackground(configSource);
|
||||||
sim.Startup();
|
m_sim.Startup();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OpenSimBase sim = null;
|
m_sim = null;
|
||||||
if (hgrid)
|
if (hgrid)
|
||||||
sim = new HGOpenSimNode(configSource);
|
m_sim = new HGOpenSimNode(configSource);
|
||||||
else
|
else
|
||||||
sim = new OpenSim(configSource);
|
m_sim = new OpenSim(configSource);
|
||||||
|
|
||||||
sim.Startup();
|
m_sim.Startup();
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,6 +77,9 @@ namespace OpenSim
|
||||||
m_log.Info("====================================================================");
|
m_log.Info("====================================================================");
|
||||||
|
|
||||||
base.StartupSpecific();
|
base.StartupSpecific();
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand("hypergrid", "link-mapping", "link-mapping [<x> <y>] <cr>", "Set local coordinate to map HG regions to", RunCommand);
|
||||||
|
MainConsole.Instance.Commands.AddCommand("hypergrid", "link-region", "link-region <Xloc> <Yloc> <HostName> <HttpPort> <LocalName> <cr>", "Link a hypergrid region", RunCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void InitialiseStandaloneServices(LibraryRootFolder libraryRootFolder)
|
protected override void InitialiseStandaloneServices(LibraryRootFolder libraryRootFolder)
|
||||||
|
@ -143,11 +146,18 @@ namespace OpenSim
|
||||||
m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
|
m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void RunCmd(string command, string[] cmdparams)
|
public void RunCommand(string module, string[] cp)
|
||||||
{
|
{
|
||||||
|
List<string> cmdparams = new List<string>(cp);
|
||||||
|
if (cmdparams.Count < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
string command = cmdparams[0];
|
||||||
|
cmdparams.RemoveAt(0);
|
||||||
|
|
||||||
if (command.Equals("link-mapping"))
|
if (command.Equals("link-mapping"))
|
||||||
{
|
{
|
||||||
if (cmdparams.Length == 2)
|
if (cmdparams.Count == 2)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -166,11 +176,11 @@ namespace OpenSim
|
||||||
else if (command.Equals("link-region"))
|
else if (command.Equals("link-region"))
|
||||||
{
|
{
|
||||||
// link-region <Xloc> <Yloc> <HostName> <HttpPort> <LocalName>
|
// link-region <Xloc> <Yloc> <HostName> <HttpPort> <LocalName>
|
||||||
if (cmdparams.Length < 4)
|
if (cmdparams.Count < 4)
|
||||||
{
|
{
|
||||||
if ((cmdparams.Length == 1) || (cmdparams.Length ==2))
|
if ((cmdparams.Count == 1) || (cmdparams.Count ==2))
|
||||||
{
|
{
|
||||||
LoadXmlLinkFile(cmdparams);
|
LoadXmlLinkFile(cmdparams.ToArray());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -201,19 +211,16 @@ namespace OpenSim
|
||||||
|
|
||||||
if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo))
|
if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo))
|
||||||
{
|
{
|
||||||
if (cmdparams.Length >= 5)
|
if (cmdparams.Count >= 5)
|
||||||
{
|
{
|
||||||
regInfo.RegionName = "";
|
regInfo.RegionName = "";
|
||||||
for (int i = 4; i < cmdparams.Length; i++)
|
for (int i = 4; i < cmdparams.Count; i++)
|
||||||
regInfo.RegionName += cmdparams[i] + " ";
|
regInfo.RegionName += cmdparams[i] + " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.RunCmd(command, cmdparams);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadXmlLinkFile(string[] cmdparams)
|
private void LoadXmlLinkFile(string[] cmdparams)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -198,6 +198,46 @@ namespace OpenSim
|
||||||
|
|
||||||
// Only enable logins to the regions once we have completely finished starting up (apart from scripts)
|
// Only enable logins to the regions once we have completely finished starting up (apart from scripts)
|
||||||
m_commsManager.GridService.RegionLoginsEnabled = true;
|
m_commsManager.GridService.RegionLoginsEnabled = true;
|
||||||
|
|
||||||
|
List<string> topics = GetHelpTopics();
|
||||||
|
|
||||||
|
foreach (string topic in topics)
|
||||||
|
{
|
||||||
|
m_console.Commands.AddCommand("plugin", "help "+topic,
|
||||||
|
"help "+topic,
|
||||||
|
"Get help on plugin command '"+topic+"'",
|
||||||
|
HandleCommanderHelp);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("plugin", topic,
|
||||||
|
topic,
|
||||||
|
"Execute subcommand for plugin '"+topic+"'",
|
||||||
|
null);
|
||||||
|
|
||||||
|
ICommander commander =
|
||||||
|
SceneManager.CurrentOrFirstScene.GetCommanders()[topic];
|
||||||
|
|
||||||
|
if (commander == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach (string command in commander.Commands.Keys)
|
||||||
|
{
|
||||||
|
m_console.Commands.AddCommand(topic, topic+" "+command,
|
||||||
|
topic+" "+commander.Commands[command].ShortHelp(),
|
||||||
|
String.Empty, HandleCommanderCommand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleCommanderCommand(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
m_sceneManager.SendCommandToPluginModules(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleCommanderHelp(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
ICommander moduleCommander = SceneManager.CurrentOrFirstScene.GetCommander(cmd[1]);
|
||||||
|
if (moduleCommander != null)
|
||||||
|
m_console.Notice(moduleCommander.Help);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -108,6 +108,8 @@ namespace OpenSim.Region.ClientStack
|
||||||
|
|
||||||
m_log.Info("[REGION]: Starting HTTP server");
|
m_log.Info("[REGION]: Starting HTTP server");
|
||||||
m_httpServer.Start();
|
m_httpServer.Start();
|
||||||
|
|
||||||
|
base.StartupSpecific();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -88,6 +88,18 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string ShortHelp()
|
||||||
|
{
|
||||||
|
string help = m_name;
|
||||||
|
|
||||||
|
foreach (CommandArgument arg in m_args)
|
||||||
|
{
|
||||||
|
help += " <" + arg.Name + ">";
|
||||||
|
}
|
||||||
|
|
||||||
|
return help;
|
||||||
|
}
|
||||||
|
|
||||||
public void ShowConsoleHelp()
|
public void ShowConsoleHelp()
|
||||||
{
|
{
|
||||||
Console.WriteLine("== " + Name + " ==");
|
Console.WriteLine("== " + Name + " ==");
|
||||||
|
|
|
@ -32,21 +32,20 @@ using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
using OpenSim;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
using OpenSim.Region.Environment.Modules.Framework;
|
using OpenSim.Region.Environment.Modules.Framework;
|
||||||
using OpenSim.Region.Environment.Modules.Framework.InterfaceCommander;
|
|
||||||
using OpenSim.Framework.Communications.Cache;
|
using OpenSim.Framework.Communications.Cache;
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment.Modules.World.Permissions
|
namespace OpenSim.Region.Environment.Modules.World.Permissions
|
||||||
{
|
{
|
||||||
public class PermissionsModule : IRegionModule, ICommandableModule
|
public class PermissionsModule : IRegionModule
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
protected Scene m_scene;
|
protected Scene m_scene;
|
||||||
private readonly Commander m_commander = new Commander("permissions");
|
|
||||||
|
|
||||||
#region Constants
|
#region Constants
|
||||||
// These are here for testing. They will be taken out
|
// These are here for testing. They will be taken out
|
||||||
|
@ -94,60 +93,6 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ICommandableModule Members
|
|
||||||
|
|
||||||
public ICommander CommandInterface
|
|
||||||
{
|
|
||||||
get { throw new System.NotImplementedException(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InterfaceDebugPermissions(Object[] args)
|
|
||||||
{
|
|
||||||
if ((bool)args[0] == true)
|
|
||||||
{
|
|
||||||
m_debugPermissions = true;
|
|
||||||
m_log.Info("[PERMISSIONS]: Permissions Debugging Enabled.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_debugPermissions = false;
|
|
||||||
m_log.Info("[PERMISSIONS]: Permissions Debugging Disabled.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InterfaceBypassPermissions(Object[] args)
|
|
||||||
{
|
|
||||||
if ((bool)args[0] == true)
|
|
||||||
{
|
|
||||||
m_log.Info("[PERMISSIONS]: Permissions Bypass Enabled.");
|
|
||||||
m_bypassPermissionsValue = (bool)args[1];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_bypassPermissions = false;
|
|
||||||
m_log.Info("[PERMISSIONS]: Permissions Bypass Disabled. Normal Operation.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Processes commandline input. Do not call directly.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="args">Commandline arguments</param>
|
|
||||||
private void EventManager_OnPluginConsole(string[] args)
|
|
||||||
{
|
|
||||||
if (args[0] == "permissions")
|
|
||||||
{
|
|
||||||
string[] tmpArgs = new string[args.Length - 2];
|
|
||||||
int i;
|
|
||||||
for (i = 2; i < args.Length; i++)
|
|
||||||
tmpArgs[i - 2] = args[i];
|
|
||||||
|
|
||||||
m_commander.ProcessConsoleCommand(args[1], tmpArgs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region IRegionModule Members
|
#region IRegionModule Members
|
||||||
|
|
||||||
public void Initialise(Scene scene, IConfigSource config)
|
public void Initialise(Scene scene, IConfigSource config)
|
||||||
|
@ -226,20 +171,89 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
|
||||||
|
|
||||||
m_scene.Permissions.AddCanTeleportHandler(CanTeleport); //NOT YET IMPLEMENTED
|
m_scene.Permissions.AddCanTeleportHandler(CanTeleport); //NOT YET IMPLEMENTED
|
||||||
|
|
||||||
//Register Debug Commands
|
m_scene.AddCommand("permissions", "bypass permissions",
|
||||||
Command bypassCommand = new Command("bypass", CommandIntentions.COMMAND_HAZARDOUS, InterfaceBypassPermissions, "Force the permissions a specific way to test permissions");
|
"bypass permissions <true / false>",
|
||||||
bypassCommand.AddArgument("enable_bypass_perms", "true to enable bypassing all perms", "Boolean");
|
"Bypass permission checks",
|
||||||
bypassCommand.AddArgument("bypass_perms_value", "true/false: true will ignore all perms; false will restrict everything", "Boolean");
|
HandleBypassPermissions);
|
||||||
|
|
||||||
m_commander.RegisterCommand("bypass", bypassCommand);
|
m_scene.AddCommand("permissions", "force permissions",
|
||||||
|
"force permissions <true / false>",
|
||||||
|
"Force permissions on or off",
|
||||||
|
HandleForcePermissions);
|
||||||
|
|
||||||
Command debugCommand = new Command("debug", CommandIntentions.COMMAND_STATISTICAL, InterfaceDebugPermissions, "Force the permissions a specific way to test permissions");
|
m_scene.AddCommand("permissions", "debug permissions",
|
||||||
debugCommand.AddArgument("enable_debug_perms", "true to enable debugging to console all perms", "Boolean");
|
"debug permissions <true / false>",
|
||||||
|
"Enable permissions debugging",
|
||||||
|
HandleDebugPermissions);
|
||||||
|
}
|
||||||
|
|
||||||
m_commander.RegisterCommand("debug", debugCommand);
|
public void HandleBypassPermissions(string module, string[] args)
|
||||||
m_scene.RegisterModuleCommander(m_commander);
|
{
|
||||||
|
if (m_scene.ConsoleScene() != null &&
|
||||||
|
m_scene.ConsoleScene() != m_scene)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_scene.EventManager.OnPluginConsole += new EventManager.OnPluginConsoleDelegate(EventManager_OnPluginConsole);
|
if (args.Length > 2)
|
||||||
|
{
|
||||||
|
bool val;
|
||||||
|
|
||||||
|
if (!bool.TryParse(args[2], out val))
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_bypassPermissions = val;
|
||||||
|
|
||||||
|
m_log.InfoFormat("[PERMISSIONS] Set permissions bypass to {0} for {1}", m_bypassPermissions, m_scene.RegionInfo.RegionName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandleForcePermissions(string module, string[] args)
|
||||||
|
{
|
||||||
|
if (m_scene.ConsoleScene() != null &&
|
||||||
|
m_scene.ConsoleScene() != m_scene)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_bypassPermissions)
|
||||||
|
{
|
||||||
|
m_log.Error("[PERMISSIONS] Permissions can't be forced unless they are bypassed first");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.Length > 2)
|
||||||
|
{
|
||||||
|
bool val;
|
||||||
|
|
||||||
|
if (!bool.TryParse(args[2], out val))
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_bypassPermissionsValue = val;
|
||||||
|
|
||||||
|
m_log.InfoFormat("[PERMISSIONS] Forced permissions to {0} in {1}", m_bypassPermissionsValue, m_scene.RegionInfo.RegionName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandleDebugPermissions(string module, string[] args)
|
||||||
|
{
|
||||||
|
if (m_scene.ConsoleScene() != null &&
|
||||||
|
m_scene.ConsoleScene() != m_scene)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.Length > 2)
|
||||||
|
{
|
||||||
|
bool val;
|
||||||
|
|
||||||
|
if (!bool.TryParse(args[2], out val))
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_debugPermissions = val;
|
||||||
|
|
||||||
|
m_log.InfoFormat("[PERMISSIONS] Set permissions debugging to {0} in {1}", m_debugPermissions, m_scene.RegionInfo.RegionName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PostInitialise()
|
public void PostInitialise()
|
||||||
|
|
|
@ -46,5 +46,6 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
|
|
||||||
void Run(object[] args);
|
void Run(object[] args);
|
||||||
void ShowConsoleHelp();
|
void ShowConsoleHelp();
|
||||||
|
string ShortHelp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ using OpenMetaverse;
|
||||||
using OpenMetaverse.Imaging;
|
using OpenMetaverse.Imaging;
|
||||||
using OpenMetaverse.Packets;
|
using OpenMetaverse.Packets;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Framework.Communications;
|
using OpenSim.Framework.Communications;
|
||||||
using OpenSim.Framework.Communications.Cache;
|
using OpenSim.Framework.Communications.Cache;
|
||||||
using OpenSim.Framework.Servers;
|
using OpenSim.Framework.Servers;
|
||||||
|
@ -3384,7 +3385,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <param name="cmdparams"></param>
|
/// <param name="cmdparams"></param>
|
||||||
public void HandleEditCommand(string[] cmdparams)
|
public void HandleEditCommand(string[] cmdparams)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Searching for Primitive: '" + cmdparams[0] + "'");
|
Console.WriteLine("Searching for Primitive: '" + cmdparams[2] + "'");
|
||||||
|
|
||||||
List<EntityBase> EntityList = GetEntities();
|
List<EntityBase> EntityList = GetEntities();
|
||||||
|
|
||||||
|
@ -3395,11 +3396,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID);
|
SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID);
|
||||||
if (part != null)
|
if (part != null)
|
||||||
{
|
{
|
||||||
if (part.Name == cmdparams[0])
|
if (part.Name == cmdparams[2])
|
||||||
{
|
{
|
||||||
part.Resize(
|
part.Resize(
|
||||||
new Vector3(Convert.ToSingle(cmdparams[1]), Convert.ToSingle(cmdparams[2]),
|
new Vector3(Convert.ToSingle(cmdparams[3]), Convert.ToSingle(cmdparams[4]),
|
||||||
Convert.ToSingle(cmdparams[3])));
|
Convert.ToSingle(cmdparams[5])));
|
||||||
|
|
||||||
Console.WriteLine("Edited scale of Primitive: " + part.Name);
|
Console.WriteLine("Edited scale of Primitive: " + part.Name);
|
||||||
}
|
}
|
||||||
|
@ -4235,5 +4236,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Scene ConsoleScene()
|
||||||
|
{
|
||||||
|
if (MainConsole.Instance == null)
|
||||||
|
return null;
|
||||||
|
if (MainConsole.Instance.ConsoleScene is Scene)
|
||||||
|
return (Scene)MainConsole.Instance.ConsoleScene;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ using System.Threading;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using log4net;
|
using log4net;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Framework.Communications.Cache;
|
using OpenSim.Framework.Communications.Cache;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
|
|
||||||
|
@ -458,5 +459,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddCommand(string module, string command, string shorthelp, string longhelp, CommandDelegate callback)
|
||||||
|
{
|
||||||
|
if (MainConsole.Instance == null)
|
||||||
|
return;
|
||||||
|
MainConsole.Instance.Commands.AddCommand(module, command, shorthelp, longhelp, callback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,12 +128,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
get { return m_ScriptEngine.World; }
|
get { return m_ScriptEngine.World; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extension commands use this:
|
|
||||||
public ICommander GetCommander(string name)
|
|
||||||
{
|
|
||||||
return World.GetCommander(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void state(string newState)
|
public void state(string newState)
|
||||||
{
|
{
|
||||||
m_ScriptEngine.SetState(m_itemID, newState);
|
m_ScriptEngine.SetState(m_itemID, newState);
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace OpenSim.TestSuite
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Thread/Bot manager for the application
|
/// Thread/Bot manager for the application
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class BotManager : conscmd_callback
|
public class BotManager
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
@ -58,8 +58,6 @@ namespace OpenSim.TestSuite
|
||||||
public BotManager()
|
public BotManager()
|
||||||
{
|
{
|
||||||
m_log.Info("In bot manager");
|
m_log.Info("In bot manager");
|
||||||
// m_console = CreateConsole();
|
|
||||||
// MainConsole.Instance = m_console;
|
|
||||||
m_lBot = new List<PhysicsBot>();
|
m_lBot = new List<PhysicsBot>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,52 +167,5 @@ namespace OpenSim.TestSuite
|
||||||
pb.shutdown();
|
pb.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Standard CreateConsole routine
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
protected ConsoleBase CreateConsole()
|
|
||||||
{
|
|
||||||
return new ConsoleBase("Region", this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Command runnint tool.. Currently use it to add bots, shutdown and (dangerous)Forcequit
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="command"></param>
|
|
||||||
/// <param name="cmdparams"></param>
|
|
||||||
public void RunCmd(string command, string[] cmdparams)
|
|
||||||
{
|
|
||||||
switch (command)
|
|
||||||
{
|
|
||||||
case "shutdown":
|
|
||||||
m_console.Warn("BOTMANAGER", "Shutting down bots");
|
|
||||||
doBotShutdown();
|
|
||||||
break;
|
|
||||||
case "quit":
|
|
||||||
m_console.Warn("DANGER", "This should only be used to quit the program if you've already used the shutdown command and the program hasn't quit");
|
|
||||||
Environment.Exit(0);
|
|
||||||
break;
|
|
||||||
case "addbots":
|
|
||||||
int newbots;
|
|
||||||
Int32.TryParse(cmdparams[0], out newbots);
|
|
||||||
|
|
||||||
if (newbots > 0)
|
|
||||||
addbots(newbots);
|
|
||||||
break;
|
|
||||||
case "help":
|
|
||||||
m_console.Notice("HELP", "\nshutdown - graceful shutdown\naddbots <n> - adds n bots to the test\nquit - forcequits, dangerous if you have not already run shutdown");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method to implement the conscmd_callback interface
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="showParams">What to show</param>
|
|
||||||
public void Show(string[] showParams)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,9 @@ using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
using log4net.Appender;
|
||||||
|
using log4net.Core;
|
||||||
|
using log4net.Repository;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
|
@ -40,7 +43,7 @@ namespace pCampBot
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Thread/Bot manager for the application
|
/// Thread/Bot manager for the application
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class BotManager : conscmd_callback
|
public class BotManager
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
@ -59,6 +62,36 @@ namespace pCampBot
|
||||||
{
|
{
|
||||||
m_console = CreateConsole();
|
m_console = CreateConsole();
|
||||||
MainConsole.Instance = m_console;
|
MainConsole.Instance = m_console;
|
||||||
|
|
||||||
|
// Make log4net see the console
|
||||||
|
//
|
||||||
|
ILoggerRepository repository = LogManager.GetRepository();
|
||||||
|
IAppender[] appenders = repository.GetAppenders();
|
||||||
|
OpenSimAppender consoleAppender = null;
|
||||||
|
|
||||||
|
foreach (IAppender appender in appenders)
|
||||||
|
{
|
||||||
|
if (appender.Name == "Console")
|
||||||
|
{
|
||||||
|
consoleAppender = (OpenSimAppender)appender;
|
||||||
|
consoleAppender.Console = m_console;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("bot", "shutdown",
|
||||||
|
"shutdown",
|
||||||
|
"Gracefully shut down bots", HandleShutdown);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("bot", "quit",
|
||||||
|
"quit",
|
||||||
|
"Force quit (DANGEROUS, try shutdown first)",
|
||||||
|
HandleShutdown);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("bot", "add bots",
|
||||||
|
"add bots <number>",
|
||||||
|
"Add more bots", HandleAddBots);
|
||||||
|
|
||||||
m_lBot = new List<PhysicsBot>();
|
m_lBot = new List<PhysicsBot>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,45 +208,31 @@ namespace pCampBot
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected ConsoleBase CreateConsole()
|
protected ConsoleBase CreateConsole()
|
||||||
{
|
{
|
||||||
return new ConsoleBase("Region", this);
|
return new ConsoleBase("Region");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private void HandleShutdown(string module, string[] cmd)
|
||||||
/// Command runnint tool.. Currently use it to add bots, shutdown and (dangerous)Forcequit
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="command"></param>
|
|
||||||
/// <param name="cmdparams"></param>
|
|
||||||
public void RunCmd(string command, string[] cmdparams)
|
|
||||||
{
|
{
|
||||||
switch (command)
|
|
||||||
{
|
|
||||||
case "shutdown":
|
|
||||||
m_console.Warn("BOTMANAGER", "Shutting down bots");
|
m_console.Warn("BOTMANAGER", "Shutting down bots");
|
||||||
doBotShutdown();
|
doBotShutdown();
|
||||||
break;
|
}
|
||||||
case "quit":
|
|
||||||
|
private void HandleQuit(string module, string[] cmd)
|
||||||
|
{
|
||||||
m_console.Warn("DANGER", "This should only be used to quit the program if you've already used the shutdown command and the program hasn't quit");
|
m_console.Warn("DANGER", "This should only be used to quit the program if you've already used the shutdown command and the program hasn't quit");
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
break;
|
}
|
||||||
case "addbots":
|
|
||||||
int newbots;
|
|
||||||
Int32.TryParse(cmdparams[0], out newbots);
|
|
||||||
|
|
||||||
|
private void HandleAddBots(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
int newbots = 0;
|
||||||
|
|
||||||
|
if (cmd.Length > 2)
|
||||||
|
{
|
||||||
|
Int32.TryParse(cmd[2], out newbots);
|
||||||
|
}
|
||||||
if (newbots > 0)
|
if (newbots > 0)
|
||||||
addbots(newbots);
|
addbots(newbots);
|
||||||
break;
|
|
||||||
case "help":
|
|
||||||
m_console.Notice("HELP", "\nshutdown - graceful shutdown\naddbots <n> - adds n bots to the test\nquit - forcequits, dangerous if you have not already run shutdown");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method to implement the conscmd_callback interface
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="showParams">What to show</param>
|
|
||||||
public void Show(string[] showParams)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue