aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules
diff options
context:
space:
mode:
authorBlueWall2011-05-28 11:11:01 -0400
committerBlueWall2011-05-28 16:20:10 -0400
commitc7e18f9017302991f7a4411293ef2fbb20cc9b5a (patch)
tree79f3058a7f7b30e0e70257478715015539ffbdf1 /OpenSim/Region/OptionalModules
parentAdd option to disable logins (diff)
downloadopensim-SC_OLD-c7e18f9017302991f7a4411293ef2fbb20cc9b5a.zip
opensim-SC_OLD-c7e18f9017302991f7a4411293ef2fbb20cc9b5a.tar.gz
opensim-SC_OLD-c7e18f9017302991f7a4411293ef2fbb20cc9b5a.tar.bz2
opensim-SC_OLD-c7e18f9017302991f7a4411293ef2fbb20cc9b5a.tar.xz
Adding an event to signal that logins are enabled
Added an event to signal the eabling of logins and added an alert to send to a configured service.
Diffstat (limited to 'OpenSim/Region/OptionalModules')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs87
1 files changed, 76 insertions, 11 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
index c59c88c..eed6450 100644
--- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Net; 31using System.Net;
32using System.IO; 32using System.IO;
33using System.Text;
33 34
34using log4net; 35using log4net;
35using Nini.Config; 36using Nini.Config;
@@ -54,6 +55,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
54 private int m_channelNotify = -1000; 55 private int m_channelNotify = -1000;
55 private bool m_enabled = false; 56 private bool m_enabled = false;
56 private bool m_disable_logins = false; 57 private bool m_disable_logins = false;
58 private string m_uri = string.Empty;
57 59
58 Scene m_scene = null; 60 Scene m_scene = null;
59 61
@@ -77,6 +79,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
77 { 79 {
78 m_channelNotify = m_config.GetInt("channel_notify", m_channelNotify); 80 m_channelNotify = m_config.GetInt("channel_notify", m_channelNotify);
79 m_disable_logins = m_config.GetBoolean("login_disable", false); 81 m_disable_logins = m_config.GetBoolean("login_disable", false);
82 m_uri = m_config.GetString("alert_uri",string.Empty);
80 } 83 }
81 } 84 }
82 85
@@ -97,6 +100,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
97 100
98 m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; 101 m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue;
99 m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded; 102 m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded;
103 m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled;
100 104
101 m_log.DebugFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName); 105 m_log.DebugFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName);
102 106
@@ -105,6 +109,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
105 scene.LoginLock = true; 109 scene.LoginLock = true;
106 scene.LoginsDisabled = true; 110 scene.LoginsDisabled = true;
107 m_log.InfoFormat("[RegionReady]: Logins disabled for {0}",m_scene.RegionInfo.RegionName); 111 m_log.InfoFormat("[RegionReady]: Logins disabled for {0}",m_scene.RegionInfo.RegionName);
112
113 if(m_uri != string.Empty)
114 {
115 RRAlert("disabled");
116 }
108 } 117 }
109 } 118 }
110 119
@@ -161,19 +170,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
161 c.SenderUUID = UUID.Zero; 170 c.SenderUUID = UUID.Zero;
162 c.Scene = m_scene; 171 c.Scene = m_scene;
163 172
164 if(m_disable_logins == true)
165 {
166 if(m_scene.StartDisabled == false)
167 {
168 m_scene.LoginsDisabled = false;
169 m_scene.LoginLock = false;
170 m_log.InfoFormat("[RegionReady]: Logins enabled for {0}", m_scene.RegionInfo.RegionName);
171 }
172 }
173
174 m_log.InfoFormat("[RegionReady]: Region \"{0}\" is ready: \"{1}\" on channel {2}", 173 m_log.InfoFormat("[RegionReady]: Region \"{0}\" is ready: \"{1}\" on channel {2}",
175 m_scene.RegionInfo.RegionName, c.Message, m_channelNotify); 174 m_scene.RegionInfo.RegionName, c.Message, m_channelNotify);
176 m_scene.EventManager.TriggerOnChatBroadcast(this, c); 175
176 m_scene.EventManager.TriggerOnChatBroadcast(this, c);
177 m_scene.EventManager.TriggerLoginsEnabled(m_scene.RegionInfo.RegionName);
177 } 178 }
178 } 179 }
179 180
@@ -188,5 +189,69 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
188 m_lastOarLoadedOk = false; 189 m_lastOarLoadedOk = false;
189 } 190 }
190 } 191 }
192
193 void OnLoginsEnabled(string regionName)
194 {
195 if (m_disable_logins == true)
196 {
197 if (m_scene.StartDisabled == false)
198 {
199 m_scene.LoginsDisabled = false;
200 m_scene.LoginLock = false;
201 m_log.InfoFormat("[RegionReady]: Logins enabled for {0}", m_scene.RegionInfo.RegionName);
202 if ( m_uri != string.Empty )
203 {
204 RRAlert("enabled");
205 }
206 }
207 }
208 }
209
210 public void RRAlert(string status)
211 {
212 string request_method = "POST";
213 string content_type = "application/json";
214 OSDMap RRAlert = new OSDMap();
215
216 RRAlert["alert"] = "region_ready";
217 RRAlert["login"] = status;
218 RRAlert["region_name"] = m_scene.RegionInfo.RegionName;
219 RRAlert["region_id"] = m_scene.RegionInfo.RegionID;
220
221 string strBuffer = "";
222 byte[] buffer = new byte[1];
223 try
224 {
225 strBuffer = OSDParser.SerializeJsonString(RRAlert);
226 Encoding str = Util.UTF8;
227 buffer = str.GetBytes(strBuffer);
228
229 }
230 catch (Exception e)
231 {
232 m_log.WarnFormat("[RegionReady]: Exception thrown on alert: {0}", e.Message);
233 }
234
235 WebRequest request = WebRequest.Create(m_uri);
236 request.Method = request_method;
237 request.ContentType = content_type;
238
239 Stream os = null;
240 try
241 {
242 request.ContentLength = buffer.Length;
243 os = request.GetRequestStream();
244 os.Write(buffer, 0, strBuffer.Length);
245 }
246 catch(Exception e)
247 {
248 m_log.WarnFormat("[RegionReady]: Exception thrown sending alert: {0}", e.Message);
249 }
250 finally
251 {
252 if (os != null)
253 os.Close();
254 }
255 }
191 } 256 }
192} 257}