From 4dd523b45d1e635c66eb4e556764fabe29dbfc58 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 15:34:56 -0800 Subject: * Changed IPresenceService Logout, so that it takes a position and a lookat * CommsManager.AvatarService rerouted --- .../RemoteController/RemoteAdminPlugin.cs | 19 ++++++++++------ OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs | 9 ++------ .../Rest/Inventory/RestAppearanceServices.cs | 26 +++++++++++++--------- .../Resources/CoreModulePlugin.addin.xml | 2 -- .../Interregion/RESTInterregionComms.cs | 15 +++++++------ .../Presence/LocalPresenceServiceConnector.cs | 4 ++-- .../Presence/PresenceDetector.cs | 18 ++++++++++++++- .../Presence/RemotePresenceServiceConnector.cs | 4 ++-- .../Presence/Tests/PresenceConnectorsTests.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 1 - .../Framework/Scenes/SceneCommunicationService.cs | 13 ----------- .../Handlers/Presence/PresenceServerPostHandler.cs | 9 +++++++- .../Presence/PresenceServiceConnector.cs | 4 +++- OpenSim/Services/Interfaces/IPresenceService.cs | 2 +- OpenSim/Services/LLLoginService/LLLoginService.cs | 6 ++--- .../Services/PresenceService/PresenceService.cs | 4 +++- OpenSim/Tests/Clients/Presence/PresenceClient.cs | 2 +- 17 files changed, 78 insertions(+), 62 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index a82d25a..eda2934 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -1430,8 +1430,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController private void establishAppearance(UUID dest, UUID srca) { m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", dest, srca); - - AvatarAppearance ava = m_app.CommunicationsManager.AvatarService.GetUserAppearance(srca); + AvatarAppearance ava = null; + AvatarData avatar = m_app.SceneManager.CurrentOrFirstScene.AvatarService.GetAvatar(srca); + if (avatar != null) + ava = avatar.ToAvatarAppearance(); // If the model has no associated appearance we're done. @@ -1524,7 +1526,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController throw new Exception("Unable to load both inventories"); } - m_app.CommunicationsManager.AvatarService.UpdateUserAppearance(dest, ava); + AvatarData adata = new AvatarData(ava); + m_app.SceneManager.CurrentOrFirstScene.AvatarService.SetAvatar(dest, adata); } catch (Exception e) { @@ -1671,10 +1674,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController iserv.GetUserInventory(ID, uic.callback); // While the inventory is being fetched, setup for appearance processing - if ((mava = m_app.CommunicationsManager.AvatarService.GetUserAppearance(ID)) == null) - { + AvatarData adata = m_app.SceneManager.CurrentOrFirstScene.AvatarService.GetAvatar(ID); + if (adata != null) + mava = adata.ToAvatarAppearance(); + else mava = new AvatarAppearance(); - } { AvatarWearable[] wearables = mava.Wearables; @@ -1809,7 +1813,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController m_log.DebugFormat("[RADMIN] Outfit {0} load completed", oname); } // foreach outfit m_log.DebugFormat("[RADMIN] Inventory update complete for {0}", name); - m_app.CommunicationsManager.AvatarService.UpdateUserAppearance(ID, mava); + AvatarData adata2 = new AvatarData(mava); + m_app.SceneManager.CurrentOrFirstScene.AvatarService.SetAvatar(ID, adata2); } catch (Exception e) { diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs index 791cfcd..c40ea0e 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs @@ -36,7 +36,7 @@ using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Services.Interfaces; using IUserService = OpenSim.Framework.Communications.IUserService; -using IAvatarService = OpenSim.Framework.Communications.IAvatarService; +using IAvatarService = OpenSim.Services.Interfaces.IAvatarService; namespace OpenSim.ApplicationPlugins.Rest.Inventory { @@ -93,11 +93,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// initializes. /// - internal static CommunicationsManager Comms - { - get { return main.CommunicationsManager; } - } - internal static IInventoryService InventoryServices { get { return main.SceneManager.CurrentOrFirstScene.InventoryService; } @@ -115,7 +110,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory internal static IAvatarService AvatarServices { - get { return Comms.AvatarService; } + get { return main.SceneManager.CurrentOrFirstScene.AvatarService; } } internal static IAssetService AssetServices diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs index 0a45eff..5429890 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs @@ -32,6 +32,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Services.Interfaces; namespace OpenSim.ApplicationPlugins.Rest.Inventory { @@ -295,15 +296,15 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory private void DoGet(AppearanceRequestData rdata) { + AvatarData adata = Rest.AvatarServices.GetAvatar(rdata.userProfile.ID); - rdata.userAppearance = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID); - - if (rdata.userAppearance == null) + if (adata == null) { rdata.Fail(Rest.HttpStatusCodeNoContent, String.Format("appearance data not found for user {0} {1}", rdata.userProfile.FirstName, rdata.userProfile.SurName)); } + rdata.userAppearance = adata.ToAvatarAppearance(); rdata.initXmlWriter(); @@ -342,18 +343,20 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory // increasingly doubtful that it is appropriate for REST. If I attempt to // add a new record, and it already exists, then it seems to me that the // attempt should fail, rather than update the existing record. - + AvatarData adata = null; if (GetUserAppearance(rdata)) { modified = rdata.userAppearance != null; created = !modified; - Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance); + adata = new AvatarData(rdata.userAppearance); + Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata); // Rest.UserServices.UpdateUserProfile(rdata.userProfile); } else { created = true; - Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance); + adata = new AvatarData(rdata.userAppearance); + Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata); // Rest.UserServices.UpdateUserProfile(rdata.userProfile); } @@ -439,21 +442,22 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory private void DoDelete(AppearanceRequestData rdata) { + AvatarData adata = Rest.AvatarServices.GetAvatar(rdata.userProfile.ID); - AvatarAppearance old = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID); - - if (old != null) + if (adata != null) { + AvatarAppearance old = adata.ToAvatarAppearance(); rdata.userAppearance = new AvatarAppearance(); - rdata.userAppearance.Owner = old.Owner; + adata = new AvatarData(rdata.userAppearance); - Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance); + Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata); rdata.Complete(); } else { + rdata.Complete(Rest.HttpStatusCodeNoContent); } diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 7b9fdee..a43b728 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -46,8 +46,6 @@ - - diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs index fa3681a..10ab76f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs @@ -781,13 +781,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion ipaddr = Util.GetHostFromDNS(parts[0]); if (parts.Length == 2) UInt32.TryParse(parts[1], out port); - - // local authority (standalone), local call - if (m_thisIP.Equals(ipaddr) && (m_aScene.RegionInfo.HttpPort == port)) - return ((IAuthentication)m_aScene.CommsManager.UserAdminService).VerifyKey(userID, key); - // remote call - else - return AuthClient.VerifyKey("http://" + authority, userID, key); + return true; + + //// local authority (standalone), local call + //if (m_thisIP.Equals(ipaddr) && (m_aScene.RegionInfo.HttpPort == port)) + // return ((IAuthentication)m_aScene.CommsManager.UserAdminService).VerifyKey(userID, key); + //// remote call + //else + // return AuthClient.VerifyKey("http://" + authority, userID, key); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs index 2cb18c7..d78daf9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs @@ -163,9 +163,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence return false; } - public bool LogoutAgent(UUID sessionID) + public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat) { - return m_PresenceService.LogoutAgent(sessionID); + return m_PresenceService.LogoutAgent(sessionID, position, lookat); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs index 3ca5560..891fc14 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs @@ -42,6 +42,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IPresenceService m_PresenceService; + private Scene m_aScene; public PresenceDetector(IPresenceService presenceservice) { @@ -54,6 +55,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence scene.EventManager.OnNewClient += OnNewClient; m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID); + + if (m_aScene == null) + m_aScene = scene; } public void RemoveRegion(Scene scene) @@ -62,6 +66,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence scene.EventManager.OnNewClient -= OnNewClient; m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID); + } public void OnMakeRootAgent(ScenePresence sp) @@ -78,7 +83,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence public void OnLogout(IClientAPI client) { client.OnLogout -= OnLogout; - m_PresenceService.LogoutAgent(client.SessionId); + + ScenePresence sp = null; + Vector3 position = new Vector3(128, 128, 0); + Vector3 lookat = new Vector3(0, 1, 0); + + if (m_aScene.TryGetAvatar(client.AgentId, out sp)) + { + position = sp.AbsolutePosition; + lookat = sp.Lookat; + } + m_PresenceService.LogoutAgent(client.SessionId, position, lookat); + } } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs index 6c69570..865f99e 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) + public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat) { - return m_RemoteConnector.LogoutAgent(sessionID); + return m_RemoteConnector.LogoutAgent(sessionID, position, lookat); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs index ebb2c3e..9ba1bdc 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs @@ -91,7 +91,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests 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); + r = m_LocalConnector.LogoutAgent(session1, Vector3.Zero, Vector3.UnitY); Assert.IsTrue(r, "LogoutAgent returned false"); result = m_LocalConnector.GetAgent(session1); Assert.IsNotNull(result, "Agent session disappeared from storage after logout"); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 53c51e6..6d6f0b1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3213,7 +3213,6 @@ namespace OpenSim.Region.Framework.Scenes if (!avatar.IsChildAgent) { - m_sceneGridService.LogOffUser(agentID, RegionInfo.RegionID, RegionInfo.RegionHandle, avatar.AbsolutePosition, avatar.Lookat); //List childknownRegions = new List(); //List ckn = avatar.KnownChildRegionHandles; //for (int i = 0; i < ckn.Count; i++) diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index ce3c16c..04ecb5f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -1444,19 +1444,6 @@ namespace OpenSim.Region.Framework.Scenes //m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); } - - public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) - { - m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat); - } - - // deprecated as of 2008-08-27 - public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) - { - m_commsProvider.LogOffUser(userid, regionid, regionhandle, posx, posy, posz); - } - - public List GenerateAgentPickerRequestResponse(UUID queryID, string query) { return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query); diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index 6e47b22..926c195 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs @@ -131,6 +131,8 @@ namespace OpenSim.Server.Handlers.Presence byte[] LogoutAgent(Dictionary request) { UUID session = UUID.Zero; + Vector3 position = Vector3.Zero; + Vector3 lookat = Vector3.Zero; if (!request.ContainsKey("SessionID")) return FailureResult(); @@ -138,7 +140,12 @@ namespace OpenSim.Server.Handlers.Presence if (!UUID.TryParse(request["SessionID"].ToString(), out session)) return FailureResult(); - if (m_PresenceService.LogoutAgent(session)) + if (request.ContainsKey("Position") && request["Position"] != null) + Vector3.TryParse(request["Position"].ToString(), out position); + if (request.ContainsKey("LookAt") && request["Position"] != null) + Vector3.TryParse(request["LookAt"].ToString(), out lookat); + + if (m_PresenceService.LogoutAgent(session, position, lookat)) return SuccessResult(); return FailureResult(); diff --git a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs index 29cfd6e..fac3d1f 100644 --- a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs +++ b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs @@ -132,7 +132,7 @@ namespace OpenSim.Services.Connectors } - public bool LogoutAgent(UUID sessionID) + public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat) { Dictionary sendData = new Dictionary(); //sendData["SCOPEID"] = scopeID.ToString(); @@ -141,6 +141,8 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "logout"; sendData["SessionID"] = sessionID.ToString(); + sendData["Position"] = position.ToString(); + sendData["LookAt"] = lookat.ToString(); string reqString = ServerUtils.BuildQueryString(sendData); // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); diff --git a/OpenSim/Services/Interfaces/IPresenceService.cs b/OpenSim/Services/Interfaces/IPresenceService.cs index a010611..b4c1859 100644 --- a/OpenSim/Services/Interfaces/IPresenceService.cs +++ b/OpenSim/Services/Interfaces/IPresenceService.cs @@ -115,7 +115,7 @@ namespace OpenSim.Services.Interfaces public interface IPresenceService { bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID); - bool LogoutAgent(UUID sessionID); + bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookAt); bool LogoutRegionAgents(UUID regionID); bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt); diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index 2ae552f..47d1b16 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -163,7 +163,7 @@ namespace OpenSim.Services.LLLoginService GridRegion destination = FindDestination(account, presence, session, startLocation, out where, out position, out lookAt); if (destination == null) { - m_PresenceService.LogoutAgent(session); + m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt); m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: destination not found"); return LLFailedLoginResponse.GridProblem; } @@ -195,7 +195,7 @@ namespace OpenSim.Services.LLLoginService } if (aCircuit == null) { - m_PresenceService.LogoutAgent(session); + m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt); m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason); return LLFailedLoginResponse.AuthorizationProblem; } @@ -212,7 +212,7 @@ namespace OpenSim.Services.LLLoginService { m_log.WarnFormat("[LLOGIN SERVICE]: Exception processing login for {0} {1}: {2}", firstName, lastName, e.StackTrace); if (m_PresenceService != null) - m_PresenceService.LogoutAgent(session); + m_PresenceService.LogoutAgent(session, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); return LLFailedLoginResponse.InternalError; } } diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 2884199..34a3154 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -87,7 +87,7 @@ namespace OpenSim.Services.PresenceService return true; } - public bool LogoutAgent(UUID sessionID) + public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat) { PresenceData data = m_Database.Get(sessionID); if (data == null) @@ -103,6 +103,8 @@ namespace OpenSim.Services.PresenceService data.Data["Online"] = "false"; data.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString(); + data.Data["Position"] = position.ToString(); + data.Data["LookAt"] = lookat.ToString(); m_Database.Store(data); diff --git a/OpenSim/Tests/Clients/Presence/PresenceClient.cs b/OpenSim/Tests/Clients/Presence/PresenceClient.cs index 3416804..4f959f6 100644 --- a/OpenSim/Tests/Clients/Presence/PresenceClient.cs +++ b/OpenSim/Tests/Clients/Presence/PresenceClient.cs @@ -103,7 +103,7 @@ namespace OpenSim.Tests.Clients.PresenceClient pinfo.UserID, pinfo.Online, pinfo.RegionID, pinfo.HomeRegionID); System.Console.WriteLine("\n"); - success = m_Connector.LogoutAgent(session1); + success = m_Connector.LogoutAgent(session1, Vector3.Zero, Vector3.UnitY); if (success) m_log.InfoFormat("[PRESENCE CLIENT]: Successfully logged out user {0}", user1); else -- cgit v1.1