diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index b693f2d5ef..31bcdedebd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -93,6 +93,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends /// protected Dictionary m_Friends = new Dictionary(); + /// + /// Maintain a record of clients that need to notify about their online status. This only + /// needs to be done on login. Subsequent online/offline friend changes are sent by a different mechanism. + /// + protected HashSet m_NeedsToNotifyStatus = new HashSet(); + /// /// Maintain a record of viewers that need to be sent notifications for friends that are online. This only /// needs to be done on login. Subsequent online/offline friend changes are sent by a different mechanism. @@ -324,6 +330,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private void OnMakeRootAgent(ScenePresence sp) { RecacheFriends(sp.ControllingClient); + + lock (m_NeedsToNotifyStatus) + { + if (m_NeedsToNotifyStatus.Remove(sp.UUID)) + { + // Inform the friends that this user is online. This can only be done once the client is a Root Agent. + StatusChange(sp.UUID, true); + } + } } private void OnClientLogin(IClientAPI client) @@ -331,8 +346,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends UUID agentID = client.AgentId; //m_log.DebugFormat("[XXX]: OnClientLogin!"); - // Inform the friends that this user is online - StatusChange(agentID, true); + + // Register that we need to send this user's status to friends. This can only be done + // once the client becomes a Root Agent, because as part of sending out the presence + // we also get back the presence of the HG friends, and we need to send that to the + // client, but that can only be done when the client is a Root Agent. + lock (m_NeedsToNotifyStatus) + m_NeedsToNotifyStatus.Add(agentID); // Register that we need to send the list of online friends to this user lock (m_NeedsListOfOnlineFriends) diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index d00945ed16..be129359c5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -239,6 +239,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends fList.Add(s.Substring(0, 36)); } + // FIXME: also query the presence status of friends in other grids (like in HGStatusNotifier.Notify()) + PresenceInfo[] presence = PresenceService.GetAgents(fList.ToArray()); foreach (PresenceInfo pi in presence) {