diff options
author | MW | 2007-05-26 13:40:19 +0000 |
---|---|---|
committer | MW | 2007-05-26 13:40:19 +0000 |
commit | 3436961bb5c01d659d09be134368f4f69460cef9 (patch) | |
tree | 3753ba4d7818df2a6bce0bbe863ff033cdfd568a /OpenSim/OpenSim.RegionServer/OpenSimMain.cs | |
download | opensim-SC_OLD-3436961bb5c01d659d09be134368f4f69460cef9.zip opensim-SC_OLD-3436961bb5c01d659d09be134368f4f69460cef9.tar.gz opensim-SC_OLD-3436961bb5c01d659d09be134368f4f69460cef9.tar.bz2 opensim-SC_OLD-3436961bb5c01d659d09be134368f4f69460cef9.tar.xz |
Start of rewrite 5279!
Diffstat (limited to 'OpenSim/OpenSim.RegionServer/OpenSimMain.cs')
-rw-r--r-- | OpenSim/OpenSim.RegionServer/OpenSimMain.cs | 531 |
1 files changed, 531 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim/OpenSim.RegionServer/OpenSimMain.cs new file mode 100644 index 0000000..003412d --- /dev/null +++ b/OpenSim/OpenSim.RegionServer/OpenSimMain.cs | |||
@@ -0,0 +1,531 @@ | |||
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 | //moved to the opensim main application project (do we want it there or here?) | ||
57 | /* | ||
58 | public class OpenSimMain : OpenSimApplicationBase , conscmd_callback | ||
59 | { | ||
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 | } | ||
104 | else | ||
105 | { | ||
106 | this.SetupRemoteGridServers(); | ||
107 | //Authenticate Session Handler | ||
108 | AuthenticateSessionsRemote authen = new AuthenticateSessionsRemote(); | ||
109 | this.AuthenticateSessionsHandler = authen; | ||
110 | } | ||
111 | |||
112 | startuptime = DateTime.Now; | ||
113 | |||
114 | try | ||
115 | { | ||
116 | AssetCache = new AssetCache(GridServers.AssetServer); | ||
117 | InventoryCache = new InventoryCache(); | ||
118 | } | ||
119 | catch (Exception e) | ||
120 | { | ||
121 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup local cache"); | ||
122 | Environment.Exit(1); | ||
123 | } | ||
124 | |||
125 | 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); | ||
126 | |||
127 | //should be passing a IGenericConfig object to these so they can read the config data they want from it | ||
128 | GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey); | ||
129 | IGridServer gridServer = GridServers.GridServer; | ||
130 | gridServer.SetServerInfo(regionData.GridURL, regionData.GridSendKey, regionData.GridRecvKey); | ||
131 | |||
132 | if (!m_sandbox) | ||
133 | { | ||
134 | this.ConnectToRemoteGridServer(); | ||
135 | } | ||
136 | |||
137 | this.SetupLocalWorld(); | ||
138 | |||
139 | if (m_sandbox) | ||
140 | { | ||
141 | AssetCache.LoadDefaultTextureSet(); | ||
142 | } | ||
143 | |||
144 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Initialising HTTP server"); | ||
145 | |||
146 | this.SetupHttpListener(); | ||
147 | |||
148 | LoginServer loginServer = null; | ||
149 | LoginServer adminLoginServer = null; | ||
150 | |||
151 | bool sandBoxWithLoginServer = m_loginserver && m_sandbox; | ||
152 | if (sandBoxWithLoginServer) | ||
153 | { | ||
154 | loginServer = new LoginServer( regionData.IPListenAddr, regionData.IPListenPort, regionData.RegionLocX, regionData.RegionLocY, this.user_accounts); | ||
155 | loginServer.Startup(); | ||
156 | loginServer.SetSessionHandler(((AuthenticateSessionsLocal) this.AuthenticateSessionsHandler).AddNewSession); | ||
157 | |||
158 | if (user_accounts) | ||
159 | { | ||
160 | //sandbox mode with loginserver using accounts | ||
161 | this.GridServers.UserServer = loginServer; | ||
162 | adminLoginServer = loginServer; | ||
163 | |||
164 | httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod); | ||
165 | } | ||
166 | else | ||
167 | { | ||
168 | //sandbox mode with loginserver not using accounts | ||
169 | httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer); | ||
174 | adminWebFront.LoadMethods(httpServer); | ||
175 | |||
176 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting HTTP server"); | ||
177 | httpServer.Start(); | ||
178 | |||
179 | //MainServerListener(); | ||
180 | this.m_udpServer.ServerListener(); | ||
181 | |||
182 | m_heartbeatTimer.Enabled = true; | ||
183 | m_heartbeatTimer.Interval = 100; | ||
184 | m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat); | ||
185 | } | ||
186 | |||
187 | # region Setup methods | ||
188 | protected virtual void SetupLocalGridServers() | ||
189 | { | ||
190 | GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll"; | ||
191 | GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll"; | ||
192 | |||
193 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Sandbox mode"); | ||
194 | |||
195 | try | ||
196 | { | ||
197 | GridServers.Initialise(); | ||
198 | } | ||
199 | catch (Exception e) | ||
200 | { | ||
201 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface"); | ||
202 | Environment.Exit(1); | ||
203 | } | ||
204 | } | ||
205 | |||
206 | protected virtual void SetupRemoteGridServers() | ||
207 | { | ||
208 | if (this.gridLocalAsset) | ||
209 | { | ||
210 | GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll"; | ||
211 | } | ||
212 | else | ||
213 | { | ||
214 | GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll"; | ||
215 | } | ||
216 | GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll"; | ||
217 | |||
218 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Grid mode"); | ||
219 | |||
220 | try | ||
221 | { | ||
222 | GridServers.Initialise(); | ||
223 | } | ||
224 | catch (Exception e) | ||
225 | { | ||
226 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface"); | ||
227 | Environment.Exit(1); | ||
228 | } | ||
229 | } | ||
230 | |||
231 | protected virtual void SetupLocalWorld() | ||
232 | { | ||
233 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "Main.cs:Startup() - We are " + regionData.RegionName + " at " + regionData.RegionLocX.ToString() + "," + regionData.RegionLocY.ToString()); | ||
234 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Initialising world"); | ||
235 | m_console.componentname = "Region " + regionData.RegionName; | ||
236 | |||
237 | m_localWorld = new World(this.m_udpServer.PacketServer.ClientThreads, regionData, regionData.RegionHandle, regionData.RegionName); | ||
238 | LocalWorld.InventoryCache = InventoryCache; | ||
239 | LocalWorld.AssetCache = AssetCache; | ||
240 | |||
241 | this.m_udpServer.LocalWorld = LocalWorld; | ||
242 | this.m_udpServer.PacketServer.RegisterClientPacketHandlers(); | ||
243 | |||
244 | this.physManager = new OpenSim.Physics.Manager.PhysicsManager(); | ||
245 | this.physManager.LoadPlugins(); | ||
246 | |||
247 | LocalWorld.m_datastore = this.regionData.DataStore; | ||
248 | |||
249 | LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded. | ||
250 | LocalWorld.LoadWorldMap(); | ||
251 | |||
252 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting up messaging system"); | ||
253 | LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine); | ||
254 | LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.getHeights1D()); | ||
255 | LocalWorld.LoadPrimsFromStorage(); | ||
256 | } | ||
257 | |||
258 | protected virtual void SetupHttpListener() | ||
259 | { | ||
260 | httpServer = new BaseHttpServer(regionData.IPListenPort); | ||
261 | |||
262 | if (this.GridServers.GridServer.GetName() == "Remote") | ||
263 | { | ||
264 | |||
265 | // we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server | ||
266 | httpServer.AddXmlRPCHandler("expect_user", ((AuthenticateSessionsRemote)this.AuthenticateSessionsHandler).ExpectUser ); | ||
267 | |||
268 | httpServer.AddXmlRPCHandler("agent_crossing", | ||
269 | delegate(XmlRpcRequest request) | ||
270 | { | ||
271 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
272 | AgentCircuitData agent_data = new AgentCircuitData(); | ||
273 | agent_data.firstname = (string)requestData["firstname"]; | ||
274 | agent_data.lastname = (string)requestData["lastname"]; | ||
275 | agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); | ||
276 | agent_data.startpos = new LLVector3(Single.Parse((string)requestData["pos_x"]), Single.Parse((string)requestData["pos_y"]), Single.Parse((string)requestData["pos_z"])); | ||
277 | |||
278 | if (((RemoteGridBase)this.GridServers.GridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode)) | ||
279 | { | ||
280 | ((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].firstname = agent_data.firstname; | ||
281 | ((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].lastname = agent_data.lastname; | ||
282 | ((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].startpos = agent_data.startpos; | ||
283 | } | ||
284 | |||
285 | return new XmlRpcResponse(); | ||
286 | }); | ||
287 | |||
288 | httpServer.AddRestHandler("GET", "/simstatus/", | ||
289 | delegate(string request, string path, string param) | ||
290 | { | ||
291 | return "OK"; | ||
292 | }); | ||
293 | } | ||
294 | } | ||
295 | |||
296 | protected virtual void ConnectToRemoteGridServer() | ||
297 | { | ||
298 | if (GridServers.GridServer.RequestConnection(regionData.SimUUID, regionData.IPListenAddr, (uint)regionData.IPListenPort)) | ||
299 | { | ||
300 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Success: Got a grid connection OK!"); | ||
301 | } | ||
302 | else | ||
303 | { | ||
304 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, "Main.cs:Startup() - FAILED: Unable to get connection to grid. Shutting down."); | ||
305 | Shutdown(); | ||
306 | } | ||
307 | |||
308 | GridServers.AssetServer.SetServerInfo((string)((RemoteGridBase)GridServers.GridServer).GridData["asset_url"], (string)((RemoteGridBase)GridServers.GridServer).GridData["asset_sendkey"]); | ||
309 | |||
310 | // If we are being told to load a file, load it. | ||
311 | string dataUri = (string)((RemoteGridBase)GridServers.GridServer).GridData["data_uri"]; | ||
312 | |||
313 | if (!String.IsNullOrEmpty(dataUri)) | ||
314 | { | ||
315 | this.LocalWorld.m_datastore = dataUri; | ||
316 | } | ||
317 | |||
318 | if (((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString() != "") | ||
319 | { | ||
320 | // The grid server has told us who we are | ||
321 | // We must obey the grid server. | ||
322 | try | ||
323 | { | ||
324 | regionData.RegionLocX = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locx"].ToString()); | ||
325 | regionData.RegionLocY = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locy"].ToString()); | ||
326 | regionData.RegionName = ((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString(); | ||
327 | } | ||
328 | catch (Exception e) | ||
329 | { | ||
330 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, e.Message + "\nBAD ERROR! THIS SHOULD NOT HAPPEN! Bad GridData from the grid interface!!!! ZOMG!!!"); | ||
331 | Environment.Exit(1); | ||
332 | } | ||
333 | } | ||
334 | } | ||
335 | |||
336 | #endregion | ||
337 | |||
338 | private void SetupFromConfigFile(IGenericConfig configData) | ||
339 | { | ||
340 | try | ||
341 | { | ||
342 | // SandBoxMode | ||
343 | string attri = ""; | ||
344 | attri = configData.GetAttribute("SandBox"); | ||
345 | if ((attri == "") || ((attri != "false") && (attri != "true"))) | ||
346 | { | ||
347 | this.m_sandbox = false; | ||
348 | configData.SetAttribute("SandBox", "false"); | ||
349 | } | ||
350 | else | ||
351 | { | ||
352 | this.m_sandbox = Convert.ToBoolean(attri); | ||
353 | } | ||
354 | |||
355 | // LoginServer | ||
356 | attri = ""; | ||
357 | attri = configData.GetAttribute("LoginServer"); | ||
358 | if ((attri == "") || ((attri != "false") && (attri != "true"))) | ||
359 | { | ||
360 | this.m_loginserver = false; | ||
361 | configData.SetAttribute("LoginServer", "false"); | ||
362 | } | ||
363 | else | ||
364 | { | ||
365 | this.m_loginserver = Convert.ToBoolean(attri); | ||
366 | } | ||
367 | |||
368 | // Sandbox User accounts | ||
369 | attri = ""; | ||
370 | attri = configData.GetAttribute("UserAccount"); | ||
371 | if ((attri == "") || ((attri != "false") && (attri != "true"))) | ||
372 | { | ||
373 | this.user_accounts = false; | ||
374 | configData.SetAttribute("UserAccounts", "false"); | ||
375 | } | ||
376 | else if (attri == "true") | ||
377 | { | ||
378 | this.user_accounts = Convert.ToBoolean(attri); | ||
379 | } | ||
380 | |||
381 | // Grid mode hack to use local asset server | ||
382 | attri = ""; | ||
383 | attri = configData.GetAttribute("LocalAssets"); | ||
384 | if ((attri == "") || ((attri != "false") && (attri != "true"))) | ||
385 | { | ||
386 | this.gridLocalAsset = false; | ||
387 | configData.SetAttribute("LocalAssets", "false"); | ||
388 | } | ||
389 | else if (attri == "true") | ||
390 | { | ||
391 | this.gridLocalAsset = Convert.ToBoolean(attri); | ||
392 | } | ||
393 | |||
394 | |||
395 | attri = ""; | ||
396 | attri = configData.GetAttribute("PhysicsEngine"); | ||
397 | switch (attri) | ||
398 | { | ||
399 | default: | ||
400 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating"); | ||
401 | Environment.Exit(1); | ||
402 | break; | ||
403 | |||
404 | case "": | ||
405 | this.m_physicsEngine = "basicphysics"; | ||
406 | configData.SetAttribute("PhysicsEngine", "basicphysics"); | ||
407 | OpenSim.world.Avatar.PhysicsEngineFlying = false; | ||
408 | break; | ||
409 | |||
410 | case "basicphysics": | ||
411 | this.m_physicsEngine = "basicphysics"; | ||
412 | configData.SetAttribute("PhysicsEngine", "basicphysics"); | ||
413 | OpenSim.world.Avatar.PhysicsEngineFlying = false; | ||
414 | break; | ||
415 | |||
416 | case "RealPhysX": | ||
417 | this.m_physicsEngine = "RealPhysX"; | ||
418 | OpenSim.world.Avatar.PhysicsEngineFlying = true; | ||
419 | break; | ||
420 | |||
421 | case "OpenDynamicsEngine": | ||
422 | this.m_physicsEngine = "OpenDynamicsEngine"; | ||
423 | OpenSim.world.Avatar.PhysicsEngineFlying = true; | ||
424 | break; | ||
425 | } | ||
426 | |||
427 | configData.Commit(); | ||
428 | } | ||
429 | catch (Exception e) | ||
430 | { | ||
431 | Console.WriteLine(e.Message); | ||
432 | Console.WriteLine("\nSorry, a fatal error occurred while trying to initialise the configuration data"); | ||
433 | Console.WriteLine("Can not continue starting up"); | ||
434 | Environment.Exit(1); | ||
435 | } | ||
436 | } | ||
437 | |||
438 | /// <summary> | ||
439 | /// Performs any last-minute sanity checking and shuts down the region server | ||
440 | /// </summary> | ||
441 | public virtual void Shutdown() | ||
442 | { | ||
443 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Closing all threads"); | ||
444 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Killing listener thread"); | ||
445 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Killing clients"); | ||
446 | // IMPLEMENT THIS | ||
447 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Closing console and terminating"); | ||
448 | LocalWorld.Close(); | ||
449 | GridServers.Close(); | ||
450 | m_console.Close(); | ||
451 | Environment.Exit(0); | ||
452 | } | ||
453 | |||
454 | /// <summary> | ||
455 | /// Performs per-frame updates regularly | ||
456 | /// </summary> | ||
457 | /// <param name="sender"></param> | ||
458 | /// <param name="e"></param> | ||
459 | void Heartbeat(object sender, System.EventArgs e) | ||
460 | { | ||
461 | LocalWorld.Update(); | ||
462 | } | ||
463 | |||
464 | #region Console Commands | ||
465 | /// <summary> | ||
466 | /// Runs commands issued by the server console from the operator | ||
467 | /// </summary> | ||
468 | /// <param name="command">The first argument of the parameter (the command)</param> | ||
469 | /// <param name="cmdparams">Additional arguments passed to the command</param> | ||
470 | public void RunCmd(string command, string[] cmdparams) | ||
471 | { | ||
472 | switch (command) | ||
473 | { | ||
474 | case "help": | ||
475 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "show users - show info about connected users"); | ||
476 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "shutdown - disconnect all clients and shutdown"); | ||
477 | break; | ||
478 | |||
479 | case "show": | ||
480 | Show(cmdparams[0]); | ||
481 | break; | ||
482 | |||
483 | case "terrain": | ||
484 | string result = ""; | ||
485 | if (!LocalWorld.Terrain.RunTerrainCmd(cmdparams, ref result)) | ||
486 | { | ||
487 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, result); | ||
488 | } | ||
489 | break; | ||
490 | |||
491 | case "shutdown": | ||
492 | Shutdown(); | ||
493 | break; | ||
494 | |||
495 | default: | ||
496 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "Unknown command"); | ||
497 | break; | ||
498 | } | ||
499 | } | ||
500 | |||
501 | /// <summary> | ||
502 | /// Outputs to the console information about the region | ||
503 | /// </summary> | ||
504 | /// <param name="ShowWhat">What information to display (valid arguments are "uptime", "users")</param> | ||
505 | public void Show(string ShowWhat) | ||
506 | { | ||
507 | switch (ShowWhat) | ||
508 | { | ||
509 | case "uptime": | ||
510 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "OpenSim has been running since " + startuptime.ToString()); | ||
511 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "That is " + (DateTime.Now - startuptime).ToString()); | ||
512 | break; | ||
513 | case "users": | ||
514 | OpenSim.world.Avatar TempAv; | ||
515 | 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")); | ||
516 | foreach (libsecondlife.LLUUID UUID in LocalWorld.Entities.Keys) | ||
517 | { | ||
518 | if (LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar") | ||
519 | { | ||
520 | TempAv = (OpenSim.world.Avatar)LocalWorld.Entities[UUID]; | ||
521 | 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())); | ||
522 | } | ||
523 | } | ||
524 | break; | ||
525 | } | ||
526 | } | ||
527 | #endregion | ||
528 | } | ||
529 | |||
530 | */ | ||
531 | } | ||