From 6dda7c65ae1d58cac3e8dc2d9d64f56c870df39e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 19 Jul 2012 00:09:22 +0100
Subject: Add EventManager.OnRegionLoginsStatusChange fired whenever logins are
enabled or disabled at any point, not just during initial startup.
This replaces EventManager.OnLoginsEnabled which only fired when logins were first enabled
and was affected by a bug where it would never fire if the region started with logins disabled.
---
OpenSim/Region/Framework/Scenes/EventManager.cs | 21 +++++++++++----------
OpenSim/Region/Framework/Scenes/Scene.cs | 10 +++++-----
OpenSim/Region/Framework/Scenes/SceneBase.cs | 18 ++++++++++++++++++
.../Scenes/Tests/ScenePresenceTeleportTests.cs | 2 +-
4 files changed, 35 insertions(+), 16 deletions(-)
(limited to 'OpenSim/Region/Framework')
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index b8ae0ac..620b605 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -497,13 +497,14 @@ namespace OpenSim.Region.Framework.Scenes
public event RegionHeartbeatEnd OnRegionHeartbeatEnd;
///
- /// This should only fire in all circumstances if the RegionReady module is active.
+ /// Fired when logins to a region are enabled or disabled.
///
///
- /// TODO: Fire this even when the RegionReady module is not active.
+ ///
///
- public delegate void LoginsEnabled(IScene scene);
- public event LoginsEnabled OnLoginsEnabled;
+ /// Fired
+ public event RegionLoginsStatusChange OnRegionLoginsStatusChange;
+ public delegate void RegionLoginsStatusChange(IScene scene);
///
/// Fired when a region is considered ready for use.
@@ -512,8 +513,8 @@ namespace OpenSim.Region.Framework.Scenes
/// A region is considered ready when startup operations such as loading of scripts already on the region
/// have been completed.
///
- public delegate void RegionReady(IScene scene);
public event RegionReady OnRegionReady;
+ public delegate void RegionReady(IScene scene);
public delegate void PrimsLoaded(Scene s);
public event PrimsLoaded OnPrimsLoaded;
@@ -2486,13 +2487,13 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- public void TriggerLoginsEnabled(IScene scene)
+ public void TriggerRegionLoginsStatusChange(IScene scene)
{
- LoginsEnabled handler = OnLoginsEnabled;
+ RegionLoginsStatusChange handler = OnRegionLoginsStatusChange;
if (handler != null)
{
- foreach (LoginsEnabled d in handler.GetInvocationList())
+ foreach (RegionLoginsStatusChange d in handler.GetInvocationList())
{
try
{
@@ -2500,13 +2501,13 @@ namespace OpenSim.Region.Framework.Scenes
}
catch (Exception e)
{
- m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnLoginsEnabled failed - continuing {0} - {1}",
+ m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionLoginsStatusChange failed - continuing {0} - {1}",
e.Message, e.StackTrace);
}
}
}
}
-
+
public void TriggerRegionReady(IScene scene)
{
RegionReady handler = OnRegionReady;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d4ccd41..6d8ee7b 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -128,9 +128,10 @@ namespace OpenSim.Region.Framework.Scenes
// root agents when ACL denies access to root agent
public bool m_strictAccessControl = true;
public int MaxUndoCount = 5;
+
// Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
public bool LoginLock = false;
- public bool LoginsDisabled = true;
+
public bool StartDisabled = false;
public bool LoadingPrims;
public IXfer XferManager;
@@ -1478,7 +1479,7 @@ namespace OpenSim.Region.Framework.Scenes
// landMS = Util.EnvironmentTickCountSubtract(ldMS);
//}
- if (LoginsDisabled && Frame == 20)
+ if (!LoginsEnabled && Frame == 20)
{
// m_log.DebugFormat("{0} {1} {2}", LoginsDisabled, m_sceneGraph.GetActiveScriptsCount(), LoginLock);
@@ -1492,8 +1493,7 @@ namespace OpenSim.Region.Framework.Scenes
if (!StartDisabled)
{
m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
- LoginsDisabled = false;
- EventManager.TriggerLoginsEnabled(this);
+ LoginsEnabled = true;
}
m_sceneGridService.InformNeighborsThatRegionisUp(
@@ -3460,7 +3460,7 @@ namespace OpenSim.Region.Framework.Scenes
agent.startpos
);
- if (LoginsDisabled)
+ if (!LoginsEnabled)
{
reason = "Logins Disabled";
return false;
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index f50fbfc..282fc5e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -106,6 +106,24 @@ namespace OpenSim.Region.Framework.Scenes
protected readonly ClientManager m_clientManager = new ClientManager();
+ public bool LoginsEnabled
+ {
+ get
+ {
+ return m_loginsEnabled;
+ }
+
+ set
+ {
+ if (m_loginsEnabled != value)
+ {
+ m_loginsEnabled = value;
+ EventManager.TriggerRegionLoginsStatusChange(this);
+ }
+ }
+ }
+ private bool m_loginsEnabled;
+
public float TimeDilation
{
get { return 1.0f; }
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
index a407f01..37b5184 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
@@ -301,7 +301,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
sp.AbsolutePosition = preTeleportPosition;
// Make sceneB refuse CreateAgent
- sceneB.LoginsDisabled = true;
+ sceneB.LoginsEnabled = false;
sceneA.RequestTeleportLocation(
sp.ControllingClient,
--
cgit v1.1