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.
0.7.3-extended
Justin Clark-Casey (justincc) 2012-07-19 00:09:22 +01:00
parent 58aa51218e
commit e3db5fb603
8 changed files with 47 additions and 25 deletions

View File

@ -66,6 +66,11 @@ namespace OpenSim.Framework
IConfigSource Config { get; }
/// <summary>
/// Are logins enabled on this simulator?
/// </summary>
bool LoginsEnabled { get; set; }
float TimeDilation { get; }
bool AllowScriptCrossings { get; }

View File

@ -129,18 +129,18 @@ namespace OpenSim.Region.CoreModules.World
switch (cmd[1])
{
case "enable":
scene.LoginsDisabled = false;
scene.LoginsEnabled = true;
MainConsole.Instance.Output(String.Format("Logins are enabled for region {0}", scene.RegionInfo.RegionName));
break;
case "disable":
scene.LoginsDisabled = true;
scene.LoginsEnabled = false;
MainConsole.Instance.Output(String.Format("Logins are disabled for region {0}", scene.RegionInfo.RegionName));
break;
case "status":
if (scene.LoginsDisabled)
MainConsole.Instance.Output(String.Format("Login in {0} are disabled", scene.RegionInfo.RegionName));
else
if (scene.LoginsEnabled)
MainConsole.Instance.Output(String.Format("Login in {0} are enabled", scene.RegionInfo.RegionName));
else
MainConsole.Instance.Output(String.Format("Login in {0} are disabled", scene.RegionInfo.RegionName));
break;
default:
MainConsole.Instance.Output("Syntax: login enable|disable|status");

View File

@ -490,13 +490,14 @@ namespace OpenSim.Region.Framework.Scenes
public event RegionHeartbeatEnd OnRegionHeartbeatEnd;
/// <summary>
/// This should only fire in all circumstances if the RegionReady module is active.
/// Fired when logins to a region are enabled or disabled.
/// </summary>
/// <remarks>
/// TODO: Fire this even when the RegionReady module is not active.
///
/// </remarks>
public delegate void LoginsEnabled(IScene scene);
public event LoginsEnabled OnLoginsEnabled;
/// Fired
public event RegionLoginsStatusChange OnRegionLoginsStatusChange;
public delegate void RegionLoginsStatusChange(IScene scene);
/// <summary>
/// Fired when a region is considered ready for use.
@ -505,8 +506,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.
/// </remarks>
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;
@ -2437,13 +2438,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
{
@ -2451,7 +2452,7 @@ 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);
}
}

View File

@ -124,9 +124,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;
@ -1436,7 +1437,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);
@ -1450,8 +1451,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(
@ -3413,7 +3413,7 @@ namespace OpenSim.Region.Framework.Scenes
RegionInfo.RegionName, (agent.child ? "child" : "root"),agent.firstname, agent.lastname,
agent.AgentID, agent.circuitcode, agent.IPAddress, agent.Viewer, ((TPFlags)teleportFlags).ToString(), agent.startpos);
if (LoginsDisabled)
if (!LoginsEnabled)
{
reason = "Logins Disabled";
return false;

View File

@ -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; }

View File

@ -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,

View File

@ -215,15 +215,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
if (!m_scene.StartDisabled)
{
m_scene.LoginsDisabled = false;
m_scene.LoginsEnabled = true;
// m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}",
// m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString());
m_log.InfoFormat(
"[RegionReady]: INITIALIZATION COMPLETE FOR {0} - LOGINS ENABLED", m_scene.Name);
m_scene.EventManager.TriggerLoginsEnabled(m_scene);
}
m_scene.SceneGridService.InformNeighborsThatRegionisUp(

View File

@ -190,7 +190,7 @@ namespace OpenSim.Tests.Common
= physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test");
testScene.RegionInfo.EstateSettings = new EstateSettings();
testScene.LoginsDisabled = false;
testScene.LoginsEnabled = true;
testScene.RegisterRegionWithGrid();
SceneManager.Add(testScene);