aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application/OpenSimController.cs
diff options
context:
space:
mode:
authorAdam Frisby2007-12-03 07:06:46 +0000
committerAdam Frisby2007-12-03 07:06:46 +0000
commit981c97502a25c12473328e332bb0505f8c779d73 (patch)
treef60cf6bfad1350ab5f64dbb68bd2720ed74e20a0 /OpenSim/Region/Application/OpenSimController.cs
parent* Applied a few commits left on my laptop to OpenSimController. (diff)
downloadopensim-SC-981c97502a25c12473328e332bb0505f8c779d73.zip
opensim-SC-981c97502a25c12473328e332bb0505f8c779d73.tar.gz
opensim-SC-981c97502a25c12473328e332bb0505f8c779d73.tar.bz2
opensim-SC-981c97502a25c12473328e332bb0505f8c779d73.tar.xz
* Moved XMLRPC Controller to a Application Plugin. Requires testing.
Diffstat (limited to 'OpenSim/Region/Application/OpenSimController.cs')
-rw-r--r--OpenSim/Region/Application/OpenSimController.cs122
1 files changed, 0 insertions, 122 deletions
diff --git a/OpenSim/Region/Application/OpenSimController.cs b/OpenSim/Region/Application/OpenSimController.cs
deleted file mode 100644
index 9fae426..0000000
--- a/OpenSim/Region/Application/OpenSimController.cs
+++ /dev/null
@@ -1,122 +0,0 @@
1using System;
2using System.Collections;
3using System.Net;
4using System.Timers;
5using Nwc.XmlRpc;
6using OpenSim.Framework;
7using OpenSim.Framework.Console;
8using OpenSim.Framework.Servers;
9
10namespace OpenSim
11{
12 internal class OpenSimController
13 {
14 private OpenSimMain m_app;
15 private BaseHttpServer m_httpServer;
16 private const bool m_enablexmlrpc = true;
17
18 public OpenSimController(OpenSimMain core, BaseHttpServer httpd)
19 {
20 m_app = core;
21 m_httpServer = httpd;
22
23 if (m_enablexmlrpc)
24 {
25 m_httpServer.AddXmlRPCHandler("admin_create_region", XmlRpcCreateRegionMethod);
26 m_httpServer.AddXmlRPCHandler("admin_shutdown", XmlRpcShutdownMethod);
27 }
28 }
29
30 public XmlRpcResponse XmlRpcShutdownMethod(XmlRpcRequest request)
31 {
32 MainLog.Instance.Verbose("CONTROLLER", "Recieved Shutdown Administrator Request");
33 XmlRpcResponse response = new XmlRpcResponse();
34 Hashtable requestData = (Hashtable) request.Params[0];
35
36 if ((string) requestData["shutdown"] == "delayed")
37 {
38 int timeout = (Int32)requestData["milliseconds"];
39
40 Hashtable responseData = new Hashtable();
41 responseData["accepted"] = "true";
42 response.Value = responseData;
43
44 m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((int) (timeout/1000)).ToString() +
45 " second(s). Please save what you are doing and log out.");
46
47 // Perform shutdown
48 Timer shutdownTimer = new Timer(timeout); // Wait before firing
49 shutdownTimer.AutoReset = false;
50 shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed);
51 shutdownTimer.Start();
52
53 return response;
54 }
55 else
56 {
57 Hashtable responseData = new Hashtable();
58 responseData["accepted"] = "true";
59 response.Value = responseData;
60
61 m_app.SceneManager.SendGeneralMessage("Region is going down now.");
62
63 // Perform shutdown
64 Timer shutdownTimer = new Timer(2000); // Wait 2 seconds before firing
65 shutdownTimer.AutoReset = false;
66 shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed);
67 shutdownTimer.Start();
68
69 return response;
70 }
71 }
72
73 private void shutdownTimer_Elapsed(object sender, ElapsedEventArgs e)
74 {
75 m_app.Shutdown();
76 }
77
78 public XmlRpcResponse XmlRpcCreateRegionMethod(XmlRpcRequest request)
79 {
80 MainLog.Instance.Verbose("CONTROLLER", "Recieved Create Region Administrator Request");
81 XmlRpcResponse response = new XmlRpcResponse();
82 Hashtable requestData = (Hashtable) request.Params[0];
83
84 RegionInfo newRegionData = new RegionInfo();
85
86 try
87 {
88 newRegionData.RegionID = (string)requestData["region_id"];
89 newRegionData.RegionName = (string)requestData["region_name"];
90 newRegionData.RegionLocX = Convert.ToUInt32((Int32)requestData["region_x"]);
91 newRegionData.RegionLocY = Convert.ToUInt32((Int32)requestData["region_y"]);
92
93 // Security risk
94 newRegionData.DataStore = (string) requestData["datastore"];
95
96 newRegionData.InternalEndPoint = new IPEndPoint(
97 IPAddress.Parse((string) requestData["listen_ip"]), 0);
98
99 newRegionData.InternalEndPoint.Port = (Int32)requestData["listen_port"];
100 newRegionData.ExternalHostName = (string)requestData["external_address"];
101
102 newRegionData.MasterAvatarFirstName = (string) requestData["region_master_first"];
103 newRegionData.MasterAvatarLastName = (string) requestData["region_master_last"];
104
105 m_app.CreateRegion(newRegionData);
106
107 Hashtable responseData = new Hashtable();
108 responseData["created"] = "true";
109 response.Value = responseData;
110 }
111 catch (Exception e)
112 {
113 Hashtable responseData = new Hashtable();
114 responseData["created"] = "false";
115 responseData["error"] = e.ToString();
116 response.Value = responseData;
117 }
118
119 return response;
120 }
121 }
122}