From 9bfbfa381abc92f3c5fc8e97405943128c85c5d4 Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Tue, 10 Feb 2009 23:15:48 +0000
Subject: 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.
---
OpenSim/Framework/Console/ConsoleBase.cs | 45 ++++++++++++++++++--------
OpenSim/Framework/IScene.cs | 2 +-
OpenSim/Framework/Servers/BaseOpenSimServer.cs | 16 ++++-----
3 files changed, 40 insertions(+), 23 deletions(-)
(limited to 'OpenSim/Framework')
diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs
index 8e61587..721e91a 100644
--- a/OpenSim/Framework/Console/ConsoleBase.cs
+++ b/OpenSim/Framework/Console/ConsoleBase.cs
@@ -49,6 +49,11 @@ namespace OpenSim.Framework.Console
public string module;
///
+ /// Whether the module is shared
+ ///
+ public bool shared;
+
+ ///
/// Very short BNF description
///
public string help_text;
@@ -66,7 +71,7 @@ namespace OpenSim.Framework.Console
///
/// The method to invoke for this command
///
- public CommandDelegate fn;
+ public List fn;
}
///
@@ -172,10 +177,11 @@ namespace OpenSim.Framework.Console
///
///
///
- 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);
}
///
@@ -187,8 +193,9 @@ namespace OpenSim.Framework.Console
///
///
///
- 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();
+ 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 []",
- "Get general command list or more detailed help on a specific command", Help);
+ Commands.AddCommand("console", false, "help", "help []",
+ "Get general command list or more detailed help on a specific command", Help);
}
public void SetGuiMode(bool mode)
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs
index 493c626..1c0a3b5 100644
--- a/OpenSim/Framework/IScene.cs
+++ b/OpenSim/Framework/IScene.cs
@@ -90,6 +90,6 @@ namespace OpenSim.Framework
T RequestModuleInterface();
T[] RequestModuleInterfaces();
- void AddCommand(string module, string command, string shorthelp, string longhelp, CommandDelegate callback);
+ void AddCommand(object module, string command, string shorthelp, string longhelp, CommandDelegate callback);
}
}
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index ac5e183..ff53e1a 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -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 ",
"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);
}
--
cgit v1.1