mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 01:35:46 +08:00
Add proper handling for shared vs. unshared modules to the command
interface. Shared modules will now only get added once, so the command handler is called once per module, not once per scene. Removal of scenes has no adverse effects. Nonshared modules will be called for each scene.
This commit is contained in:
@@ -48,6 +48,11 @@ namespace OpenSim.Framework.Console
|
||||
/// </value>
|
||||
public string module;
|
||||
|
||||
/// <value>
|
||||
/// Whether the module is shared
|
||||
/// </value>
|
||||
public bool shared;
|
||||
|
||||
/// <value>
|
||||
/// Very short BNF description
|
||||
/// </value>
|
||||
@@ -66,7 +71,7 @@ namespace OpenSim.Framework.Console
|
||||
/// <value>
|
||||
/// The method to invoke for this command
|
||||
/// </value>
|
||||
public CommandDelegate fn;
|
||||
public List<CommandDelegate> fn;
|
||||
}
|
||||
|
||||
/// <value>
|
||||
@@ -172,10 +177,11 @@ namespace OpenSim.Framework.Console
|
||||
/// <param name="help"></param>
|
||||
/// <param name="longhelp"></param>
|
||||
/// <param name="fn"></param>
|
||||
public void AddCommand(
|
||||
string module, string command, string help, string longhelp, CommandDelegate fn)
|
||||
public void AddCommand(string module, bool shared, string command,
|
||||
string help, string longhelp, CommandDelegate fn)
|
||||
{
|
||||
AddCommand(module, command, help, longhelp, String.Empty, fn);
|
||||
AddCommand(module, shared, command, help, longhelp,
|
||||
String.Empty, fn);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -187,8 +193,9 @@ namespace OpenSim.Framework.Console
|
||||
/// <param name="longhelp"></param>
|
||||
/// <param name="descriptivehelp"></param>
|
||||
/// <param name="fn"></param>
|
||||
public void AddCommand(
|
||||
string module, string command, string help, string longhelp, string descriptivehelp, CommandDelegate fn)
|
||||
public void AddCommand(string module, bool shared, string command,
|
||||
string help, string longhelp, string descriptivehelp,
|
||||
CommandDelegate fn)
|
||||
{
|
||||
string[] parts = Parser.Parse(command);
|
||||
|
||||
@@ -212,15 +219,25 @@ namespace OpenSim.Framework.Console
|
||||
}
|
||||
}
|
||||
|
||||
CommandInfo info;
|
||||
|
||||
if (current.ContainsKey(String.Empty))
|
||||
{
|
||||
info = (CommandInfo)current[String.Empty];
|
||||
if (!info.shared && !info.fn.Contains(fn))
|
||||
info.fn.Add(fn);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
CommandInfo info = new CommandInfo();
|
||||
info = new CommandInfo();
|
||||
info.module = module;
|
||||
info.shared = shared;
|
||||
info.help_text = help;
|
||||
info.long_help = longhelp;
|
||||
info.descriptive_help = descriptivehelp;
|
||||
info.fn = fn;
|
||||
info.fn = new List<CommandDelegate>();
|
||||
info.fn.Add(fn);
|
||||
current[String.Empty] = info;
|
||||
}
|
||||
|
||||
@@ -275,7 +292,7 @@ namespace OpenSim.Framework.Console
|
||||
if (s == String.Empty)
|
||||
{
|
||||
CommandInfo ci = (CommandInfo)current[String.Empty];
|
||||
if (ci.fn != null)
|
||||
if (ci.fn.Count != null)
|
||||
addcr = true;
|
||||
}
|
||||
else
|
||||
@@ -337,9 +354,10 @@ namespace OpenSim.Framework.Console
|
||||
if (current.ContainsKey(String.Empty))
|
||||
{
|
||||
CommandInfo ci = (CommandInfo)current[String.Empty];
|
||||
if (ci.fn == null)
|
||||
if (ci.fn.Count == null)
|
||||
return new string[0];
|
||||
ci.fn(ci.module, result);
|
||||
foreach (CommandDelegate fn in ci.fn)
|
||||
fn(ci.module, result);
|
||||
return result;
|
||||
}
|
||||
return new string[0];
|
||||
@@ -409,9 +427,8 @@ namespace OpenSim.Framework.Console
|
||||
{
|
||||
DefaultPrompt = defaultPrompt;
|
||||
|
||||
Commands.AddCommand(
|
||||
"console", "help", "help [<command>]",
|
||||
"Get general command list or more detailed help on a specific command", Help);
|
||||
Commands.AddCommand("console", false, "help", "help [<command>]",
|
||||
"Get general command list or more detailed help on a specific command", Help);
|
||||
}
|
||||
|
||||
public void SetGuiMode(bool mode)
|
||||
|
||||
@@ -90,6 +90,6 @@ namespace OpenSim.Framework
|
||||
T RequestModuleInterface<T>();
|
||||
T[] RequestModuleInterfaces<T>();
|
||||
|
||||
void AddCommand(string module, string command, string shorthelp, string longhelp, CommandDelegate callback);
|
||||
void AddCommand(object module, string command, string shorthelp, string longhelp, CommandDelegate callback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,35 +104,35 @@ namespace OpenSim.Framework.Servers
|
||||
{
|
||||
SetConsoleLogLevel(new string[] { "ALL" });
|
||||
|
||||
m_console.Commands.AddCommand("base", "quit",
|
||||
m_console.Commands.AddCommand("base", false, "quit",
|
||||
"quit",
|
||||
"Quit the application", HandleQuit);
|
||||
|
||||
m_console.Commands.AddCommand("base", "shutdown",
|
||||
m_console.Commands.AddCommand("base", false, "shutdown",
|
||||
"shutdown",
|
||||
"Quit the application", HandleQuit);
|
||||
|
||||
m_console.Commands.AddCommand("base", "set log level",
|
||||
m_console.Commands.AddCommand("base", false, "set log level",
|
||||
"set log level <level>",
|
||||
"Set the console logging level", HandleLogLevel);
|
||||
|
||||
m_console.Commands.AddCommand("base", "show info",
|
||||
m_console.Commands.AddCommand("base", false, "show info",
|
||||
"show info",
|
||||
"Show general information", HandleShow);
|
||||
|
||||
m_console.Commands.AddCommand("base", "show stats",
|
||||
m_console.Commands.AddCommand("base", false, "show stats",
|
||||
"show stats",
|
||||
"Show statistics", HandleShow);
|
||||
|
||||
m_console.Commands.AddCommand("base", "show threads",
|
||||
m_console.Commands.AddCommand("base", false, "show threads",
|
||||
"show threads",
|
||||
"Show thread status", HandleShow);
|
||||
|
||||
m_console.Commands.AddCommand("base", "show uptime",
|
||||
m_console.Commands.AddCommand("base", false, "show uptime",
|
||||
"show uptime",
|
||||
"Show server uptime", HandleShow);
|
||||
|
||||
m_console.Commands.AddCommand("base", "show version",
|
||||
m_console.Commands.AddCommand("base", false, "show version",
|
||||
"show version",
|
||||
"Show server version", HandleShow);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user