diff options
Diffstat (limited to 'OpenSim-Source/OpenSim/OpenSimMain.cs')
-rw-r--r-- | OpenSim-Source/OpenSim/OpenSimMain.cs | 533 |
1 files changed, 533 insertions, 0 deletions
diff --git a/OpenSim-Source/OpenSim/OpenSimMain.cs b/OpenSim-Source/OpenSim/OpenSimMain.cs new file mode 100644 index 0000000..9025316 --- /dev/null +++ b/OpenSim-Source/OpenSim/OpenSimMain.cs | |||
@@ -0,0 +1,533 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://osgrid.org/ | ||
3 | |||
4 | * All rights reserved. | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions are met: | ||
8 | * * Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * * Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * * Neither the name of the <organization> nor the | ||
14 | * names of its contributors may be used to endorse or promote products | ||
15 | * derived from this software without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
20 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
27 | */ | ||
28 | |||
29 | using System; | ||
30 | using System.Text; | ||
31 | using System.IO; | ||
32 | using System.Threading; | ||
33 | using System.Net; | ||
34 | using System.Net.Sockets; | ||
35 | using System.Timers; | ||
36 | using System.Reflection; | ||
37 | using System.Collections; | ||
38 | using System.Collections.Generic; | ||
39 | using libsecondlife; | ||
40 | using libsecondlife.Packets; | ||
41 | using OpenSim.world; | ||
42 | using OpenSim.Terrain; | ||
43 | using OpenSim.Framework.Interfaces; | ||
44 | using OpenSim.Framework.Types; | ||
45 | using OpenSim.UserServer; | ||
46 | using OpenSim.Assets; | ||
47 | using OpenSim.CAPS; | ||
48 | using OpenSim.Framework.Console; | ||
49 | using OpenSim.Physics.Manager; | ||
50 | using Nwc.XmlRpc; | ||
51 | using OpenSim.Servers; | ||
52 | using OpenSim.GenericConfig; | ||
53 | |||
54 | namespace OpenSim | ||
55 | { | ||
56 | |||
57 | public class OpenSimMain : RegionServerBase, conscmd_callback | ||
58 | { | ||
59 | private CheckSumServer checkServer; | ||
60 | |||
61 | public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile) | ||
62 | { | ||
63 | this.configFileSetup = useConfigFile; | ||
64 | m_sandbox = sandBoxMode; | ||
65 | m_loginserver = startLoginServer; | ||
66 | m_physicsEngine = physicsEngine; | ||
67 | m_config = configFile; | ||
68 | |||
69 | m_console = new ConsoleBase("region-console-" + Guid.NewGuid().ToString() + ".log", "Region", this, silent); | ||
70 | OpenSim.Framework.Console.MainConsole.Instance = m_console; | ||
71 | } | ||
72 | |||
73 | /// <summary> | ||
74 | /// Performs initialisation of the world, such as loading configuration from disk. | ||
75 | /// </summary> | ||
76 | public override void StartUp() | ||
77 | { | ||
78 | this.regionData = new RegionInfo(); | ||
79 | try | ||
80 | { | ||
81 | this.localConfig = new XmlConfig(m_config); | ||
82 | this.localConfig.LoadData(); | ||
83 | } | ||
84 | catch (Exception e) | ||
85 | { | ||
86 | Console.WriteLine(e.Message); | ||
87 | } | ||
88 | if (this.configFileSetup) | ||
89 | { | ||
90 | this.SetupFromConfigFile(this.localConfig); | ||
91 | } | ||
92 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Loading configuration"); | ||
93 | this.regionData.InitConfig(this.m_sandbox, this.localConfig); | ||
94 | this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change | ||
95 | |||
96 | GridServers = new Grid(); | ||
97 | if (m_sandbox) | ||
98 | { | ||
99 | this.SetupLocalGridServers(); | ||
100 | //Authenticate Session Handler | ||
101 | AuthenticateSessionsLocal authen = new AuthenticateSessionsLocal(); | ||
102 | this.AuthenticateSessionsHandler = authen; | ||
103 | this.checkServer = new CheckSumServer(12036); | ||
104 | this.checkServer.ServerListener(); | ||
105 | } | ||
106 | else | ||
107 | { | ||
108 | this.SetupRemoteGridServers(); | ||
109 | //Authenticate Session Handler | ||
110 | AuthenticateSessionsRemote authen = new AuthenticateSessionsRemote(); | ||
111 | this.AuthenticateSessionsHandler = authen; | ||
112 | } | ||
113 | |||
114 | startuptime = DateTime.Now; | ||
115 | |||
116 | try | ||
117 | { | ||
118 | AssetCache = new AssetCache(GridServers.AssetServer); | ||
119 | InventoryCache = new InventoryCache(); | ||
120 | } | ||
121 | catch (Exception e) | ||
122 | { | ||
123 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup local cache"); | ||
124 | Environment.Exit(1); | ||
125 | } | ||
126 | |||
127 | m_udpServer = new UDPServer(this.regionData.IPListenPort, this.GridServers, this.AssetCache, this.InventoryCache, this.regionData, this.m_sandbox, this.user_accounts, this.m_console, this.AuthenticateSessionsHandler); | ||
128 | |||
129 | //should be passing a IGenericConfig object to these so they can read the config data they want from it | ||
130 | GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey); | ||
131 | IGridServer gridServer = GridServers.GridServer; | ||
132 | gridServer.SetServerInfo(regionData.GridURL, regionData.GridSendKey, regionData.GridRecvKey); | ||
133 | |||
134 | if (!m_sandbox) | ||
135 | { | ||
136 | this.ConnectToRemoteGridServer(); | ||
137 | } | ||
138 | |||
139 | this.SetupLocalWorld(); | ||
140 | |||
141 | if (m_sandbox) | ||
142 | { | ||
143 | AssetCache.LoadDefaultTextureSet(); | ||
144 | } | ||
145 | |||
146 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Initialising HTTP server"); | ||
147 | |||
148 | this.SetupHttpListener(); | ||
149 | |||
150 | //Login server setup | ||
151 | LoginServer loginServer = null; | ||
152 | LoginServer adminLoginServer = null; | ||
153 | |||
154 | bool sandBoxWithLoginServer = m_loginserver && m_sandbox; | ||
155 | if (sandBoxWithLoginServer) | ||
156 | { | ||
157 | loginServer = new LoginServer(regionData.IPListenAddr, regionData.IPListenPort, regionData.RegionLocX, regionData.RegionLocY, this.user_accounts); | ||
158 | loginServer.Startup(); | ||
159 | loginServer.SetSessionHandler(((AuthenticateSessionsLocal)this.AuthenticateSessionsHandler).AddNewSession); | ||
160 | |||
161 | if (user_accounts) | ||
162 | { | ||
163 | //sandbox mode with loginserver using accounts | ||
164 | this.GridServers.UserServer = loginServer; | ||
165 | adminLoginServer = loginServer; | ||
166 | |||
167 | httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod); | ||
168 | } | ||
169 | else | ||
170 | { | ||
171 | //sandbox mode with loginserver not using accounts | ||
172 | httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod); | ||
173 | } | ||
174 | } | ||
175 | |||
176 | //Web front end setup | ||
177 | AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer); | ||
178 | adminWebFront.LoadMethods(httpServer); | ||
179 | |||
180 | //Start http server | ||
181 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting HTTP server"); | ||
182 | httpServer.Start(); | ||
183 | |||
184 | // Start UDP server | ||
185 | this.m_udpServer.ServerListener(); | ||
186 | |||
187 | m_heartbeatTimer.Enabled = true; | ||
188 | m_heartbeatTimer.Interval = 100; | ||
189 | m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat); | ||
190 | } | ||
191 | |||
192 | # region Setup methods | ||
193 | protected override void SetupLocalGridServers() | ||
194 | { | ||
195 | GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll"; | ||
196 | GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll"; | ||
197 | |||
198 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Sandbox mode"); | ||
199 | |||
200 | try | ||
201 | { | ||
202 | GridServers.Initialise(); | ||
203 | } | ||
204 | catch (Exception e) | ||
205 | { | ||
206 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface"); | ||
207 | Environment.Exit(1); | ||
208 | } | ||
209 | } | ||
210 | |||
211 | protected override void SetupRemoteGridServers() | ||
212 | { | ||
213 | if (this.gridLocalAsset) | ||
214 | { | ||
215 | GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll"; | ||
216 | } | ||
217 | else | ||
218 | { | ||
219 | GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll"; | ||
220 | } | ||
221 | GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll"; | ||
222 | |||
223 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Grid mode"); | ||
224 | |||
225 | try | ||
226 | { | ||
227 | GridServers.Initialise(); | ||
228 | } | ||
229 | catch (Exception e) | ||
230 | { | ||
231 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface"); | ||
232 | Environment.Exit(1); | ||
233 | } | ||
234 | } | ||
235 | |||
236 | protected override void SetupLocalWorld() | ||
237 | { | ||
238 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "Main.cs:Startup() - We are " + regionData.RegionName + " at " + regionData.RegionLocX.ToString() + "," + regionData.RegionLocY.ToString()); | ||
239 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Initialising world"); | ||
240 | m_console.componentname = "Region " + regionData.RegionName; | ||
241 | |||
242 | m_localWorld = new World(this.m_udpServer.PacketServer.ClientThreads, regionData, regionData.RegionHandle, regionData.RegionName); | ||
243 | LocalWorld.InventoryCache = InventoryCache; | ||
244 | LocalWorld.AssetCache = AssetCache; | ||
245 | |||
246 | this.m_udpServer.LocalWorld = LocalWorld; | ||
247 | this.m_udpServer.PacketServer.RegisterClientPacketHandlers(); | ||
248 | |||
249 | this.physManager = new OpenSim.Physics.Manager.PhysicsManager(); | ||
250 | this.physManager.LoadPlugins(); | ||
251 | |||
252 | LocalWorld.m_datastore = this.regionData.DataStore; | ||
253 | |||
254 | LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded. | ||
255 | LocalWorld.LoadWorldMap(); | ||
256 | |||
257 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting up messaging system"); | ||
258 | LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine); | ||
259 | LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.getHeights1D()); | ||
260 | LocalWorld.LoadPrimsFromStorage(); | ||
261 | } | ||
262 | |||
263 | protected override void SetupHttpListener() | ||
264 | { | ||
265 | httpServer = new BaseHttpServer(regionData.IPListenPort); | ||
266 | |||
267 | if (this.GridServers.GridServer.GetName() == "Remote") | ||
268 | { | ||
269 | |||
270 | // we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server | ||
271 | httpServer.AddXmlRPCHandler("expect_user", ((AuthenticateSessionsRemote)this.AuthenticateSessionsHandler).ExpectUser); | ||
272 | |||
273 | httpServer.AddXmlRPCHandler("agent_crossing", | ||
274 | delegate(XmlRpcRequest request) | ||
275 | { | ||
276 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
277 | uint circuitcode = Convert.ToUInt32(requestData["circuit_code"]); | ||
278 | |||
279 | AgentCircuitData agent_data = new AgentCircuitData(); | ||
280 | agent_data.firstname = (string)requestData["firstname"]; | ||
281 | agent_data.lastname = (string)requestData["lastname"]; | ||
282 | agent_data.circuitcode = circuitcode; | ||
283 | agent_data.startpos = new LLVector3(Single.Parse((string)requestData["pos_x"]), Single.Parse((string)requestData["pos_y"]), Single.Parse((string)requestData["pos_z"])); | ||
284 | |||
285 | AuthenticateSessionsHandler.UpdateAgentData(agent_data); | ||
286 | |||
287 | return new XmlRpcResponse(); | ||
288 | }); | ||
289 | |||
290 | httpServer.AddRestHandler("GET", "/simstatus/", | ||
291 | delegate(string request, string path, string param) | ||
292 | { | ||
293 | return "OK"; | ||
294 | }); | ||
295 | } | ||
296 | } | ||
297 | |||
298 | protected override void ConnectToRemoteGridServer() | ||
299 | { | ||
300 | if (GridServers.GridServer.RequestConnection(regionData.SimUUID, regionData.IPListenAddr, (uint)regionData.IPListenPort)) | ||
301 | { | ||
302 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Success: Got a grid connection OK!"); | ||
303 | } | ||
304 | else | ||
305 | { | ||
306 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, "Main.cs:Startup() - FAILED: Unable to get connection to grid. Shutting down."); | ||
307 | Shutdown(); | ||
308 | } | ||
309 | |||
310 | GridServers.AssetServer.SetServerInfo((string)((RemoteGridBase)GridServers.GridServer).GridData["asset_url"], (string)((RemoteGridBase)GridServers.GridServer).GridData["asset_sendkey"]); | ||
311 | |||
312 | // If we are being told to load a file, load it. | ||
313 | string dataUri = (string)((RemoteGridBase)GridServers.GridServer).GridData["data_uri"]; | ||
314 | |||
315 | if (!String.IsNullOrEmpty(dataUri)) | ||
316 | { | ||
317 | this.LocalWorld.m_datastore = dataUri; | ||
318 | } | ||
319 | |||
320 | if (((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString() != "") | ||
321 | { | ||
322 | // The grid server has told us who we are | ||
323 | // We must obey the grid server. | ||
324 | try | ||
325 | { | ||
326 | regionData.RegionLocX = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locx"].ToString()); | ||
327 | regionData.RegionLocY = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locy"].ToString()); | ||
328 | regionData.RegionName = ((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString(); | ||
329 | } | ||
330 | catch (Exception e) | ||
331 | { | ||
332 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, e.Message + "\nBAD ERROR! THIS SHOULD NOT HAPPEN! Bad GridData from the grid interface!!!! ZOMG!!!"); | ||
333 | Environment.Exit(1); | ||
334 | } | ||
335 | } | ||
336 | } | ||
337 | |||
338 | #endregion | ||
339 | |||
340 | private void SetupFromConfigFile(IGenericConfig configData) | ||
341 | { | ||
342 | try | ||
343 | { | ||
344 | // SandBoxMode | ||
345 | string attri = ""; | ||
346 | attri = configData.GetAttribute("SandBox"); | ||
347 | if ((attri == "") || ((attri != "false") && (attri != "true"))) | ||
348 | { | ||
349 | this.m_sandbox = false; | ||
350 | configData.SetAttribute("SandBox", "false"); | ||
351 | } | ||
352 | else | ||
353 | { | ||
354 | this.m_sandbox = Convert.ToBoolean(attri); | ||
355 | } | ||
356 | |||
357 | // LoginServer | ||
358 | attri = ""; | ||
359 | attri = configData.GetAttribute("LoginServer"); | ||
360 | if ((attri == "") || ((attri != "false") && (attri != "true"))) | ||
361 | { | ||
362 | this.m_loginserver = false; | ||
363 | configData.SetAttribute("LoginServer", "false"); | ||
364 | } | ||
365 | else | ||
366 | { | ||
367 | this.m_loginserver = Convert.ToBoolean(attri); | ||
368 | } | ||
369 | |||
370 | // Sandbox User accounts | ||
371 | attri = ""; | ||
372 | attri = configData.GetAttribute("UserAccount"); | ||
373 | if ((attri == "") || ((attri != "false") && (attri != "true"))) | ||
374 | { | ||
375 | this.user_accounts = false; | ||
376 | configData.SetAttribute("UserAccounts", "false"); | ||
377 | } | ||
378 | else if (attri == "true") | ||
379 | { | ||
380 | this.user_accounts = Convert.ToBoolean(attri); | ||
381 | } | ||
382 | |||
383 | // Grid mode hack to use local asset server | ||
384 | attri = ""; | ||
385 | attri = configData.GetAttribute("LocalAssets"); | ||
386 | if ((attri == "") || ((attri != "false") && (attri != "true"))) | ||
387 | { | ||
388 | this.gridLocalAsset = false; | ||
389 | configData.SetAttribute("LocalAssets", "false"); | ||
390 | } | ||
391 | else if (attri == "true") | ||
392 | { | ||
393 | this.gridLocalAsset = Convert.ToBoolean(attri); | ||
394 | } | ||
395 | |||
396 | |||
397 | attri = ""; | ||
398 | attri = configData.GetAttribute("PhysicsEngine"); | ||
399 | switch (attri) | ||
400 | { | ||
401 | default: | ||
402 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating"); | ||
403 | Environment.Exit(1); | ||
404 | break; | ||
405 | |||
406 | case "": | ||
407 | this.m_physicsEngine = "basicphysics"; | ||
408 | configData.SetAttribute("PhysicsEngine", "basicphysics"); | ||
409 | OpenSim.world.Avatar.PhysicsEngineFlying = false; | ||
410 | break; | ||
411 | |||
412 | case "basicphysics": | ||
413 | this.m_physicsEngine = "basicphysics"; | ||
414 | configData.SetAttribute("PhysicsEngine", "basicphysics"); | ||
415 | OpenSim.world.Avatar.PhysicsEngineFlying = false; | ||
416 | break; | ||
417 | |||
418 | case "RealPhysX": | ||
419 | this.m_physicsEngine = "RealPhysX"; | ||
420 | OpenSim.world.Avatar.PhysicsEngineFlying = true; | ||
421 | break; | ||
422 | |||
423 | case "OpenDynamicsEngine": | ||
424 | this.m_physicsEngine = "OpenDynamicsEngine"; | ||
425 | OpenSim.world.Avatar.PhysicsEngineFlying = true; | ||
426 | break; | ||
427 | } | ||
428 | |||
429 | configData.Commit(); | ||
430 | } | ||
431 | catch (Exception e) | ||
432 | { | ||
433 | Console.WriteLine(e.Message); | ||
434 | Console.WriteLine("\nSorry, a fatal error occurred while trying to initialise the configuration data"); | ||
435 | Console.WriteLine("Can not continue starting up"); | ||
436 | Environment.Exit(1); | ||
437 | } | ||
438 | } | ||
439 | |||
440 | /// <summary> | ||
441 | /// Performs any last-minute sanity checking and shuts down the region server | ||
442 | /// </summary> | ||
443 | public virtual void Shutdown() | ||
444 | { | ||
445 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Closing all threads"); | ||
446 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Killing listener thread"); | ||
447 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Killing clients"); | ||
448 | // IMPLEMENT THIS | ||
449 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Closing console and terminating"); | ||
450 | LocalWorld.Close(); | ||
451 | GridServers.Close(); | ||
452 | m_console.Close(); | ||
453 | Environment.Exit(0); | ||
454 | } | ||
455 | |||
456 | /// <summary> | ||
457 | /// Performs per-frame updates regularly | ||
458 | /// </summary> | ||
459 | /// <param name="sender"></param> | ||
460 | /// <param name="e"></param> | ||
461 | void Heartbeat(object sender, System.EventArgs e) | ||
462 | { | ||
463 | LocalWorld.Update(); | ||
464 | } | ||
465 | |||
466 | #region Console Commands | ||
467 | /// <summary> | ||
468 | /// Runs commands issued by the server console from the operator | ||
469 | /// </summary> | ||
470 | /// <param name="command">The first argument of the parameter (the command)</param> | ||
471 | /// <param name="cmdparams">Additional arguments passed to the command</param> | ||
472 | public void RunCmd(string command, string[] cmdparams) | ||
473 | { | ||
474 | switch (command) | ||
475 | { | ||
476 | case "help": | ||
477 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "show users - show info about connected users"); | ||
478 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "shutdown - disconnect all clients and shutdown"); | ||
479 | break; | ||
480 | |||
481 | case "show": | ||
482 | Show(cmdparams[0]); | ||
483 | break; | ||
484 | |||
485 | case "terrain": | ||
486 | string result = ""; | ||
487 | if (!LocalWorld.Terrain.RunTerrainCmd(cmdparams, ref result)) | ||
488 | { | ||
489 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, result); | ||
490 | } | ||
491 | break; | ||
492 | |||
493 | case "shutdown": | ||
494 | Shutdown(); | ||
495 | break; | ||
496 | |||
497 | default: | ||
498 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "Unknown command"); | ||
499 | break; | ||
500 | } | ||
501 | } | ||
502 | |||
503 | /// <summary> | ||
504 | /// Outputs to the console information about the region | ||
505 | /// </summary> | ||
506 | /// <param name="ShowWhat">What information to display (valid arguments are "uptime", "users")</param> | ||
507 | public void Show(string ShowWhat) | ||
508 | { | ||
509 | switch (ShowWhat) | ||
510 | { | ||
511 | case "uptime": | ||
512 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "OpenSim has been running since " + startuptime.ToString()); | ||
513 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "That is " + (DateTime.Now - startuptime).ToString()); | ||
514 | break; | ||
515 | case "users": | ||
516 | OpenSim.world.Avatar TempAv; | ||
517 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP")); | ||
518 | foreach (libsecondlife.LLUUID UUID in LocalWorld.Entities.Keys) | ||
519 | { | ||
520 | if (LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar") | ||
521 | { | ||
522 | TempAv = (OpenSim.world.Avatar)LocalWorld.Entities[UUID]; | ||
523 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, 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())); | ||
524 | } | ||
525 | } | ||
526 | break; | ||
527 | } | ||
528 | } | ||
529 | #endregion | ||
530 | } | ||
531 | |||
532 | |||
533 | } \ No newline at end of file | ||