From d49dd5573b3ba73e0a6065eada827037bb51ff39 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 20 Mar 2012 21:36:02 -0700 Subject: Removed extraneous debug messages. Added a check for UUID.Zero. --- .../CoreModules/Avatar/Friends/HGFriendsModule.cs | 39 +++++++++++++--------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index 0fe1134..46b0b84 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -261,25 +261,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // fid is not a UUID... string url = string.Empty, tmp = string.Empty, f = string.Empty, l = string.Empty; - m_log.DebugFormat("[YYY]: FID {0}", fid); if (Util.ParseUniversalUserIdentifier(fid, out agentID, out url, out f, out l, out tmp)) { - m_log.DebugFormat("[YYY]: Adding user {0} {1} {2}", f, l, url); - m_uMan.AddUser(agentID, f, l, url); - - string name = m_uMan.GetUserName(agentID); - string[] parts = name.Trim().Split(new char[] {' '}); - if (parts.Length == 2) - { - first = parts[0]; - last = parts[1]; - } - else + if (!agentID.Equals(UUID.Zero)) { - first = f; - last = l; + m_uMan.AddUser(agentID, f, l, url); + + string name = m_uMan.GetUserName(agentID); + string[] parts = name.Trim().Split(new char[] { ' ' }); + if (parts.Length == 2) + { + first = parts[0]; + last = parts[1]; + } + else + { + first = f; + last = l; + } + return true; } - return true; } return false; } @@ -744,7 +745,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { string[] parts = im.fromAgentName.Split(new char[] { '@' }); if (parts.Length == 2) - m_uMan.AddUser(new UUID(im.fromAgentID), parts[0], "http://" + parts[1]); + { + string[] fl = parts[0].Trim().Split(new char[] { '.' }); + if (fl.Length == 2) + m_uMan.AddUser(new UUID(im.fromAgentID), fl[0], fl[1], "http://" + parts[1]); + else + m_uMan.AddUser(new UUID(im.fromAgentID), fl[0], "", "http://" + parts[1]); + } } return true; } -- cgit v1.1 From 1089e9b842ae359d9dcdae11145d5f329041c75e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 21 Mar 2012 08:08:12 -0700 Subject: Removed extraneous debug message --- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index f6a31b5..753c0a3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -582,10 +582,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // Try the local sim if (LocalFriendshipOffered(friendID, im)) - { - m_log.DebugFormat("[XXX]: LocalFriendshipOffered successes"); return true; - } // The prospective friend is not here [as root]. Let's forward. PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); -- cgit v1.1 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/CoreModules') 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 From 4a9ca3ca8ff18f4fcf05c3983db5e6b1d49c97ee Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 21 Mar 2012 10:35:06 -0700 Subject: HG Friends: reroute the status notifications to the HGFriends service, so that they can scale better. They were previously being handled by the UAS; that is still there, but it's now obsolete and will be removed in a future release. --- .../CoreModules/Avatar/Friends/HGFriendsModule.cs | 2 +- .../CoreModules/Avatar/Friends/HGStatusNotifier.cs | 31 +++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index f50e52b..e50a84a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -51,7 +51,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); IUserManagement m_uMan; - IUserManagement UserManagementModule + public IUserManagement UserManagementModule { get { diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs index 62d54e4..61c6a30 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; @@ -10,10 +11,14 @@ using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; using OpenMetaverse; +using log4net; + namespace OpenSim.Region.CoreModules.Avatar.Friends { public class HGStatusNotifier { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private HGFriendsModule m_FriendsModule; public HGStatusNotifier(HGFriendsModule friendsModule) @@ -31,14 +36,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends 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) + if (ids.Count == 0) + continue; // no one to notify. caller don't do this + + m_log.DebugFormat("[HG STATUS NOTIFIER]: Notifying {0} friends in {1}", ids.Count, kvp.Key); + // ASSUMPTION: we assume that all users for one home domain + // have exactly the same set of service URLs. + // If this is ever not true, we need to change this. + UUID friendID = UUID.Zero; String tmp = String.Empty; + if (Util.ParseUniversalUserIdentifier(ids[0], out friendID, out tmp, out tmp, out tmp, out tmp)) { - IClientAPI client = m_FriendsModule.LocateClientObject(userID); - if (client != null) - client.SendAgentOnline(friendsOnline.ToArray()); + string friendsServerURI = m_FriendsModule.UserManagementModule.GetUserServerURL(friendID, "FriendsServerURI"); + HGFriendsServicesConnector fConn = new HGFriendsServicesConnector(friendsServerURI); + + List friendsOnline = fConn.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