aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices.GridServer/Main.cs
diff options
context:
space:
mode:
authorgareth2007-03-25 00:27:36 +0000
committergareth2007-03-25 00:27:36 +0000
commit11d7cc89a9203a8155f3e71b92162e5d2c09bd99 (patch)
tree34ca2bbd44c5e5cb9d0b416ba5040c553fea1437 /OpenGridServices.GridServer/Main.cs
parentMoved gridserver into main trunk (but no prebuild yet) (diff)
downloadopensim-SC_OLD-11d7cc89a9203a8155f3e71b92162e5d2c09bd99.zip
opensim-SC_OLD-11d7cc89a9203a8155f3e71b92162e5d2c09bd99.tar.gz
opensim-SC_OLD-11d7cc89a9203a8155f3e71b92162e5d2c09bd99.tar.bz2
opensim-SC_OLD-11d7cc89a9203a8155f3e71b92162e5d2c09bd99.tar.xz
Finished adding the grid server to prebuild
Diffstat (limited to 'OpenGridServices.GridServer/Main.cs')
-rw-r--r--OpenGridServices.GridServer/Main.cs237
1 files changed, 237 insertions, 0 deletions
diff --git a/OpenGridServices.GridServer/Main.cs b/OpenGridServices.GridServer/Main.cs
new file mode 100644
index 0000000..de49b1e
--- /dev/null
+++ b/OpenGridServices.GridServer/Main.cs
@@ -0,0 +1,237 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3
4
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.IO;
32using System.Text;
33using libsecondlife;
34using ServerConsole;
35
36namespace OpenGridServices
37{
38 /// <summary>
39 /// </summary>
40 public class OpenGrid_Main
41 {
42
43 public static OpenGrid_Main thegrid;
44 public string GridOwner;
45 public string DefaultStartupMsg;
46 public string DefaultAssetServer;
47 public string AssetSendKey;
48 public string AssetRecvKey;
49 public string DefaultUserServer;
50 public string UserSendKey;
51 public string UserRecvKey;
52
53 public GridHTTPServer _httpd;
54 public SimProfileManager _regionmanager;
55
56 [STAThread]
57 public static void Main( string[] args )
58 {
59 Console.WriteLine("Starting...\n");
60 ServerConsole.MainConsole.Instance = new MServerConsole(ServerConsole.ConsoleBase.ConsoleType.Local, "", 0, "opengrid-console.log", "OpenGrid", new GridConsole());
61
62 thegrid = new OpenGrid_Main();
63 thegrid.Startup();
64
65 ServerConsole.MainConsole.Instance.WriteLine("\nEnter help for a list of commands\n");
66
67 while(true) {
68 ServerConsole.MainConsole.Instance.MainConsolePrompt();
69 }
70 }
71
72 public void Startup() {
73 ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Please press enter to retain default settings");
74
75 this.GridOwner=ServerConsole.MainConsole.Instance.CmdPrompt("Grid owner [OGS development team]: ","OGS development team");
76 this.DefaultStartupMsg=ServerConsole.MainConsole.Instance.CmdPrompt("Default startup message for clients [Welcome to OGS!]: ","Welcome to OGS!");
77
78 this.DefaultAssetServer=ServerConsole.MainConsole.Instance.CmdPrompt("Default asset server [no default]: ");
79 this.AssetSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to asset server: ");
80 this.AssetRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from asset server: ");
81
82 this.DefaultUserServer=ServerConsole.MainConsole.Instance.CmdPrompt("Default user server [no default]: ");
83 this.UserSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to user server: ");
84 this.UserRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from user server: ");
85
86 ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting HTTP process");
87 _httpd = new GridHTTPServer();
88
89 this._regionmanager=new SimProfileManager();
90 _regionmanager.CreateNewProfile("OpenSim Test", "http://there-is-no-caps.com", "4.78.190.75", 9000, 997, 996, this.UserSendKey, this.UserRecvKey);
91
92 }
93 }
94 /// <summary>
95 /// Description of ServerConsole.
96 /// </summary>
97 public class MServerConsole : ConsoleBase
98 {
99
100 private ConsoleType ConsType;
101 StreamWriter Log;
102 public conscmd_callback cmdparser;
103 public string componentname;
104
105 // STUPID HACK ALERT!!!! STUPID HACK ALERT!!!!!
106 // constype - the type of console to use (see enum ConsoleType)
107 // sparam - depending on the console type:
108 // TCP - the IP to bind to (127.0.0.1 if blank)
109 // Local - param ignored
110 // and for the iparam:
111 // TCP - the port to bind to
112 // Local - param ignored
113 // LogFile - duh
114 // componentname - which component of the OGS system? (user, asset etc)
115 // cmdparser - a reference to a conscmd_callback object
116
117 public MServerConsole(ConsoleType constype, string sparam, int iparam, string LogFile, string componentname, conscmd_callback cmdparser) {
118 ConsType = constype;
119 this.componentname = componentname;
120 this.cmdparser = cmdparser;
121 switch(constype) {
122 case ConsoleType.Local:
123 Console.WriteLine("ServerConsole.cs - creating new local console");
124 Console.WriteLine("Logs will be saved to current directory in " + LogFile);
125 Log=File.AppendText(LogFile);
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}