From 9b7c99f0cfd8fbcd3ce31e0be6fa68f5bedef78b Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 29 Sep 2010 14:24:32 -0700 Subject: Made IGridUserService.SetLastPosition() more flexible to allow different possible implementations. This doesn't change any behavior or any Robust code, but it simplifies the SimianGrid connector by using the standard OpenSim interface for setting last position now --- .../ServiceConnectorsOut/GridUser/ActivityDetector.cs | 9 +++++++-- .../GridUser/LocalGridUserServiceConnector.cs | 4 ++-- .../GridUser/RemoteGridUserServiceConnector.cs | 4 ++-- .../Server/Handlers/GridUser/GridUserServerPostHandler.cs | 2 +- .../Connectors/GridUser/GridUserServiceConnector.cs | 2 +- .../Connectors/SimianGrid/SimianActivityDetector.cs | 8 ++++---- .../SimianGrid/SimianPresenceServiceConnector.cs | 6 ------ OpenSim/Services/Interfaces/IGridUserService.cs | 14 ++++++++++++-- OpenSim/Services/UserAccountService/GridUserService.cs | 2 +- 9 files changed, 30 insertions(+), 21 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs index 83c8eac..116a1dc 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs @@ -69,9 +69,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser public void OnMakeRootAgent(ScenePresence sp) { - m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); + UUID sessionID = UUID.Zero; + + IClientAPI client; + if (m_aScene.TryGetClient(sp.UUID, out client)) + sessionID = client.SessionId; - m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); + m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); + m_GridUserService.SetLastPosition(sp.UUID.ToString(), sessionID, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); } public void OnNewClient(IClientAPI client) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs index d914a57..76e030f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs @@ -162,9 +162,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser return m_GridUserService.SetHome(userID, homeID, homePosition, homeLookAt); } - public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) + public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) { - return m_GridUserService.SetLastPosition(userID, regionID, lastPosition, lastLookAt); + return m_GridUserService.SetLastPosition(userID, sessionID, regionID, lastPosition, lastLookAt); } public GridUserInfo GetGridUserInfo(string userID) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs index e3e2e61..fb11e9a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs @@ -137,9 +137,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser return m_RemoteConnector.SetHome(userID, regionID, position, lookAt); } - public bool SetLastPosition(string userID, UUID regionID, Vector3 position, Vector3 lookAt) + public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) { - return m_RemoteConnector.SetLastPosition(userID, regionID, position, lookAt); + return m_RemoteConnector.SetLastPosition(userID, sessionID, regionID, position, lookAt); } public GridUserInfo GetGridUserInfo(string userID) diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs index f8fa429..6b14a52 100644 --- a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs +++ b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs @@ -166,7 +166,7 @@ namespace OpenSim.Server.Handlers.GridUser if (!UnpackArgs(request, out user, out region, out position, out look)) return FailureResult(); - if (m_GridUserService.SetLastPosition(user, region, position, look)) + if (m_GridUserService.SetLastPosition(user, UUID.Zero, region, position, look)) return SuccessResult(); return FailureResult(); diff --git a/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs b/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs index 935ebb1..48d2939 100644 --- a/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs +++ b/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs @@ -123,7 +123,7 @@ namespace OpenSim.Services.Connectors return Set(sendData, userID, regionID, position, lookAt); } - public bool SetLastPosition(string userID, UUID regionID, Vector3 position, Vector3 lookAt) + public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) { Dictionary sendData = new Dictionary(); //sendData["SCOPEID"] = scopeID.ToString(); diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs index 67a06f3..c89c81a 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs @@ -29,6 +29,7 @@ using System; using System.Reflection; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; using OpenMetaverse; using log4net; @@ -38,12 +39,12 @@ namespace OpenSim.Services.Connectors.SimianGrid { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private SimianPresenceServiceConnector m_GridUserService; + private IGridUserService m_GridUserService; private Scene m_aScene; - public SimianActivityDetector(SimianPresenceServiceConnector guservice) + public SimianActivityDetector(IGridUserService guService) { - m_GridUserService = guservice; + m_GridUserService = guService; m_log.DebugFormat("[SIMIAN ACTIVITY DETECTOR]: Started"); } @@ -103,7 +104,6 @@ namespace OpenSim.Services.Connectors.SimianGrid m_log.DebugFormat("[SIMIAN ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); m_GridUserService.LoggedOut(client.AgentId.ToString(), client.Scene.RegionInfo.RegionID, position, lookat); } - } void OnEnteringNewParcel(ScenePresence sp, int localLandID, UUID regionID) diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs index a344594..fa51c9a 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs @@ -304,12 +304,6 @@ namespace OpenSim.Services.Connectors.SimianGrid return UpdateSession(sessionID, regionID, lastPosition, lastLookAt); } - public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) - { - // Never called - return false; - } - public GridUserInfo GetGridUserInfo(string user) { m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user); diff --git a/OpenSim/Services/Interfaces/IGridUserService.cs b/OpenSim/Services/Interfaces/IGridUserService.cs index 95ce5e8..dfb79a4 100644 --- a/OpenSim/Services/Interfaces/IGridUserService.cs +++ b/OpenSim/Services/Interfaces/IGridUserService.cs @@ -108,8 +108,18 @@ namespace OpenSim.Services.Interfaces bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt); bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt); - bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt); - + + /// + /// Stores the last known user position at the grid level + /// + /// Ignore if your connector does not use userID for position updates + /// Ignore if your connector does not use sessionID for position updates + /// RegionID where the user is currently located + /// Region-relative position + /// Normalized look direction + /// True if the user's last position was successfully updated, otherwise false + bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt); + GridUserInfo GetGridUserInfo(string userID); } } \ No newline at end of file diff --git a/OpenSim/Services/UserAccountService/GridUserService.cs b/OpenSim/Services/UserAccountService/GridUserService.cs index 697ba63..00a1ae2 100644 --- a/OpenSim/Services/UserAccountService/GridUserService.cs +++ b/OpenSim/Services/UserAccountService/GridUserService.cs @@ -139,7 +139,7 @@ namespace OpenSim.Services.UserAccountService return m_Database.Store(d); } - public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) + public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) { //m_log.DebugFormat("[Grid User Service]: SetLastPosition for {0}", userID); GridUserData d = m_Database.Get(userID); -- cgit v1.1