aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices.GridServer/Main.cs
diff options
context:
space:
mode:
authorlbsa712007-03-27 08:10:15 +0000
committerlbsa712007-03-27 08:10:15 +0000
commita4fc6b5fbba7fd9a7b147b11a0d1c3ded1834d54 (patch)
tree560961306b9d80636d8ec976c05fcb8b54304f33 /OpenGridServices.GridServer/Main.cs
parentHeightfield needs fixing, or i'll re-implement it (probably actually the coll... (diff)
downloadopensim-SC_OLD-a4fc6b5fbba7fd9a7b147b11a0d1c3ded1834d54.zip
opensim-SC_OLD-a4fc6b5fbba7fd9a7b147b11a0d1c3ded1834d54.tar.gz
opensim-SC_OLD-a4fc6b5fbba7fd9a7b147b11a0d1c3ded1834d54.tar.bz2
opensim-SC_OLD-a4fc6b5fbba7fd9a7b147b11a0d1c3ded1834d54.tar.xz
* Now there's one Console class, and instead the apps responds to cmd's and show's
* Removed Golden Future TCP/SimChat options * Moved Ode.NET.dll to bin and changed prebuild accordingly (due to Prebuild limitations) * Normalized some namespaces * Added FxCop project * Added (temp disabled) Servers project (for great justice)
Diffstat (limited to '')
-rw-r--r--OpenGridServices.GridServer/Main.cs291
1 files changed, 90 insertions, 201 deletions
diff --git a/OpenGridServices.GridServer/Main.cs b/OpenGridServices.GridServer/Main.cs
index de49b1e..16abc24 100644
--- a/OpenGridServices.GridServer/Main.cs
+++ b/OpenGridServices.GridServer/Main.cs
@@ -31,207 +31,96 @@ using System;
31using System.IO; 31using System.IO;
32using System.Text; 32using System.Text;
33using libsecondlife; 33using libsecondlife;
34using ServerConsole; 34using OpenSim.Framework.Console;
35 35
36namespace OpenGridServices 36namespace OpenGridServices.GridServer
37{ 37{
38 /// <summary> 38 /// <summary>
39 /// </summary> 39 /// </summary>
40 public class OpenGrid_Main 40 public class OpenGrid_Main : conscmd_callback
41 { 41 {
42 42
43 public static OpenGrid_Main thegrid; 43 public static OpenGrid_Main thegrid;
44 public string GridOwner; 44 public string GridOwner;
45 public string DefaultStartupMsg; 45 public string DefaultStartupMsg;
46 public string DefaultAssetServer; 46 public string DefaultAssetServer;
47 public string AssetSendKey; 47 public string AssetSendKey;
48 public string AssetRecvKey; 48 public string AssetRecvKey;
49 public string DefaultUserServer; 49 public string DefaultUserServer;
50 public string UserSendKey; 50 public string UserSendKey;
51 public string UserRecvKey; 51 public string UserRecvKey;
52 52
53 public GridHTTPServer _httpd; 53 public GridHTTPServer _httpd;
54 public SimProfileManager _regionmanager; 54 public SimProfileManager _regionmanager;
55 55
56 [STAThread] 56 private ConsoleBase m_console;
57 public static void Main( string[] args ) 57
58 { 58 [STAThread]
59 Console.WriteLine("Starting...\n"); 59 public static void Main(string[] args)
60 ServerConsole.MainConsole.Instance = new MServerConsole(ServerConsole.ConsoleBase.ConsoleType.Local, "", 0, "opengrid-console.log", "OpenGrid", new GridConsole()); 60 {
61 61 Console.WriteLine("Starting...\n");
62 thegrid = new OpenGrid_Main(); 62
63 thegrid.Startup(); 63 thegrid = new OpenGrid_Main();
64 64 thegrid.Startup();
65 ServerConsole.MainConsole.Instance.WriteLine("\nEnter help for a list of commands\n"); 65
66 66 thegrid.Work();
67 while(true) { 67 }
68 ServerConsole.MainConsole.Instance.MainConsolePrompt(); 68
69 } 69 private void Work()
70 } 70 {
71 71 m_console.WriteLine("\nEnter help for a list of commands\n");
72 public void Startup() { 72
73 ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Please press enter to retain default settings"); 73 while (true)
74 74 {
75 this.GridOwner=ServerConsole.MainConsole.Instance.CmdPrompt("Grid owner [OGS development team]: ","OGS development team"); 75 m_console.MainConsolePrompt();
76 this.DefaultStartupMsg=ServerConsole.MainConsole.Instance.CmdPrompt("Default startup message for clients [Welcome to OGS!]: ","Welcome to OGS!"); 76 }
77 77 }
78 this.DefaultAssetServer=ServerConsole.MainConsole.Instance.CmdPrompt("Default asset server [no default]: "); 78
79 this.AssetSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to asset server: "); 79 private OpenGrid_Main()
80 this.AssetRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from asset server: "); 80 {
81 81 m_console = new ConsoleBase("opengrid-console.log", "OpenGrid", this);
82 this.DefaultUserServer=ServerConsole.MainConsole.Instance.CmdPrompt("Default user server [no default]: "); 82 MainConsole.Instance = m_console;
83 this.UserSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to user server: "); 83 }
84 this.UserRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from user server: "); 84
85 85 public void Startup()
86 ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting HTTP process"); 86 {
87 _httpd = new GridHTTPServer(); 87 m_console.WriteLine("Main.cs:Startup() - Please press enter to retain default settings");
88 88
89 this._regionmanager=new SimProfileManager(); 89 this.GridOwner = m_console.CmdPrompt("Grid owner [OGS development team]: ", "OGS development team");
90 _regionmanager.CreateNewProfile("OpenSim Test", "http://there-is-no-caps.com", "4.78.190.75", 9000, 997, 996, this.UserSendKey, this.UserRecvKey); 90 this.DefaultStartupMsg = m_console.CmdPrompt("Default startup message for clients [Welcome to OGS!]: ", "Welcome to OGS!");
91 91
92 } 92 this.DefaultAssetServer = m_console.CmdPrompt("Default asset server [no default]: ");
93 } 93 this.AssetSendKey = m_console.CmdPrompt("Key to send to asset server: ");
94 /// <summary> 94 this.AssetRecvKey = m_console.CmdPrompt("Key to expect from asset server: ");
95 /// Description of ServerConsole. 95
96 /// </summary> 96 this.DefaultUserServer = m_console.CmdPrompt("Default user server [no default]: ");
97 public class MServerConsole : ConsoleBase 97 this.UserSendKey = m_console.CmdPrompt("Key to send to user server: ");
98 { 98 this.UserRecvKey = m_console.CmdPrompt("Key to expect from user server: ");
99 99
100 private ConsoleType ConsType; 100 m_console.WriteLine("Main.cs:Startup() - Starting HTTP process");
101 StreamWriter Log; 101 _httpd = new GridHTTPServer();
102 public conscmd_callback cmdparser; 102
103 public string componentname; 103 this._regionmanager = new SimProfileManager();
104 104 _regionmanager.CreateNewProfile("OpenSim Test", "http://there-is-no-caps.com", "4.78.190.75", 9000, 997, 996, this.UserSendKey, this.UserRecvKey);
105 // STUPID HACK ALERT!!!! STUPID HACK ALERT!!!!! 105 }
106 // constype - the type of console to use (see enum ConsoleType) 106
107 // sparam - depending on the console type: 107 public void RunCmd(string cmd, string[] cmdparams)
108 // TCP - the IP to bind to (127.0.0.1 if blank) 108 {
109 // Local - param ignored 109 switch (cmd)
110 // and for the iparam: 110 {
111 // TCP - the port to bind to 111 case "help":
112 // Local - param ignored 112 m_console.WriteLine("shutdown - shutdown the grid (USE CAUTION!)");
113 // LogFile - duh 113 break;
114 // componentname - which component of the OGS system? (user, asset etc) 114
115 // cmdparser - a reference to a conscmd_callback object 115 case "shutdown":
116 116 m_console.Close();
117 public MServerConsole(ConsoleType constype, string sparam, int iparam, string LogFile, string componentname, conscmd_callback cmdparser) { 117 Environment.Exit(0);
118 ConsType = constype; 118 break;
119 this.componentname = componentname; 119 }
120 this.cmdparser = cmdparser; 120 }
121 switch(constype) { 121
122 case ConsoleType.Local: 122 public void Show(string ShowWhat)
123 Console.WriteLine("ServerConsole.cs - creating new local console"); 123 {
124 Console.WriteLine("Logs will be saved to current directory in " + LogFile); 124 }
125 Log=File.AppendText(LogFile); 125 }
126 Log.WriteLine("========================================================================");
127 Log.WriteLine(componentname + " Started at " + DateTime.Now.ToString());
128 break;
129
130 case ConsoleType.TCP:
131 break;
132
133 default:
134 Console.WriteLine("ServerConsole.cs - what are you smoking? that isn't a valid console type!");
135 break;
136 }
137 }
138
139 public override void Close() {
140 Log.WriteLine("Shutdown at " + DateTime.Now.ToString());
141 Log.Close();
142 }
143
144 // You know what ReadLine() and WriteLine() do, right? And Read() and Write()? Right, you do actually know C#, right? Are you actually a programmer? Do you know english? Do you find my sense of humour in comments irritating? Good, glad you're still here
145 public override void WriteLine(string Line) {
146 Log.WriteLine(Line);
147 Console.WriteLine(Line);
148 return;
149 }
150
151 public override string ReadLine() {
152 string TempStr=Console.ReadLine();
153 Log.WriteLine(TempStr);
154 return TempStr;
155 }
156
157 public override int Read() {
158 int TempInt= Console.Read();
159 Log.Write((char)TempInt);
160 return TempInt;
161 }
162
163 public override void Write(string Line) {
164 Console.Write(Line);
165 Log.Write(Line);
166 return;
167 }
168
169
170 // Displays a prompt and waits for the user to enter a string, then returns that string
171 // Done with no echo and suitable for passwords
172 public override string PasswdPrompt(string prompt) {
173 // FIXME: Needs to be better abstracted
174 Log.WriteLine(prompt);
175 this.Write(prompt);
176 ConsoleColor oldfg=Console.ForegroundColor;
177 Console.ForegroundColor=Console.BackgroundColor;
178 string temp=Console.ReadLine();
179 Console.ForegroundColor=oldfg;
180 return temp;
181 }
182
183 // Displays a command prompt and waits for the user to enter a string, then returns that string
184 public override string CmdPrompt(string prompt) {
185 this.Write(prompt);
186 return this.ReadLine();
187 }
188
189 // Displays a command prompt and returns a default value if the user simply presses enter
190 public override string CmdPrompt(string prompt, string defaultresponse) {
191 string temp=CmdPrompt(prompt);
192 if(temp=="") {
193 return defaultresponse;
194 } else {
195 return temp;
196 }
197 }
198
199 // Displays a command prompt and returns a default value, user may only enter 1 of 2 options
200 public override string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) {
201 bool itisdone=false;
202 string temp=CmdPrompt(prompt,defaultresponse);
203 while(itisdone==false) {
204 if((temp==OptionA) || (temp==OptionB)) {
205 itisdone=true;
206 } else {
207 this.WriteLine("Valid options are " + OptionA + " or " + OptionB);
208 temp=CmdPrompt(prompt,defaultresponse);
209 }
210 }
211 return temp;
212 }
213
214 // Runs a command with a number of parameters
215 public override Object RunCmd(string Cmd, string[] cmdparams) {
216 cmdparser.RunCmd(Cmd, cmdparams);
217 return null;
218 }
219
220 // Shows data about something
221 public override void ShowCommands(string ShowWhat) {
222 cmdparser.Show(ShowWhat);
223 }
224
225 public override void MainConsolePrompt() {
226 string[] tempstrarray;
227 string tempstr = this.CmdPrompt(this.componentname + "# ");
228 tempstrarray = tempstr.Split(' ');
229 string cmd=tempstrarray[0];
230 Array.Reverse(tempstrarray);
231 Array.Resize<string>(ref tempstrarray,tempstrarray.Length-1);
232 Array.Reverse(tempstrarray);
233 string[] cmdparams=(string[])tempstrarray;
234 RunCmd(cmd,cmdparams);
235 }
236 }
237} 126}