diff options
author | BlueWall | 2011-05-28 16:21:30 -0400 |
---|---|---|
committer | BlueWall | 2011-05-28 16:21:30 -0400 |
commit | 3326e417b4e105d8d9850aa983981615df3eebc4 (patch) | |
tree | 600279962de2a4c54791b486cb3d93ed22685fd3 | |
parent | Merge branch 'master' of /home/opensim/src/opensim (diff) | |
parent | Adding an event to signal that logins are enabled (diff) | |
download | opensim-SC_OLD-3326e417b4e105d8d9850aa983981615df3eebc4.zip opensim-SC_OLD-3326e417b4e105d8d9850aa983981615df3eebc4.tar.gz opensim-SC_OLD-3326e417b4e105d8d9850aa983981615df3eebc4.tar.bz2 opensim-SC_OLD-3326e417b4e105d8d9850aa983981615df3eebc4.tar.xz |
Merge branch 'master' of /home/opensim/src/opensim
-rw-r--r-- | OpenSim/Region/Framework/Scenes/EventManager.cs | 24 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 3 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs | 87 | ||||
-rw-r--r-- | bin/OpenSimDefaults.ini | 3 |
4 files changed, 106 insertions, 11 deletions
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index e04317b..b43d5f0 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -389,6 +389,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
389 | public delegate void RegionUp(GridRegion region); | 389 | public delegate void RegionUp(GridRegion region); |
390 | public event RegionUp OnRegionUp; | 390 | public event RegionUp OnRegionUp; |
391 | 391 | ||
392 | public delegate void LoginsEnabled(string regionName); | ||
393 | public event LoginsEnabled OnLoginsEnabled; | ||
394 | |||
392 | public class MoneyTransferArgs : EventArgs | 395 | public class MoneyTransferArgs : EventArgs |
393 | { | 396 | { |
394 | public UUID sender; | 397 | public UUID sender; |
@@ -2218,5 +2221,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
2218 | } | 2221 | } |
2219 | } | 2222 | } |
2220 | } | 2223 | } |
2224 | |||
2225 | public void TriggerLoginsEnabled (string regionName) | ||
2226 | { | ||
2227 | LoginsEnabled handler = OnLoginsEnabled; | ||
2228 | |||
2229 | if ( handler != null) | ||
2230 | { | ||
2231 | foreach (LoginsEnabled d in handler.GetInvocationList()) | ||
2232 | { | ||
2233 | try | ||
2234 | { | ||
2235 | d(regionName); | ||
2236 | } | ||
2237 | catch (Exception e) | ||
2238 | { | ||
2239 | m_log.ErrorFormat("[EVENT MANAGER]: Delegate for LoginsEnabled failed - continuing {0} - {1}", | ||
2240 | e.Message, e.StackTrace); | ||
2241 | } | ||
2242 | } | ||
2243 | } | ||
2244 | } | ||
2221 | } | 2245 | } |
2222 | } | 2246 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e9f5f9e..1d562fd 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1376,9 +1376,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1376 | IConfig startupConfig = m_config.Configs["Startup"]; | 1376 | IConfig startupConfig = m_config.Configs["Startup"]; |
1377 | if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false)) | 1377 | if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false)) |
1378 | { | 1378 | { |
1379 | // This handles a case of a region having no scripts for the RegionReady module | ||
1379 | if (m_sceneGraph.GetActiveScriptsCount() == 0) | 1380 | if (m_sceneGraph.GetActiveScriptsCount() == 0) |
1380 | { | 1381 | { |
1382 | // need to be able to tell these have changed in RegionReady | ||
1381 | LoginLock = false; | 1383 | LoginLock = false; |
1384 | EventManager.TriggerLoginsEnabled(RegionInfo.RegionName); | ||
1382 | } | 1385 | } |
1383 | m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); | 1386 | m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); |
1384 | // For RegionReady lockouts | 1387 | // For RegionReady lockouts |
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; | |||
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Net; | 31 | using System.Net; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Text; | ||
33 | 34 | ||
34 | using log4net; | 35 | using log4net; |
35 | using Nini.Config; | 36 | using 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 | } |
diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 1d24201..8613d4e 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini | |||
@@ -1174,7 +1174,10 @@ | |||
1174 | ; - the third field is a number indicating how many scripts failed to compile | 1174 | ; - the third field is a number indicating how many scripts failed to compile |
1175 | ; - "oar error" if supplied, provides the error message from the OAR load | 1175 | ; - "oar error" if supplied, provides the error message from the OAR load |
1176 | channel_notify = -800 | 1176 | channel_notify = -800 |
1177 | ; - disallow logins while scripts are loading | ||
1177 | login_disable = false | 1178 | login_disable = false |
1179 | ; - send an alert as json to a service | ||
1180 | alert_uri = "http://myappserver.net/my_handler/" | ||
1178 | 1181 | ||
1179 | 1182 | ||
1180 | [MRM] | 1183 | [MRM] |