From 5c48d7a378ff066f59b9cee02f2803ebe1616481 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Nov 2012 04:05:09 +0000 Subject: factor out common HandleShow code for "show uptime" --- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 39 +++----------------- OpenSim/Framework/Servers/ServerBase.cs | 50 ++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 34 deletions(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 6346279..4f9ac08 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -62,7 +62,6 @@ namespace OpenSim.Framework.Servers /// private Timer m_periodicDiagnosticsTimer = new Timer(60 * 60 * 1000); - protected CommandConsole m_console; protected OpenSimAppender m_consoleAppender; protected IAppender m_logFileAppender = null; @@ -139,7 +138,8 @@ namespace OpenSim.Framework.Servers } else { - m_consoleAppender.Console = m_console; + // FIXME: This should be done through an interface rather than casting. + m_consoleAppender.Console = (ConsoleBase)m_console; // If there is no threshold set then the threshold is effectively everything. if (null == m_consoleAppender.Threshold) @@ -367,8 +367,10 @@ namespace OpenSim.Framework.Servers } } - public virtual void HandleShow(string module, string[] cmd) + public override void HandleShow(string module, string[] cmd) { + base.HandleShow(module, cmd); + List args = new List(cmd); args.RemoveAt(0); @@ -385,10 +387,6 @@ namespace OpenSim.Framework.Servers Notice(GetThreadsReport()); break; - case "uptime": - Notice(GetUptimeReport()); - break; - case "version": Notice(GetVersionText()); break; @@ -430,33 +428,6 @@ namespace OpenSim.Framework.Servers } /// - /// Console output is only possible if a console has been established. - /// That is something that cannot be determined within this class. So - /// all attempts to use the console MUST be verified. - /// - /// - protected void Notice(string msg) - { - if (m_console != null) - { - m_console.Output(msg); - } - } - - /// - /// Console output is only possible if a console has been established. - /// That is something that cannot be determined within this class. So - /// all attempts to use the console MUST be verified. - /// - /// - /// - protected void Notice(string format, params string[] components) - { - if (m_console != null) - m_console.OutputFormat(format, components); - } - - /// /// Enhance the version string with extra information if it's available. /// protected void EnhanceVersionInformation() diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index d19234b..afe1f73 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs @@ -26,13 +26,20 @@ */ using System; +using System.Collections.Generic; using System.Text; +using OpenSim.Framework.Console; namespace OpenSim.Framework.Servers { public class ServerBase { /// + /// Console to be used for any command line output. Can be null, in which case there should be no output. + /// + protected ICommandConsole m_console; + + /// /// Time at which this server was started /// protected DateTime m_startuptime; @@ -42,6 +49,22 @@ namespace OpenSim.Framework.Servers m_startuptime = DateTime.Now; } + public virtual void HandleShow(string module, string[] cmd) + { + List args = new List(cmd); + + args.RemoveAt(0); + + string[] showParams = args.ToArray(); + + switch (showParams[0]) + { + case "uptime": + Notice(GetUptimeReport()); + break; + } + } + /// /// Return a report about the uptime of this server /// @@ -54,5 +77,32 @@ namespace OpenSim.Framework.Servers return sb.ToString(); } + + /// + /// Console output is only possible if a console has been established. + /// That is something that cannot be determined within this class. So + /// all attempts to use the console MUST be verified. + /// + /// + protected void Notice(string msg) + { + if (m_console != null) + { + m_console.Output(msg); + } + } + + /// + /// Console output is only possible if a console has been established. + /// That is something that cannot be determined within this class. So + /// all attempts to use the console MUST be verified. + /// + /// + /// + protected void Notice(string format, params string[] components) + { + if (m_console != null) + m_console.OutputFormat(format, components); + } } } \ No newline at end of file -- cgit v1.1