From d8bcb78b10faf1e4b213a7caa7ee8fcb8d10cf52 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 21 Mar 2012 09:14:17 -0700 Subject: HG Friends: pulled sim-bound notification code to HGStatusNotifier, so that we can better manage this traffic. --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 2 +- .../CoreModules/Avatar/Friends/HGFriendsModule.cs | 29 +++++-------- .../CoreModules/Avatar/Friends/HGStatusNotifier.cs | 47 ++++++++++++++++++++++ 3 files changed, 58 insertions(+), 20 deletions(-) create mode 100644 OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 753c0a3..be767c4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -212,7 +212,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends scene.EventManager.OnClientLogin += OnClientLogin; } - public void RegionLoaded(Scene scene) + public virtual void RegionLoaded(Scene scene) { } diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index 46b0b84..f50e52b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -62,6 +62,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } protected HGFriendsServicesConnector m_HGFriendsConnector = new HGFriendsServicesConnector(); + protected HGStatusNotifier m_StatusNotifier; #region ISharedRegionModule public override string Name @@ -78,6 +79,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends scene.RegisterModuleInterface(this); } + public override void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + if (m_StatusNotifier == null) + m_StatusNotifier = new HGStatusNotifier(this); + } + #endregion #region IFriendsSimConnector @@ -230,25 +239,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (friendsPerDomain.ContainsKey("local")) base.StatusNotify(friendsPerDomain["local"], userID, online); - foreach (KeyValuePair> kvp in friendsPerDomain) - { - if (kvp.Key != "local") - { - // For the others, call the user agent service - List ids = new List(); - foreach (FriendInfo f in kvp.Value) - ids.Add(f.Friend); - UserAgentServiceConnector uConn = new UserAgentServiceConnector(kvp.Key); - List friendsOnline = uConn.StatusNotification(ids, userID, online); - - if (online && friendsOnline.Count > 0) - { - IClientAPI client = LocateClientObject(userID); - if (client != null) - client.SendAgentOnline(friendsOnline.ToArray()); - } - } - } + m_StatusNotifier.Notify(userID, friendsPerDomain, online); // m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting StatusNotify for {0}", userID); } diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs new file mode 100644 index 0000000..62d54e4 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Connectors.Hypergrid; +using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; + +using OpenMetaverse; + +namespace OpenSim.Region.CoreModules.Avatar.Friends +{ + public class HGStatusNotifier + { + private HGFriendsModule m_FriendsModule; + + public HGStatusNotifier(HGFriendsModule friendsModule) + { + m_FriendsModule = friendsModule; + } + + public void Notify(UUID userID, Dictionary> friendsPerDomain, bool online) + { + foreach (KeyValuePair> kvp in friendsPerDomain) + { + if (kvp.Key != "local") + { + // For the others, call the user agent service + List ids = new List(); + foreach (FriendInfo f in kvp.Value) + ids.Add(f.Friend); + UserAgentServiceConnector uConn = new UserAgentServiceConnector(kvp.Key); + List friendsOnline = uConn.StatusNotification(ids, userID, online); + + if (online && friendsOnline.Count > 0) + { + IClientAPI client = m_FriendsModule.LocateClientObject(userID); + if (client != null) + client.SendAgentOnline(friendsOnline.ToArray()); + } + } + } + } + } +} -- cgit v1.1