diff options
-rw-r--r-- | OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs b/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs new file mode 100644 index 0000000..98710c6 --- /dev/null +++ b/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs | |||
@@ -0,0 +1,102 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Net; | ||
5 | using System.Reflection; | ||
6 | using System.Text; | ||
7 | using log4net; | ||
8 | using Nini.Config; | ||
9 | using Nwc.XmlRpc; | ||
10 | using OpenSim.Framework.Communications; | ||
11 | using OpenSim.Region.Framework.Interfaces; | ||
12 | using OpenSim.Region.Framework.Scenes; | ||
13 | |||
14 | namespace OpenSim.Region.CoreModules.InterGrid | ||
15 | { | ||
16 | public class OGSRadmin : ISharedRegionModule | ||
17 | { | ||
18 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
19 | private readonly List<Scene> m_scenes = new List<Scene>(); | ||
20 | private CommunicationsManager m_com; | ||
21 | private IConfigSource m_settings; | ||
22 | |||
23 | #region Implementation of IRegionModuleBase | ||
24 | |||
25 | public string Name | ||
26 | { | ||
27 | get { return "OGS Supporting RAdmin"; } | ||
28 | } | ||
29 | |||
30 | public void Initialise(IConfigSource source) | ||
31 | { | ||
32 | m_settings = source; | ||
33 | } | ||
34 | |||
35 | public void Close() | ||
36 | { | ||
37 | |||
38 | } | ||
39 | |||
40 | public void AddRegion(Scene scene) | ||
41 | { | ||
42 | lock(m_scenes) | ||
43 | m_scenes.Add(scene); | ||
44 | } | ||
45 | |||
46 | public void RemoveRegion(Scene scene) | ||
47 | { | ||
48 | lock (m_scenes) | ||
49 | m_scenes.Remove(scene); | ||
50 | } | ||
51 | |||
52 | public void RegionLoaded(Scene scene) | ||
53 | { | ||
54 | |||
55 | } | ||
56 | |||
57 | public void PostInitialise() | ||
58 | { | ||
59 | if (m_settings.Configs["Startup"].GetBoolean("gridmode", false)) | ||
60 | { | ||
61 | m_com = m_scenes[0].CommsManager; | ||
62 | m_com.HttpServer.AddXmlRPCHandler("grid_message", GridWideMessage); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | #endregion | ||
67 | |||
68 | public XmlRpcResponse GridWideMessage(XmlRpcRequest req, IPEndPoint remoteClient) | ||
69 | { | ||
70 | XmlRpcResponse response = new XmlRpcResponse(); | ||
71 | Hashtable responseData = new Hashtable(); | ||
72 | |||
73 | Hashtable requestData = (Hashtable)req.Params[0]; | ||
74 | |||
75 | if ((!requestData.Contains("password") || (string)requestData["password"] != m_com.NetworkServersInfo.GridRecvKey)) | ||
76 | { | ||
77 | responseData["accepted"] = false; | ||
78 | responseData["success"] = false; | ||
79 | responseData["error"] = "Invalid Key"; | ||
80 | response.Value = responseData; | ||
81 | return response; | ||
82 | } | ||
83 | |||
84 | string message = (string)requestData["message"]; | ||
85 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); | ||
86 | |||
87 | lock(m_scenes) | ||
88 | foreach (Scene scene in m_scenes) | ||
89 | { | ||
90 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
91 | if (dialogModule != null) | ||
92 | dialogModule.SendGeneralAlert(message); | ||
93 | } | ||
94 | |||
95 | responseData["accepted"] = true; | ||
96 | responseData["success"] = true; | ||
97 | response.Value = responseData; | ||
98 | |||
99 | return response; | ||
100 | } | ||
101 | } | ||
102 | } | ||