From 51dc1e709c1941c7a436fa50cf84a6381591b990 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 28 Mar 2012 15:01:37 -0700 Subject: HG 2.0: added the beginning of HGSuitcaseInventoryService. Plus moved the hack away from ScenePresence. This is better but it still doesn't restore the inventory upon arrival. --- .../EntityTransfer/HGEntityTransferModule.cs | 68 +++++++++++++++++++--- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 16 ----- 2 files changed, 61 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 4cdf303..e8d821f 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -71,7 +71,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (name == Name) { InitialiseCommon(source); - IConfig transferConfig = source.Configs["HGEntityTransfer"]; + IConfig transferConfig = source.Configs["HGEntityTransferModule"]; if (transferConfig != null) m_RestrictInventoryAccessAbroad = transferConfig.GetBoolean("RestrictInventoryAccessAbroad", false); @@ -94,6 +94,31 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer client.OnTeleportHomeRequest += TeleportHome; client.OnTeleportLandmarkRequest += RequestTeleportLandmark; client.OnConnectionClosed += new Action(OnConnectionClosed); + client.OnCompleteMovementToRegion += new Action(OnCompleteMovementToRegion); + } + + protected void OnCompleteMovementToRegion(IClientAPI client, bool arg2) + { + // HACK HACK -- just seeing how the viewer responds + // Let's send the Suitcase or the real root folder folder for incoming HG agents + // Visiting agents get their suitcase contents; incoming local users get their real root folder's content + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: OnCompleteMovementToRegion of user {0}", client.AgentId); + object sp = null; + if (client.Scene.TryGetScenePresence(client.AgentId, out sp)) + { + if (sp is ScenePresence) + { + AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId); + if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) + { + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: ViaHGLogin"); + if (m_RestrictInventoryAccessAbroad) + { + RestoreRootFolderContents(client); + } + } + } + } } @@ -105,6 +130,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService); m_Initialized = true; + + scene.AddCommand( + "HG", this, "send inventory", + "send inventory", + "Don't use this", + HandleSendInventory); + } } @@ -369,7 +401,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId); if (root != null) { - m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing root inventory"); + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing root inventory for user {0}", client.AgentId); InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID); UUID[] ids = new UUID[content.Folders.Count]; int i = 0; @@ -388,12 +420,25 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer private void RestoreRootFolderContents(IClientAPI client) { - // Restore the user's inventory, because we removed it earlier on - InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId); - if (root != null) + if (client is IClientCore) { - m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root inventory"); - client.SendBulkUpdateInventory(root); + IClientCore core = (IClientCore)client; + IClientInventory inv; + + if (core.TryGet(out inv)) + { + InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId); + if (root != null) + { + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root inventory for user {0}", client.AgentId); + InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID); + m_log.DebugFormat("[XXX]: Folder name {0}, id {1}, parent {2}", root.Name, root.ID, root.ParentID); + foreach (InventoryItemBase i in content.Items) + m_log.DebugFormat("[XXX]: Name={0}, folderID={1}", i.Name, i.Folder); + + inv.SendBulkUpdateInventory(content.Folders.ToArray(), content.Items.ToArray()); + } + } } } @@ -413,5 +458,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0); return region; } + + protected void HandleSendInventory(string module, string[] cmd) + { + m_Scenes[0].ForEachClient(delegate(IClientAPI client) + { + RestoreRootFolderContents(client); + }); + } + } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 547f66f..19dab32 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1163,22 +1163,6 @@ namespace OpenSim.Region.Framework.Scenes friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); } - // HACK HACK -- just seeing how the viewer responds - // Let's send the Suitcase or the real root folder folder for incoming HG agents - // Visiting agents get their suitcase contents; incoming local users get their real root folder's content - AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(UUID); - if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) - { - // HACK FOR NOW. JUST TESTING, SO KEEPING EVERYONE ELSE OUT OF THESE TESTS - IConfig config = m_scene.Config.Configs["HGEntityTransferModule"]; - if (config != null && config.GetBoolean("RestrictInventoryAccessAbroad", false)) - { - m_log.DebugFormat("[SCENE]: Sending root folder to viewer..."); - InventoryFolderBase root = m_scene.InventoryService.GetRootFolder(client.AgentId); - //InventoryCollection rootContents = InventoryService.GetFolderContent(client.AgentId, root.ID); - client.SendBulkUpdateInventory(root); - } - } // m_log.DebugFormat( // "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", -- cgit v1.1 From 6bf4d88397bb95cf7d8f304604481838edf75280 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 28 Mar 2012 15:32:19 -0700 Subject: HG 2.0 Suitcase inventory: proof of concept now working properly with the heavy SendBulkInventoryUpdate message. Waiting for Melanie to finish the light-weight version of that message. --- .../EntityTransfer/HGEntityTransferModule.cs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index e8d821f..ec260b4 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -428,16 +428,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (core.TryGet(out inv)) { InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId); - if (root != null) - { - m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root inventory for user {0}", client.AgentId); - InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID); - m_log.DebugFormat("[XXX]: Folder name {0}, id {1}, parent {2}", root.Name, root.ID, root.ParentID); - foreach (InventoryItemBase i in content.Items) - m_log.DebugFormat("[XXX]: Name={0}, folderID={1}", i.Name, i.Folder); - - inv.SendBulkUpdateInventory(content.Folders.ToArray(), content.Items.ToArray()); - } + client.SendBulkUpdateInventory(root); + //if (root != null) + //{ + // m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root inventory for user {0}", client.AgentId); + // InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID); + // m_log.DebugFormat("[XXX]: Folder name {0}, id {1}, parent {2}", root.Name, root.ID, root.ParentID); + // foreach (InventoryItemBase i in content.Items) + // m_log.DebugFormat("[XXX]: Name={0}, folderID={1}", i.Name, i.Folder); + + // inv.SendBulkUpdateInventory(content.Folders.ToArray(), content.Items.ToArray()); + //} } } } -- cgit v1.1 From d9f7b8549b3cb9699eb8bd54242d31aac0f8241a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 28 Mar 2012 23:40:25 +0100 Subject: Simplify friends caching by only doing this for root agents - no functions require caching for child agents. This allows us to avoid unnecessary multiple calls to the friends service. All friends functions originate from the root agent and only go to other root agents in existing code. This also allows us to eliminate complex ref counting. --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 4 +- .../CoreModules/Avatar/Friends/FriendsModule.cs | 62 +++++++--------------- .../CoreModules/Avatar/Friends/HGFriendsModule.cs | 6 +-- OpenSim/Region/Framework/Scenes/EventManager.cs | 3 +- OpenSim/Region/Framework/Scenes/Scene.cs | 1 + .../Server/IRCClientView.cs | 4 +- .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 2 +- 7 files changed, 29 insertions(+), 53 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index cd81df5..9899669 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -384,7 +384,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP set { m_startpos = value; } } public UUID AgentId { get { return m_agentId; } } - public ISceneAgent SceneAgent { get; private set; } + public ISceneAgent SceneAgent { get; set; } public UUID ActiveGroupId { get { return m_activeGroupID; } } public string ActiveGroupName { get { return m_activeGroupName; } } public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } } @@ -695,7 +695,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public virtual void Start() { - SceneAgent = m_scene.AddNewClient(this, PresenceType.User); + m_scene.AddNewClient(this, PresenceType.User); RefreshGroupMembership(); } diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index d1a1af0..f3982ea 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -57,7 +57,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { public UUID PrincipalID; public FriendInfo[] Friends; - public int Refcount; public bool IsFriend(string friend) { @@ -255,6 +254,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private void OnNewClient(IClientAPI client) { + if (client.SceneAgent.IsChildAgent) + return; + client.OnInstantMessage += OnInstantMessage; client.OnApproveFriendRequest += OnApproveFriendRequest; client.OnDenyFriendRequest += OnDenyFriendRequest; @@ -281,23 +283,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends UUID agentID = client.AgentId; lock (m_Friends) { - UserFriendData friendsData; - if (m_Friends.TryGetValue(agentID, out friendsData)) - { - friendsData.Refcount++; - return false; - } - else - { - friendsData = new UserFriendData(); - friendsData.PrincipalID = agentID; - friendsData.Friends = GetFriendsFromService(client); - friendsData.Refcount = 1; + UserFriendData friendsData = new UserFriendData(); + friendsData.PrincipalID = agentID; + friendsData.Friends = GetFriendsFromService(client); - m_Friends[agentID] = friendsData; - return true; - } + m_Friends[agentID] = friendsData; } + + return true; } private void OnClientClosed(UUID agentID, Scene scene) @@ -307,23 +300,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { // do this for root agents closing out StatusChange(agentID, false); - } - lock (m_Friends) - { - UserFriendData friendsData; - if (m_Friends.TryGetValue(agentID, out friendsData)) - { - friendsData.Refcount--; - if (friendsData.Refcount <= 0) - m_Friends.Remove(agentID); - } + lock (m_Friends) + m_Friends.Remove(agentID); } } private void OnMakeRootAgent(ScenePresence sp) { - RecacheFriends(sp.ControllingClient); + // FIXME: Ideally, we want to avoid doing this here since it sits the EventManager.OnMakeRootAgent event + // is on the critical path for transferring an avatar from one region to another. + CacheFriends(sp.ControllingClient); } private void OnClientLogin(IClientAPI client) @@ -623,7 +610,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends StoreFriendships(client.AgentId, friendID); // Update the local cache. - RecacheFriends(client); + CacheFriends(client); // // Notify the friend @@ -685,7 +672,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends client.SendAlertMessage("Unable to terminate friendship on this sim."); // Update local cache - RecacheFriends(client); + CacheFriends(client); client.SendTerminateFriend(exfriendID); @@ -799,7 +786,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends friendClient.SendInstantMessage(im); // Update the local cache - RecacheFriends(friendClient); + CacheFriends(friendClient); // we're done return true; @@ -832,7 +819,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // the friend in this sim as root agent friendClient.SendTerminateFriend(exfriendID); // update local cache - RecacheFriends(friendClient); + CacheFriends(friendClient); // we're done return true; } @@ -933,19 +920,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return FriendsService.GetFriends(client.AgentId); } - protected void RecacheFriends(IClientAPI client) - { - // FIXME: Ideally, we want to avoid doing this here since it sits the EventManager.OnMakeRootAgent event - // is on the critical path for transferring an avatar from one region to another. - UUID agentID = client.AgentId; - lock (m_Friends) - { - UserFriendData friendsData; - if (m_Friends.TryGetValue(agentID, out friendsData)) - friendsData.Friends = GetFriendsFromService(client); - } - } - /// /// Are friends cached on this simulator for a particular user? /// diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index e50a84a..7bc3018 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { UUID agentID = client.AgentId; // we do this only for the root agent - if (m_Friends[agentID].Refcount == 1) + if (!client.SceneAgent.IsChildAgent) { // We need to preload the user management cache with the names // of foreign friends, just like we do with SOPs' creators @@ -426,14 +426,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends agentClientCircuit = ((Scene)(agentClient.Scene)).AuthenticateHandler.GetAgentCircuitData(agentClient.CircuitCode); agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit); agentFriendService = agentClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); - RecacheFriends(agentClient); + CacheFriends(agentClient); } if (friendClient != null) { friendClientCircuit = ((Scene)(friendClient.Scene)).AuthenticateHandler.GetAgentCircuitData(friendClient.CircuitCode); friendUUI = Util.ProduceUserUniversalIdentifier(friendClientCircuit); friendFriendService = friendClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); - RecacheFriends(friendClient); + CacheFriends(friendClient); } m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}", diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 7993abe..fe3438e 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -71,6 +71,7 @@ namespace OpenSim.Region.Framework.Scenes /// Triggered when a new client is added to the scene. /// /// + /// This is triggered for both child and root agent client connections. /// Triggered before OnClientLogin. /// public event OnNewClientDelegate OnNewClient; @@ -191,7 +192,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate void ClientClosed(UUID clientID, Scene scene); /// - /// Fired when a client is removed from a scene. + /// Fired when a client is removed from a scene whether it's a child or a root agent. /// /// /// At the point of firing, the scene still contains the client's scene presence. diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c887b4e..60fe48f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2670,6 +2670,7 @@ namespace OpenSim.Region.Framework.Scenes sp.IsChildAgent ? "child" : "root", sp.Name, RegionInfo.RegionName); } + client.SceneAgent = sp; m_LastLogin = Util.EnvironmentTickCount(); // Cache the user's name diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 5cf478a..43548e6 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server private UUID m_agentID = UUID.Random(); - public ISceneAgent SceneAgent { get; private set; } + public ISceneAgent SceneAgent { get; set; } private string m_username; private string m_nick; @@ -895,7 +895,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server public void Start() { - SceneAgent = m_scene.AddNewClient(this, PresenceType.User); + m_scene.AddNewClient(this, PresenceType.User); // Mimicking LLClientView which gets always set appearance from client. AvatarAppearance appearance; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 16ec34f..5ea5af7 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -72,7 +72,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC get { return m_ownerID; } } - public ISceneAgent SceneAgent { get { throw new NotImplementedException(); } } + public ISceneAgent SceneAgent { get; set; } public void Say(string message) { -- cgit v1.1 From 964cae4f37120db34d0d3e2f08ab998215237dfd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 29 Mar 2012 00:21:14 +0100 Subject: Add comment about setting client.SceneAgent in AddNewClient() --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 60fe48f..44cd30a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2670,7 +2670,10 @@ namespace OpenSim.Region.Framework.Scenes sp.IsChildAgent ? "child" : "root", sp.Name, RegionInfo.RegionName); } + // We must set this here so that TriggerOnNewClient and TriggerOnClientLogin can determine whether the + // client is for a root or child agent. client.SceneAgent = sp; + m_LastLogin = Util.EnvironmentTickCount(); // Cache the user's name -- cgit v1.1