From 2fe669448f8cfefe2ef6e046faec3c0e709a41e4 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Mon, 10 May 2010 05:43:16 -0700 Subject: Greatly improve login time for users with large friends lists by requesting all unknown UUID's in one go rather than individually --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 45 +++++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index febd4ca..57dde76 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -67,7 +67,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return false; } } - + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected List m_Scenes = new List(); @@ -234,7 +234,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends newFriends.RegionID = UUID.Zero; m_Friends.Add(client.AgentId, newFriends); - + //StatusChange(client.AgentId, true); } @@ -289,7 +289,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // Inform the friends that this user is online StatusChange(agentID, true); - + // Register that we need to send the list of online friends to this user lock (m_NeedsListOfFriends) if (!m_NeedsListOfFriends.Contains(agentID)) @@ -442,11 +442,44 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (((fi.MyFlags & 1) != 0) && (fi.TheirFlags != -1)) friendList.Add(fi); } + /* foreach (FriendInfo fi in friendList) { // Notify about this user status StatusNotify(fi, agentID, online); } + */ + + StatusNotifyMass(friendList, agentID, online); + } + } + + private void StatusNotifyMass(List friendList, UUID userID, bool online) + { + string[] friendIDs = new string[friendList.Count]; + int notlocal = 0; + for (int x = 0; x < friendList.Count; x++) + { + UUID friendID = UUID.Zero; + if (UUID.TryParse(friendList[x].Friend, out friendID)) + { + if (!LocalStatusNotification(userID, friendID, online)) + { + friendIDs[notlocal++] = friendID.ToString(); + } + } + } + + PresenceInfo[] friendSessions = PresenceService.GetAgents(friendIDs); + + for (int x = 0; x < friendSessions.GetLength(0); x++) + { + PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + m_FriendsSimConnector.StatusNotify(region, userID, new UUID(friendIDs[x]), online); + } } } @@ -459,7 +492,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // Try local if (LocalStatusNotification(userID, friendID, online)) return; - + // The friend is not here [as root]. Let's forward. PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); @@ -476,7 +509,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private void OnInstantMessage(IClientAPI client, GridInstantMessage im) { if (im.dialog == (byte)OpenMetaverse.InstantMessageDialog.FriendshipOffered) - { + { // we got a friendship offer UUID principalID = new UUID(im.fromAgentID); UUID friendID = new UUID(im.toAgentID); @@ -688,7 +721,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // we're done return true; } - + return false; } -- cgit v1.1