aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/ServerBase.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-11-22 04:05:09 +0000
committerJustin Clark-Casey (justincc)2012-11-22 04:05:09 +0000
commit5c48d7a378ff066f59b9cee02f2803ebe1616481 (patch)
tree82af06819d5bb9d184890b5395e831b4e47c91d7 /OpenSim/Framework/Servers/ServerBase.cs
parentrefactor: Factor out copy/pasted server uptime report code (diff)
downloadopensim-SC_OLD-5c48d7a378ff066f59b9cee02f2803ebe1616481.zip
opensim-SC_OLD-5c48d7a378ff066f59b9cee02f2803ebe1616481.tar.gz
opensim-SC_OLD-5c48d7a378ff066f59b9cee02f2803ebe1616481.tar.bz2
opensim-SC_OLD-5c48d7a378ff066f59b9cee02f2803ebe1616481.tar.xz
factor out common HandleShow code for "show uptime"
Diffstat (limited to 'OpenSim/Framework/Servers/ServerBase.cs')
-rw-r--r--OpenSim/Framework/Servers/ServerBase.cs50
1 files changed, 50 insertions, 0 deletions
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 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Text; 30using System.Text;
31using OpenSim.Framework.Console;
30 32
31namespace OpenSim.Framework.Servers 33namespace OpenSim.Framework.Servers
32{ 34{
33 public class ServerBase 35 public class ServerBase
34 { 36 {
35 /// <summary> 37 /// <summary>
38 /// Console to be used for any command line output. Can be null, in which case there should be no output.
39 /// </summary>
40 protected ICommandConsole m_console;
41
42 /// <summary>
36 /// Time at which this server was started 43 /// Time at which this server was started
37 /// </summary> 44 /// </summary>
38 protected DateTime m_startuptime; 45 protected DateTime m_startuptime;
@@ -42,6 +49,22 @@ namespace OpenSim.Framework.Servers
42 m_startuptime = DateTime.Now; 49 m_startuptime = DateTime.Now;
43 } 50 }
44 51
52 public virtual void HandleShow(string module, string[] cmd)
53 {
54 List<string> args = new List<string>(cmd);
55
56 args.RemoveAt(0);
57
58 string[] showParams = args.ToArray();
59
60 switch (showParams[0])
61 {
62 case "uptime":
63 Notice(GetUptimeReport());
64 break;
65 }
66 }
67
45 /// <summary> 68 /// <summary>
46 /// Return a report about the uptime of this server 69 /// Return a report about the uptime of this server
47 /// </summary> 70 /// </summary>
@@ -54,5 +77,32 @@ namespace OpenSim.Framework.Servers
54 77
55 return sb.ToString(); 78 return sb.ToString();
56 } 79 }
80
81 /// <summary>
82 /// Console output is only possible if a console has been established.
83 /// That is something that cannot be determined within this class. So
84 /// all attempts to use the console MUST be verified.
85 /// </summary>
86 /// <param name="msg"></param>
87 protected void Notice(string msg)
88 {
89 if (m_console != null)
90 {
91 m_console.Output(msg);
92 }
93 }
94
95 /// <summary>
96 /// Console output is only possible if a console has been established.
97 /// That is something that cannot be determined within this class. So
98 /// all attempts to use the console MUST be verified.
99 /// </summary>
100 /// <param name="format"></param>
101 /// <param name="components"></param>
102 protected void Notice(string format, params string[] components)
103 {
104 if (m_console != null)
105 m_console.OutputFormat(format, components);
106 }
57 } 107 }
58} \ No newline at end of file 108} \ No newline at end of file