From 86defd0a69d53df6d352b7d4b9a5b9d6621c19e8 Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 28 Jun 2008 15:13:17 +0000 Subject: plumbing for multiple inventory servers. Mostly done on the region server side. TODO next is to make the login server read/write a users inventory from the correct server (the inventory url set in a userprofile) On the region side, although not tested with multiple servers it should work if that inventory url was set, and the inventory servers urls have been added to the CommunicationsManager, using CommunicationsManager.AddInventoryService(string hostUrl) --- .../Communications/Cache/CachedUserInfo.cs | 116 +++++++++++++++++---- .../Cache/UserProfileCacheService.cs | 7 +- .../Communications/CommunicationsManager.cs | 72 +++++++++++-- OpenSim/Framework/Communications/IAvatarService.cs | 21 ++++ .../Framework/Communications/IInventoryServices.cs | 4 + OpenSim/Framework/Communications/IUserService.cs | 8 +- .../Communications/InventoryServiceBase.cs | 5 + 7 files changed, 198 insertions(+), 35 deletions(-) create mode 100644 OpenSim/Framework/Communications/IAvatarService.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 3127bd6..524f314 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -87,6 +87,24 @@ namespace OpenSim.Framework.Communications.Cache private IDictionary> pendingCategorizationFolders = new Dictionary>(); + private string m_inventoryHost + { + get + { + if (m_userProfile != null) + { + if (m_userProfile.UserInventoryURI != String.Empty) + { + Uri uri = new Uri(m_userProfile.UserInventoryURI); + return uri.Host; + } + } + + return ""; + } + + } + /// /// Constructor /// @@ -325,9 +343,15 @@ namespace OpenSim.Framework.Communications.Cache createdBaseFolder.Type = createdFolder.Type; createdBaseFolder.Version = createdFolder.Version; - m_commsManager.InventoryService.AddFolder(createdBaseFolder); + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //m_commsManager.InventoryService + invService.AddFolder(createdBaseFolder); + return true; + } - return true; + return false; } else { @@ -379,14 +403,19 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.Type = (short) type; baseFolder.Version = RootFolder.Version; - m_commsManager.InventoryService.UpdateFolder(baseFolder); - - InventoryFolderImpl folder=RootFolder.FindFolder(folderID); - if(folder != null) - { - folder.Name = name; - folder.ParentID = parentID; - } + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //m_commsManager.InventoryService. + invService.UpdateFolder(baseFolder); + + InventoryFolderImpl folder = RootFolder.FindFolder(folderID); + if (folder != null) + { + folder.Name = name; + folder.ParentID = parentID; + } + } } else { @@ -421,13 +450,24 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.ID = folderID; baseFolder.ParentID = parentID; - m_commsManager.InventoryService.MoveFolder(baseFolder); - - InventoryFolderImpl folder=RootFolder.FindFolder(folderID); - if(folder != null) - folder.ParentID = parentID; - - return true; + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + // m_commsManager.InventoryService + invService.MoveFolder(baseFolder); + + InventoryFolderImpl folder = RootFolder.FindFolder(folderID); + if (folder != null) + { + folder.ParentID = parentID; + } + + return true; + } + else + { + return false; + } } else { @@ -468,11 +508,16 @@ namespace OpenSim.Framework.Communications.Cache purgedBaseFolder.Type = purgedFolder.Type; purgedBaseFolder.Version = purgedFolder.Version; - m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder); + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //m_commsManager.InventoryService + invService.PurgeFolder(purgedBaseFolder); - purgedFolder.Purge(); + purgedFolder.Purge(); - return true; + return true; + } } } else @@ -505,7 +550,13 @@ namespace OpenSim.Framework.Communications.Cache item.Folder=RootFolder.ID; } ItemReceive(item); - m_commsManager.InventoryService.AddItem(item); + + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //m_commsManager.InventoryService + invService.AddItem(item); + } } else { @@ -525,7 +576,12 @@ namespace OpenSim.Framework.Communications.Cache { if (HasInventory) { - m_commsManager.InventoryService.UpdateItem(item); + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //m_commsManager.InventoryService + invService.UpdateItem(item); + } } else { @@ -564,7 +620,14 @@ namespace OpenSim.Framework.Communications.Cache if (RootFolder.DeleteItem(item.ID)) { - return m_commsManager.InventoryService.DeleteItem(item); + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //return m_commsManager.InventoryService + return invService.DeleteItem(item); + } + + return false; } } else @@ -641,6 +704,13 @@ namespace OpenSim.Framework.Communications.Cache } return null; } + + public IInventoryServices GetInventoryService() + { + IInventoryServices invService; + m_commsManager.TryGetInventoryService(m_inventoryHost, out invService); + return invService; + } } /// diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index fe61406..37451ab 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -119,7 +119,12 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userInfo = GetUserDetails(userID); if (userInfo != null) { - m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.InventoryReceive); + //m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.InventoryReceive); + IInventoryServices invService = userInfo.GetInventoryService(); + if (invService != null) + { + invService.RequestInventoryForUser(userID, userInfo.InventoryReceive); + } } else { diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 5de0c71..0410f0e 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -55,12 +55,6 @@ namespace OpenSim.Framework.Communications get { return m_gridService; } } - protected IInventoryServices m_inventoryService; - - public IInventoryServices InventoryService - { - get { return m_inventoryService; } - } protected IInterRegionCommunications m_interRegion; @@ -106,6 +100,70 @@ namespace OpenSim.Framework.Communications // m_transactionsManager = new AgentAssetTransactionsManager(this, dumpAssetsToFile); } + #region Inventory + protected string m_defaultInventoryHost = "default"; + + protected List m_inventoryServices = new List(); + // protected IInventoryServices m_inventoryService; + + public IInventoryServices InventoryService + { + get + { + if (m_inventoryServices.Count > 0) + { + // return m_inventoryServices[0]; + IInventoryServices invService; + if (TryGetInventoryService(m_defaultInventoryHost, out invService)) + { + return invService; + } + + } + + return null; + } + } + + public bool TryGetInventoryService(string host, out IInventoryServices inventoryService) + { + if ((host == string.Empty) | (host == "default")) + { + host = m_defaultInventoryHost; + } + + + lock (m_inventoryServices) + { + foreach (IInventoryServices service in m_inventoryServices) + { + if (service.Host == host) + { + inventoryService = service; + return true; + } + } + } + + inventoryService = null; + return false; + } + + public virtual void AddInventoryService(string hostUrl) + { + + } + + public virtual void AddInventoryService(IInventoryServices service) + { + lock (m_inventoryServices) + { + m_inventoryServices.Add(service); + } + } + + #endregion + public void doCreate(string[] cmmdParams) { switch (cmmdParams[0]) @@ -167,7 +225,7 @@ namespace OpenSim.Framework.Communications } else { - m_inventoryService.CreateNewUserInventory(userProf.ID); + InventoryService.CreateNewUserInventory(userProf.ID); m_log.Info("[USERS]: Created new inventory set for " + firstName + " " + lastName); return userProf.ID; } diff --git a/OpenSim/Framework/Communications/IAvatarService.cs b/OpenSim/Framework/Communications/IAvatarService.cs new file mode 100644 index 0000000..fdac53f --- /dev/null +++ b/OpenSim/Framework/Communications/IAvatarService.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Communications +{ + public interface IAvatarService + { + /// Get's the User Appearance + AvatarAppearance GetUserAppearance(LLUUID user); + + void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); + + void AddAttachment(LLUUID user, LLUUID attach); + + void RemoveAttachment(LLUUID user, LLUUID attach); + + List GetAttachments(LLUUID user); + } +} diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 8dc09bc..3929a4e 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -42,6 +42,10 @@ namespace OpenSim.Framework.Communications /// public interface IInventoryServices { + string Host + { + get; + } /// /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the /// inventory has been received diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index a7f19e7..f8ef358 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -112,16 +112,16 @@ namespace OpenSim.Framework.Communications List GetUserFriendList(LLUUID friendlistowner); /// - /// Get's the User Appearance - AvatarAppearance GetUserAppearance(LLUUID user); - - /// /// Updates the current region the User is in /// /// User Region the Avatar is IN /// User Region the Avatar is IN void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle); + /// + /// Get's the User Appearance + AvatarAppearance GetUserAppearance(LLUUID user); + void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); void AddAttachment(LLUUID user, LLUUID attach); diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 89ccf93..d26a3bb 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -81,6 +81,11 @@ namespace OpenSim.Framework.Communications #region IInventoryServices methods + public string Host + { + get { return "default"; } + } + // See IInventoryServices public List GetInventorySkeleton(LLUUID userId) { -- cgit v1.1