aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/SimConsole.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim.RegionServer/SimConsole.cs211
1 files changed, 0 insertions, 211 deletions
diff --git a/OpenSim.RegionServer/SimConsole.cs b/OpenSim.RegionServer/SimConsole.cs
index d6d5e44..e69de29 100644
--- a/OpenSim.RegionServer/SimConsole.cs
+++ b/OpenSim.RegionServer/SimConsole.cs
@@ -1,211 +0,0 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Threading;
32using System.IO;
33using System.Net;
34using libsecondlife;
35using libsecondlife.Packets;
36using OpenSim.Framework.Console;
37
38namespace OpenSim
39{
40 /// <summary>
41 /// Description of ServerConsole.
42 /// </summary>
43 public class SimConsole : ConsoleBase
44 {
45
46 private ConsoleType ConsType;
47 StreamWriter Log;
48
49
50 // STUPID HACK ALERT!!!! STUPID HACK ALERT!!!!!
51 // constype - the type of console to use (see enum ConsoleType)
52 // sparam - depending on the console type:
53 // TCP - the IP to bind to (127.0.0.1 if blank)
54 // Local - param ignored
55 // SimChat - the AgentID of this sim's admin
56 // and for the iparam:
57 // TCP - the port to bind to
58 // Local - param ignored
59 // SimChat - the chat channel to accept commands from
60 public SimConsole(ConsoleType constype, string sparam, int iparam) {
61 ConsType = constype;
62 switch(constype) {
63 case ConsoleType.Local:
64
65 Console.WriteLine("ServerConsole.cs - creating new local console");
66 Console.WriteLine("Logs will be saved to current directory in opensim-console.log");
67 Log=File.AppendText("opensim-console.log");
68 Log.WriteLine("========================================================================");
69 //Log.WriteLine("OpenSim " + VersionInfo.Version + " Started at " + DateTime.Now.ToString());
70 break;
71 case ConsoleType.TCP:
72 break;
73 case ConsoleType.SimChat:
74 break;
75
76 default:
77 Console.WriteLine("ServerConsole.cs - what are you smoking? that isn't a valid console type!");
78 break;
79 }
80 }
81
82 public override void Close() {
83 Log.WriteLine("OpenSim shutdown at " + DateTime.Now.ToString());
84 Log.Close();
85 }
86
87 public override void Write(string format, params object[] args)
88 {
89 Log.Write(format, args);
90 Console.Write(format, args);
91 return;
92 }
93
94 public override void WriteLine(string format, params object[] args)
95 {
96 Log.WriteLine(format, args);
97 Console.WriteLine(format, args);
98 return;
99 }
100
101 public override string ReadLine()
102 {
103 string TempStr=Console.ReadLine();
104 Log.WriteLine(TempStr);
105 return TempStr;
106 }
107
108 public override int Read() {
109 int TempInt= Console.Read();
110 Log.Write((char)TempInt);
111 return TempInt;
112 }
113
114 // Displays a command prompt and waits for the user to enter a string, then returns that string
115 public override string CmdPrompt(string prompt) {
116 this.Write(prompt);
117 return this.ReadLine();
118 }
119
120 // Displays a command prompt and returns a default value if the user simply presses enter
121 public override string CmdPrompt(string prompt, string defaultresponse) {
122 string temp=CmdPrompt(prompt);
123 if(temp=="") {
124 return defaultresponse;
125 } else {
126 return temp;
127 }
128 }
129
130 // Displays a command prompt and returns a default value, user may only enter 1 of 2 options
131 public override string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) {
132 bool itisdone=false;
133 string temp=CmdPrompt(prompt,defaultresponse);
134 while(itisdone==false) {
135 if((temp==OptionA) || (temp==OptionB)) {
136 itisdone=true;
137 } else {
138 this.WriteLine("Valid options are " + OptionA + " or " + OptionB);
139 temp=CmdPrompt(prompt,defaultresponse);
140 }
141 }
142 return temp;
143 }
144
145 // Runs a command with a number of parameters
146 public override Object RunCmd(string Cmd, string[] cmdparams) {
147 switch(Cmd) {
148 case "help":
149 this.WriteLine("show users - show info about connected users");
150 this.WriteLine("shutdown - disconnect all clients and shutdown");
151 this.WriteLine("regenerate - regenerate the sim's terrain");
152 break;
153
154 case "show":
155 ShowCommands(cmdparams[0]);
156 break;
157
158 case "regenerate":
159 OpenSimRoot.Instance.LocalWorld.RegenerateTerrain();
160 break;
161
162 case "shutdown":
163 OpenSimRoot.Instance.Shutdown();
164 break;
165 }
166 return null;
167 }
168
169 // Shows data about something
170 public override void ShowCommands(string ShowWhat) {
171 switch(ShowWhat) {
172 case "uptime":
173 this.WriteLine("OpenSim has been running since " + OpenSimRoot.Instance.startuptime.ToString());
174 this.WriteLine("That is " + (DateTime.Now-OpenSimRoot.Instance.startuptime).ToString());
175 break;
176 case "users":
177 OpenSim.world.Avatar TempAv;
178 this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}","Firstname", "Lastname","Agent ID", "Session ID", "Circuit", "IP"));
179 foreach (libsecondlife.LLUUID UUID in OpenSimRoot.Instance.LocalWorld.Entities.Keys) {
180 if(OpenSimRoot.Instance.LocalWorld.Entities[UUID].ToString()== "OpenSim.world.Avatar")
181 {
182 TempAv=(OpenSim.world.Avatar)OpenSimRoot.Instance.LocalWorld.Entities[UUID];
183 this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}",TempAv.firstname, TempAv.lastname,UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString()));
184 }
185 }
186 break;
187 }
188 }
189
190 // Displays a prompt to the user and then runs the command they entered
191 public override void MainConsolePrompt() {
192 string[] tempstrarray;
193 string tempstr = this.CmdPrompt("OpenSim-" + OpenSimRoot.Instance.Cfg.RegionHandle.ToString() + " # ");
194 tempstrarray = tempstr.Split(' ');
195 string cmd=tempstrarray[0];
196 Array.Reverse(tempstrarray);
197 Array.Resize<string>(ref tempstrarray,tempstrarray.Length-1);
198 Array.Reverse(tempstrarray);
199 string[] cmdparams=(string[])tempstrarray;
200 RunCmd(cmd,cmdparams);
201 }
202
203
204 public override void SetStatus(string status)
205 {
206 Console.Write( status + "\r" );
207 }
208 }
209}
210
211