From a58859a0d4206c194c9c56212218e2cafc2cc373 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Fri, 7 May 2010 21:29:56 -0700
Subject: GridUserService in place. Replaces the contrived concept of storing
user's home and position info in the presence service. WARNING: I violated a
taboo by deleting 2 migration files and simplifying the original table
creation for Presence. This should not cause any problems to anyone, though.
Things will work with the new simplified table, as well as with the previous
contrived one. If there are any problems, solving them is as easy as dropping
the presence table and deleting its row in the migrations table. The presence
info only exists during a user's session anyway.
BTW, the Meshing files want to be committed too -- EOFs.
---
.../EntityTransfer/EntityTransferModule.cs | 9 +--
.../EntityTransfer/HGEntityTransferModule.cs | 9 ++-
.../Resources/CoreModulePlugin.addin.xml | 4 +-
.../GridUser/LocalGridUserServiceConnector.cs | 69 +++++++++++++++++-----
.../Presence/LocalPresenceServiceConnector.cs | 13 ++--
.../Presence/PresenceDetector.cs | 12 ++--
.../Presence/RemotePresenceServiceConnector.cs | 13 ++--
.../Presence/Tests/PresenceConnectorsTests.cs | 8 +--
8 files changed, 87 insertions(+), 50 deletions(-)
(limited to 'OpenSim/Region/CoreModules')
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index f2b03e4..ef37f63 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -526,11 +526,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
{
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName);
- OpenSim.Services.Interfaces.PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(client.SessionId);
+ //OpenSim.Services.Interfaces.PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(client.SessionId);
+ GridUserInfo uinfo = m_aScene.GridUserService.GetGridUserInfo(client.AgentId.ToString());
- if (pinfo != null)
+ if (uinfo != null)
{
- GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, pinfo.HomeRegionID);
+ GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID);
if (regionInfo == null)
{
// can't find the Home region: Tell viewer and abort
@@ -539,7 +540,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
}
// a little eekie that this goes back to Scene and with a forced cast, will fix that at some point...
((Scene)(client.Scene)).RequestTeleportLocation(
- client, regionInfo.RegionHandle, pinfo.HomePosition, pinfo.HomeLookAt,
+ client, regionInfo.RegionHandle, uinfo.HomePosition, uinfo.HomeLookAt,
(uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
}
}
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 28593fc..137dfec 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -154,7 +154,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason);
if (success)
// Log them out of this grid
- m_aScene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat);
+ m_aScene.PresenceService.LogoutAgent(agentCircuit.SessionID);
return success;
}
@@ -238,6 +238,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
{
if (obj.IsLoggingOut)
{
+ object sp = null;
+ if (obj.Scene.TryGetScenePresence(obj.AgentId, out sp))
+ {
+ if (((ScenePresence)sp).IsChildAgent)
+ return;
+ }
+
AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode);
if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index 0a5ff3f..ee07075 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -59,9 +59,11 @@
-
+
+
+
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs
index d5fae23..d914a57 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs
@@ -41,13 +41,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
{
public class LocalGridUserServicesConnector : ISharedRegionModule, IGridUserService
{
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ private static readonly ILog m_log =
+ LogManager.GetLogger(
+ MethodBase.GetCurrentMethod().DeclaringType);
- private IGridUserService m_service;
+ private IGridUserService m_GridUserService;
+
+ private ActivityDetector m_ActivityDetector;
private bool m_Enabled = false;
- public Type ReplaceableInterface
+ #region ISharedRegionModule
+
+ public Type ReplaceableInterface
{
get { return null; }
}
@@ -68,7 +74,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
IConfig userConfig = source.Configs["GridUserService"];
if (userConfig == null)
{
- m_log.Error("[LOCAL GRID USER SERVICE CONNECTOR]: GridUserService missing from ini files");
+ m_log.Error("[LOCAL GRID USER SERVICE CONNECTOR]: GridUserService missing from OpenSim.ini");
return;
}
@@ -81,15 +87,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
}
Object[] args = new Object[] { source };
- m_service = ServerUtils.LoadPlugin(serviceDll, args);
+ m_GridUserService = ServerUtils.LoadPlugin(serviceDll, args);
- if (m_service == null)
+ if (m_GridUserService == null)
{
- m_log.Error("[LOCAL GRID USER SERVICE CONNECTOR]: Can't load GridUser service");
+ m_log.ErrorFormat(
+ "[LOCAL GRID USER SERVICE CONNECTOR]: Cannot load user account service specified as {0}", serviceDll);
return;
}
+
+ m_ActivityDetector = new ActivityDetector(this);
+
m_Enabled = true;
- m_log.Info("[LOCAL GRID USER SERVICE CONNECTOR]: Local GridUser connector enabled");
+
+ m_log.Info("[LOCAL GRID USER SERVICE CONNECTOR]: Local grid user connector enabled");
}
}
}
@@ -111,29 +122,57 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
if (!m_Enabled)
return;
- scene.RegisterModuleInterface(m_service);
+ scene.RegisterModuleInterface(m_GridUserService);
+ m_ActivityDetector.AddRegion(scene);
}
public void RemoveRegion(Scene scene)
{
if (!m_Enabled)
return;
+
+ scene.UnregisterModuleInterface(this);
+ m_ActivityDetector.RemoveRegion(scene);
}
public void RegionLoaded(Scene scene)
{
if (!m_Enabled)
return;
+
+ m_log.InfoFormat("[LOCAL GRID USER SERVICE CONNECTOR]: Enabled local grid user for region {0}", scene.RegionInfo.RegionName);
}
- public GridUserInfo GetGridUserInfo(string userID)
+ #endregion
+
+ #region IGridUserService
+
+ public GridUserInfo LoggedIn(string userID)
{
- return m_service.GetGridUserInfo(userID);
+ return m_GridUserService.LoggedIn(userID);
}
-
- public bool StoreGridUserInfo(GridUserInfo info)
+
+ public bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
{
- return m_service.StoreGridUserInfo(info);
+ return m_GridUserService.LoggedOut(userID, regionID, lastPosition, lastLookAt);
}
+
+ public bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt)
+ {
+ return m_GridUserService.SetHome(userID, homeID, homePosition, homeLookAt);
+ }
+
+ public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
+ {
+ return m_GridUserService.SetLastPosition(userID, regionID, lastPosition, lastLookAt);
+ }
+
+ public GridUserInfo GetGridUserInfo(string userID)
+ {
+ return m_GridUserService.GetGridUserInfo(userID);
+ }
+
+ #endregion
+
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs
index c402a3f..49dd633 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs
@@ -167,9 +167,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
return false;
}
- public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat)
+ public bool LogoutAgent(UUID sessionID)
{
- return m_PresenceService.LogoutAgent(sessionID, position, lookat);
+ return m_PresenceService.LogoutAgent(sessionID);
}
@@ -178,9 +178,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
return m_PresenceService.LogoutRegionAgents(regionID);
}
- public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
+ public bool ReportAgent(UUID sessionID, UUID regionID)
{
- return m_PresenceService.ReportAgent(sessionID, regionID, position, lookAt);
+ return m_PresenceService.ReportAgent(sessionID, regionID);
}
public PresenceInfo GetAgent(UUID sessionID)
@@ -193,11 +193,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
return m_PresenceService.GetAgents(userIDs);
}
- public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
- {
- return m_PresenceService.SetHomeLocation(userID, regionID, position, lookAt);
- }
-
#endregion
}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
index 7a75a89..62b8278 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
public void OnMakeRootAgent(ScenePresence sp)
{
m_log.DebugFormat("[PRESENCE DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName);
- m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
+ m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID);
}
public void OnNewClient(IClientAPI client)
@@ -85,19 +85,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
if (client.IsLoggingOut)
{
object sp = null;
- Vector3 position = new Vector3(128, 128, 0);
- Vector3 lookat = new Vector3(0, 1, 0);
-
if (client.Scene.TryGetScenePresence(client.AgentId, out sp))
{
if (sp is ScenePresence)
{
- position = ((ScenePresence)sp).AbsolutePosition;
- lookat = ((ScenePresence)sp).Lookat;
+ if (((ScenePresence)sp).IsChildAgent)
+ return;
}
}
- m_PresenceService.LogoutAgent(client.SessionId, position, lookat);
+ m_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);
+ m_PresenceService.LogoutAgent(client.SessionId);
}
}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs
index 5f3666e..bf4e9ab 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs
@@ -127,9 +127,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
return false;
}
- public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat)
+ public bool LogoutAgent(UUID sessionID)
{
- return m_RemoteConnector.LogoutAgent(sessionID, position, lookat);
+ return m_RemoteConnector.LogoutAgent(sessionID);
}
@@ -138,9 +138,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
return m_RemoteConnector.LogoutRegionAgents(regionID);
}
- public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
+ public bool ReportAgent(UUID sessionID, UUID regionID)
{
- return m_RemoteConnector.ReportAgent(sessionID, regionID, position, lookAt);
+ return m_RemoteConnector.ReportAgent(sessionID, regionID);
}
public PresenceInfo GetAgent(UUID sessionID)
@@ -153,11 +153,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
return m_RemoteConnector.GetAgents(userIDs);
}
- public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
- {
- return m_RemoteConnector.SetHomeLocation(userID, regionID, position, lookAt);
- }
-
#endregion
}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
index 63a28fc..e5ded5b 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
@@ -93,24 +93,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests
Assert.IsTrue(result.Online, "Agent just logged in but is offline");
UUID region1 = UUID.Random();
- bool r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero);
+ bool r = m_LocalConnector.ReportAgent(session1, region1);
Assert.IsTrue(r, "First ReportAgent returned false");
result = m_LocalConnector.GetAgent(session1);
Assert.That(result.RegionID, Is.EqualTo(region1), "Agent is not in the right region (region1)");
UUID region2 = UUID.Random();
- r = m_LocalConnector.ReportAgent(session1, region2, Vector3.Zero, Vector3.Zero);
+ r = m_LocalConnector.ReportAgent(session1, region2);
Assert.IsTrue(r, "Second ReportAgent returned false");
result = m_LocalConnector.GetAgent(session1);
Assert.That(result.RegionID, Is.EqualTo(region2), "Agent is not in the right region (region2)");
- r = m_LocalConnector.LogoutAgent(session1, Vector3.Zero, Vector3.UnitY);
+ r = m_LocalConnector.LogoutAgent(session1);
Assert.IsTrue(r, "LogoutAgent returned false");
result = m_LocalConnector.GetAgent(session1);
Assert.IsNotNull(result, "Agent session disappeared from storage after logout");
Assert.IsFalse(result.Online, "Agent is reported to be Online after logout");
- r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero);
+ r = m_LocalConnector.ReportAgent(session1, region1);
Assert.IsFalse(r, "ReportAgent of non-logged in user returned true");
}
}
--
cgit v1.1