aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorAdam Frisby2007-10-25 12:13:58 +0000
committerAdam Frisby2007-10-25 12:13:58 +0000
commit2048d611cf2ecccfbdb6b234c995e19d72ad03f2 (patch)
treea7cbc539a7e69cb1f8e70a094df8e26048d07375 /OpenSim
parentCreated a generic RESTClient component, which simplifies querying for resourc... (diff)
downloadopensim-SC-2048d611cf2ecccfbdb6b234c995e19d72ad03f2.zip
opensim-SC-2048d611cf2ecccfbdb6b234c995e19d72ad03f2.tar.gz
opensim-SC-2048d611cf2ecccfbdb6b234c995e19d72ad03f2.tar.bz2
opensim-SC-2048d611cf2ecccfbdb6b234c995e19d72ad03f2.tar.xz
* Added XMLRPC Controller Module to OpenSimMain which allows XML-RPC queries to be sent to the core application.
* Disabled by default, but has two functions so far -- shutdown (timed or now), and create-region. * Added SendGeneralAlert function to SceneManager allowing all-user alerts to be sent from OpenSimMain.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Application/OpenSimController.cs132
-rw-r--r--OpenSim/Region/Application/OpenSimMain.cs3
-rw-r--r--OpenSim/Region/ClientStack/RegionApplicationBase.cs5
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs1
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneManager.cs8
5 files changed, 148 insertions, 1 deletions
diff --git a/OpenSim/Region/Application/OpenSimController.cs b/OpenSim/Region/Application/OpenSimController.cs
new file mode 100644
index 0000000..14e4a4c
--- /dev/null
+++ b/OpenSim/Region/Application/OpenSimController.cs
@@ -0,0 +1,132 @@
1using System;
2using System.Collections.Generic;
3using System.Collections;
4using System.IO;
5using System.Text;
6using Nini.Config;
7using OpenSim.Framework.Communications.Cache;
8using OpenSim.Framework.Console;
9using OpenSim.Framework.Interfaces;
10using OpenSim.Framework.Servers;
11using OpenSim.Framework.Types;
12using OpenSim.Framework.Utilities;
13using OpenSim.Region.ClientStack;
14using OpenSim.Region.Communications.Local;
15using OpenSim.Region.Communications.OGS1;
16using OpenSim.Region.Environment;
17using OpenSim.Region.Environment.Scenes;
18using OpenSim.Region.Physics.Manager;
19using System.Globalization;
20using Nwc.XmlRpc;
21using RegionInfo = OpenSim.Framework.Types.RegionInfo;
22
23namespace OpenSim
24{
25 class OpenSimController
26 {
27 private OpenSimMain m_app;
28 private BaseHttpServer m_httpServer;
29 private const bool m_enablexmlrpc = false;
30
31 public OpenSimController(OpenSimMain core, BaseHttpServer httpd)
32 {
33 m_app = core;
34 m_httpServer = httpd;
35
36 if (m_enablexmlrpc)
37 {
38 m_httpServer.AddXmlRPCHandler("admin_create_region", XmlRpcCreateRegionMethod);
39 m_httpServer.AddXmlRPCHandler("admin_shutdown", XmlRpcShutdownMethod);
40 }
41 }
42
43 public XmlRpcResponse XmlRpcShutdownMethod(XmlRpcRequest request)
44 {
45 MainLog.Instance.Verbose("CONTROLLER", "Recieved Shutdown Administrator Request");
46 XmlRpcResponse response = new XmlRpcResponse();
47 Hashtable requestData = (Hashtable)request.Params[0];
48
49 if ((string)requestData["shutdown"] == "delayed")
50 {
51 int timeout = Convert.ToInt32((string)requestData["milliseconds"]);
52
53 Hashtable responseData = new Hashtable();
54 responseData["accepted"] = "true";
55 response.Value = responseData;
56
57 m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((int)(timeout / 1000)).ToString() + " second(s). Please save what you are doing and log out.");
58
59 // Perform shutdown
60 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing
61 shutdownTimer.AutoReset = false;
62 shutdownTimer.Elapsed += new System.Timers.ElapsedEventHandler(shutdownTimer_Elapsed);
63
64 return response;
65 }
66 else
67 {
68 Hashtable responseData = new Hashtable();
69 responseData["accepted"] = "true";
70 response.Value = responseData;
71
72 m_app.SceneManager.SendGeneralMessage("Region is going down now.");
73
74 // Perform shutdown
75 System.Timers.Timer shutdownTimer = new System.Timers.Timer(2000); // Wait 2 seconds before firing
76 shutdownTimer.AutoReset = false;
77 shutdownTimer.Elapsed += new System.Timers.ElapsedEventHandler(shutdownTimer_Elapsed);
78
79 return response;
80 }
81 }
82
83 void shutdownTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
84 {
85 m_app.Shutdown();
86 }
87
88 public XmlRpcResponse XmlRpcCreateRegionMethod(XmlRpcRequest request)
89 {
90 MainLog.Instance.Verbose("CONTROLLER", "Recieved Create Region Administrator Request");
91 XmlRpcResponse response = new XmlRpcResponse();
92 Hashtable requestData = (Hashtable)request.Params[0];
93
94 RegionInfo newRegionData = new RegionInfo();
95
96 try
97 {
98 newRegionData.RegionID = (string)requestData["region_id"];
99 newRegionData.RegionName = (string)requestData["region_name"];
100 newRegionData.RegionLocX = Convert.ToUInt32((string)requestData["region_x"]);
101 newRegionData.RegionLocY = Convert.ToUInt32((string)requestData["region_y"]);
102
103 // Security risk
104 newRegionData.DataStore = (string)requestData["datastore"];
105
106 newRegionData.InternalEndPoint = new System.Net.IPEndPoint(
107 System.Net.IPAddress.Parse((string)requestData["listen_ip"]), 0);
108
109 newRegionData.InternalEndPoint.Port = Convert.ToInt32((string)requestData["listen_port"]);
110 newRegionData.ExternalHostName = (string)requestData["external_address"];
111
112 newRegionData.MasterAvatarFirstName = (string)requestData["region_master_first"];
113 newRegionData.MasterAvatarLastName = (string)requestData["region_master_last"];
114
115 m_app.CreateRegion(newRegionData);
116
117 Hashtable responseData = new Hashtable();
118 responseData["created"] = "true";
119 response.Value = responseData;
120 }
121 catch (Exception e)
122 {
123 Hashtable responseData = new Hashtable();
124 responseData["created"] = "false";
125 responseData["error"] = e.ToString();
126 response.Value = responseData;
127 }
128
129 return response;
130 }
131 }
132}
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index 84c8bff..a345334 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -60,6 +60,7 @@ namespace OpenSim
60 public bool user_accounts; 60 public bool user_accounts;
61 public bool m_gridLocalAsset; 61 public bool m_gridLocalAsset;
62 62
63 private OpenSimController m_controller;
63 64
64 protected ModuleLoader m_moduleLoader; 65 protected ModuleLoader m_moduleLoader;
65 protected LocalLoginService m_loginService; 66 protected LocalLoginService m_loginService;
@@ -162,6 +163,8 @@ namespace OpenSim
162 163
163 base.StartUp(); 164 base.StartUp();
164 165
166 m_controller = new OpenSimController(this, m_httpServer);
167
165 if (m_sandbox) 168 if (m_sandbox)
166 { 169 {
167 LocalInventoryService inventoryService = new LocalInventoryService(); 170 LocalInventoryService inventoryService = new LocalInventoryService();
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
index 62e2afd..bab5d16 100644
--- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -57,6 +57,11 @@ namespace OpenSim.Region.ClientStack
57 57
58 protected SceneManager m_sceneManager = new SceneManager(); 58 protected SceneManager m_sceneManager = new SceneManager();
59 59
60 public SceneManager SceneManager
61 {
62 get { return m_sceneManager; }
63 }
64
60 public RegionApplicationBase() 65 public RegionApplicationBase()
61 { 66 {
62 m_startuptime = DateTime.Now; 67 m_startuptime = DateTime.Now;
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 84eb503..d7c1759 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -1319,7 +1319,6 @@ namespace OpenSim.Region.Environment.Scenes
1319 SendAlertToUser(user, reason, false); 1319 SendAlertToUser(user, reason, false);
1320 } 1320 }
1321 1321
1322
1323 public void SendGeneralAlert(string message) 1322 public void SendGeneralAlert(string message)
1324 { 1323 {
1325 foreach (ScenePresence presence in m_scenePresences.Values) 1324 foreach (ScenePresence presence in m_scenePresences.Values)
diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs
index 3fe9479..7db6927 100644
--- a/OpenSim/Region/Environment/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs
@@ -150,6 +150,14 @@ namespace OpenSim.Region.Environment.Scenes
150 ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); }); 150 ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); });
151 } 151 }
152 152
153 public void SendGeneralMessage(string msg)
154 {
155 ForEachCurrentScene(delegate(Scene scene)
156 {
157 scene.SendGeneralAlert(msg);
158 });
159 }
160
153 public bool TrySetCurrentScene(string regionName) 161 public bool TrySetCurrentScene(string regionName)
154 { 162 {
155 if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0)) 163 if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0))