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(-) 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 91cc09b7bf5dd876a74413855b75a1197e3813e4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 20 Mar 2012 21:36:24 -0700 Subject: HG Friends config for Robust.HG.ini.example --- bin/Robust.HG.ini.example | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index db9f08b..e0242ab 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example @@ -395,8 +395,12 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 HomeURI = "http://127.0.0.1:8002" [HGFriendsService] - LocalServiceModule = "OpenSim.Services.FriendsService.dll:FriendsService" - UserAgentService = "OpenSim.Services.HypergridService.dll:UserAgentService" + LocalServiceModule = "OpenSim.Services.HypergridService.dll:HGFriendsService" + UserAgentService = "OpenSim.Services.HypergridService.dll:UserAgentService" + FriendsService = "OpenSim.Services.FriendsService.dll:FriendsService" + UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService" + GridService = "OpenSim.Services.GridService.dll:GridService" + PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" [HGInstantMessageService] LocalServiceModule = "OpenSim.Services.HypergridService.dll:HGInstantMessageService" -- 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(-) 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 8ad426f329299ecb702189b1d56ffe7be186bd58 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 21 Mar 2012 08:08:43 -0700 Subject: Removed extraneous debug message --- OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs index ca566f2..e0876cd 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs @@ -197,7 +197,6 @@ namespace OpenSim.Server.Handlers.Hypergrid string message = string.Empty; string name = string.Empty; - m_log.DebugFormat("[HGFRIENDS HANDLER]: Friendship offered"); if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID")) return BoolResult(false); -- 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 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 ++++-- .../Hypergrid/HGFriendsServerPostHandler.cs | 56 +++++++++++ .../Handlers/Hypergrid/UserAgentServerConnector.cs | 1 + .../Hypergrid/HGFriendsServiceConnector.cs | 52 ++++++++++ .../Hypergrid/UserAgentServiceConnector.cs | 1 + .../Services/HypergridService/HGFriendsService.cs | 107 +++++++++++++++++++++ .../Services/HypergridService/UserAgentService.cs | 2 + OpenSim/Services/Interfaces/IHypergridServices.cs | 4 +- 9 files changed, 248 insertions(+), 8 deletions(-) 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()); + } } } } diff --git a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs index e0876cd..8ef03e7 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs @@ -105,6 +105,9 @@ namespace OpenSim.Server.Handlers.Hypergrid case "validate_friendship_offered": return ValidateFriendshipOffered(request); + + case "statusnotification": + return StatusNotification(request); /* case "friendship_approved": return FriendshipApproved(request); @@ -228,6 +231,59 @@ namespace OpenSim.Server.Handlers.Hypergrid return BoolResult(success); } + byte[] StatusNotification(Dictionary request) + { + UUID principalID = UUID.Zero; + if (request.ContainsKey("userID")) + UUID.TryParse(request["userID"].ToString(), out principalID); + else + { + m_log.WarnFormat("[HGFRIENDS HANDLER]: no userID in request to notify"); + return FailureResult(); + } + + bool online = true; + if (request.ContainsKey("online")) + Boolean.TryParse(request["online"].ToString(), out online); + else + { + m_log.WarnFormat("[HGFRIENDS HANDLER]: no online in request to notify"); + return FailureResult(); + } + + List friends = new List(); + int i = 0; + foreach (KeyValuePair kvp in request) + { + if (kvp.Key.Equals("friend_" + i.ToString())) + { + friends.Add(kvp.Value.ToString()); + i++; + } + } + + List onlineFriends = m_TheService.StatusNotification(friends, principalID, online); + + Dictionary result = new Dictionary(); + if ((onlineFriends == null) || ((onlineFriends != null) && (onlineFriends.Count == 0))) + result["RESULT"] = "NULL"; + else + { + i = 0; + foreach (UUID f in onlineFriends) + { + result["friend_" + i] = f.ToString(); + i++; + } + } + + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); + + } + #endregion diff --git a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs index 9a0e27e..db62aaa 100644 --- a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs @@ -222,6 +222,7 @@ namespace OpenSim.Server.Handlers.Hypergrid } + [Obsolete] public XmlRpcResponse StatusNotification(XmlRpcRequest request, IPEndPoint remoteClient) { Hashtable hash = new Hashtable(); diff --git a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs index e3f3260..e984a54 100644 --- a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs @@ -255,6 +255,58 @@ namespace OpenSim.Services.Connectors.Hypergrid return false; } + + public List StatusNotification(List friends, UUID userID, bool online) + { + Dictionary sendData = new Dictionary(); + List friendsOnline = new List(); + + sendData["METHOD"] = "statusnotification"; + sendData["userID"] = userID.ToString(); + sendData["online"] = online.ToString(); + int i = 0; + foreach (string s in friends) + { + sendData["friend_" + i.ToString()] = s; + i++; + } + + string reply = string.Empty; + string uri = m_ServerURI + "/hgfriends"; + try + { + reply = SynchronousRestFormsRequester.MakeRequest("POST", + uri, + ServerUtils.BuildQueryString(sendData)); + } + catch (Exception e) + { + m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server at {0}: {1}", uri, e.Message); + return friendsOnline; + } + + if (reply != string.Empty) + { + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + // Here is the actual response + foreach (string key in replyData.Keys) + { + if (key.StartsWith("friend_") && replyData[key] != null) + { + UUID uuid; + if (UUID.TryParse(replyData[key].ToString(), out uuid)) + friendsOnline.Add(uuid); + } + } + } + else + m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Received empty reply from remote StatusNotify"); + + return friendsOnline; + + } + #endregion } } \ No newline at end of file diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index bf86035..2f263ae 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs @@ -417,6 +417,7 @@ namespace OpenSim.Services.Connectors.Hypergrid GetBoolResponse(request, out reason); } + [Obsolete] public List StatusNotification(List friends, UUID userID, bool online) { Hashtable hash = new Hashtable(); diff --git a/OpenSim/Services/HypergridService/HGFriendsService.cs b/OpenSim/Services/HypergridService/HGFriendsService.cs index 19ee3e2..39524ab 100644 --- a/OpenSim/Services/HypergridService/HGFriendsService.cs +++ b/OpenSim/Services/HypergridService/HGFriendsService.cs @@ -214,6 +214,91 @@ namespace OpenSim.Services.HypergridService return false; } + public List StatusNotification(List friends, UUID foreignUserID, bool online) + { + if (m_FriendsService == null || m_PresenceService == null) + { + m_log.WarnFormat("[HGFRIENDS SERVICE]: Unable to perform status notifications because friends or presence services are missing"); + return new List(); + } + + // Let's unblock the caller right now, and take it from here async + + List localFriendsOnline = new List(); + + m_log.DebugFormat("[HGFRIENDS SERVICE]: Status notification: foreign user {0} wants to notify {1} local friends of {2} status", + foreignUserID, friends.Count, (online ? "online" : "offline")); + + // First, let's double check that the reported friends are, indeed, friends of that user + // And let's check that the secret matches + List usersToBeNotified = new List(); + foreach (string uui in friends) + { + UUID localUserID; + string secret = string.Empty, tmp = string.Empty; + if (Util.ParseUniversalUserIdentifier(uui, out localUserID, out tmp, out tmp, out tmp, out secret)) + { + FriendInfo[] friendInfos = m_FriendsService.GetFriends(localUserID); + foreach (FriendInfo finfo in friendInfos) + { + if (finfo.Friend.StartsWith(foreignUserID.ToString()) && finfo.Friend.EndsWith(secret)) + { + // great! + usersToBeNotified.Add(localUserID.ToString()); + } + } + } + } + + // Now, let's send the notifications + //m_log.DebugFormat("[HGFRIENDS SERVICE]: Status notification: user has {0} local friends", usersToBeNotified.Count); + + // First, let's send notifications to local users who are online in the home grid + PresenceInfo[] friendSessions = m_PresenceService.GetAgents(usersToBeNotified.ToArray()); + if (friendSessions != null && friendSessions.Length > 0) + { + PresenceInfo friendSession = null; + foreach (PresenceInfo pinfo in friendSessions) + if (pinfo.RegionID != UUID.Zero) // let's guard against traveling agents + { + friendSession = pinfo; + break; + } + + if (friendSession != null) + { + ForwardStatusNotificationToSim(friendSession.RegionID, foreignUserID, friendSession.UserID, online); + usersToBeNotified.Remove(friendSession.UserID.ToString()); + UUID id; + if (UUID.TryParse(friendSession.UserID, out id)) + localFriendsOnline.Add(id); + + } + } + + // Lastly, let's notify the rest who may be online somewhere else + foreach (string user in usersToBeNotified) + { + UUID id = new UUID(user); + //m_UserAgentService.LocateUser(id); + //etc... + //if (m_TravelingAgents.ContainsKey(id) && m_TravelingAgents[id].GridExternalName != m_GridName) + //{ + // string url = m_TravelingAgents[id].GridExternalName; + // // forward + //} + //m_log.WarnFormat("[HGFRIENDS SERVICE]: User {0} is visiting another grid. HG Status notifications still not implemented.", user); + } + + // and finally, let's send the online friends + if (online) + { + return localFriendsOnline; + } + else + return new List(); + } + #endregion IHGFriendsService #region Aux @@ -296,6 +381,28 @@ namespace OpenSim.Services.HypergridService return false; } + protected void ForwardStatusNotificationToSim(UUID regionID, UUID foreignUserID, string user, bool online) + { + UUID userID; + if (UUID.TryParse(user, out userID)) + { + if (m_FriendsLocalSimConnector != null) + { + m_log.DebugFormat("[HGFRIENDS SERVICE]: Local Notify, user {0} is {1}", foreignUserID, (online ? "online" : "offline")); + m_FriendsLocalSimConnector.StatusNotify(foreignUserID, userID, online); + } + else + { + GridRegion region = m_GridService.GetRegionByUUID(UUID.Zero /* !!! */, regionID); + if (region != null) + { + m_log.DebugFormat("[HGFRIENDS SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, foreignUserID, (online ? "online" : "offline")); + m_FriendsSimConnector.StatusNotify(region, foreignUserID, userID, online); + } + } + } + } + #endregion Aux } } diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs index 5eca801..6a5007f 100644 --- a/OpenSim/Services/HypergridService/UserAgentService.cs +++ b/OpenSim/Services/HypergridService/UserAgentService.cs @@ -334,6 +334,7 @@ namespace OpenSim.Services.HypergridService return false; } + [Obsolete] public List StatusNotification(List friends, UUID foreignUserID, bool online) { if (m_FriendsService == null || m_PresenceService == null) @@ -414,6 +415,7 @@ namespace OpenSim.Services.HypergridService return new List(); } + [Obsolete] protected void ForwardStatusNotificationToSim(UUID regionID, UUID foreignUserID, string user, bool online) { UUID userID; diff --git a/OpenSim/Services/Interfaces/IHypergridServices.cs b/OpenSim/Services/Interfaces/IHypergridServices.cs index f48b8a9..3dc877a 100644 --- a/OpenSim/Services/Interfaces/IHypergridServices.cs +++ b/OpenSim/Services/Interfaces/IHypergridServices.cs @@ -65,8 +65,8 @@ namespace OpenSim.Services.Interfaces UUID GetUUID(String first, String last); // Returns the local friends online + [Obsolete] List StatusNotification(List friends, UUID userID, bool online); - //List GetOnlineFriends(UUID userID, List friends); bool IsAgentComingHome(UUID sessionID, string thisGridExternalName); bool VerifyAgent(UUID sessionID, string token); @@ -92,6 +92,8 @@ namespace OpenSim.Services.Interfaces bool DeleteFriendship(FriendInfo finfo, string secret); bool FriendshipOffered(UUID from, string fromName, UUID to, string message); bool ValidateFriendshipOffered(UUID fromID, UUID toID); + // Returns the local friends online + List StatusNotification(List friends, UUID userID, bool online); } public interface IInstantMessageSimConnector -- cgit v1.1 From 5170cd75775eb85922783fa8afe4f8025c054189 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 21 Mar 2012 11:22:39 -0700 Subject: Updated the UserAccountsClient a little bit, plus some more sanity checks on the service connector. --- .../UserAccounts/UserAccountServiceConnector.cs | 9 ++- .../Clients/UserAccounts/UserAccountsClient.cs | 66 +++++++++++++++------- 2 files changed, 53 insertions(+), 22 deletions(-) diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs index 609dafe..6d5ce28 100644 --- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs +++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs @@ -197,8 +197,15 @@ namespace OpenSim.Services.Connectors Dictionary structData = data.ToKeyValuePairs(); - foreach (KeyValuePair kvp in structData) + foreach (KeyValuePair kvp in structData) + { + if (kvp.Value == null) + { + m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Null value for {0}", kvp.Key); + continue; + } sendData[kvp.Key] = kvp.Value.ToString(); + } return SendAndGetBoolReply(sendData); } diff --git a/OpenSim/Tests/Clients/UserAccounts/UserAccountsClient.cs b/OpenSim/Tests/Clients/UserAccounts/UserAccountsClient.cs index 56195b1..1e0a35b 100644 --- a/OpenSim/Tests/Clients/UserAccounts/UserAccountsClient.cs +++ b/OpenSim/Tests/Clients/UserAccounts/UserAccountsClient.cs @@ -62,25 +62,39 @@ namespace OpenSim.Tests.Clients.PresenceClient string last = "Clueless"; string email = "foo@bar.com"; - UserAccount account = new UserAccount(user1); - account.FirstName = first; - account.LastName = last; - account.Email = email; - account.ServiceURLs = new Dictionary(); - account.ServiceURLs.Add("InventoryServerURI", "http://cnn.com"); - account.ServiceURLs.Add("AssetServerURI", "http://cnn.com"); - - bool success = m_Connector.StoreUserAccount(account); - if (success) - m_log.InfoFormat("[USER CLIENT]: Successfully created account for user {0} {1}", account.FirstName, account.LastName); - else - m_log.InfoFormat("[USER CLIENT]: failed to create user {0} {1}", account.FirstName, account.LastName); + //UserAccount account = new UserAccount(user1); + //account.ScopeID = UUID.Zero; + //account.FirstName = first; + //account.LastName = last; + //account.Email = email; + //account.ServiceURLs = new Dictionary(); + //account.ServiceURLs.Add("InventoryServerURI", "http://cnn.com"); + //account.ServiceURLs.Add("AssetServerURI", "http://cnn.com"); - System.Console.WriteLine("\n"); + //bool success = m_Connector.StoreUserAccount(account); + //if (success) + // m_log.InfoFormat("[USER CLIENT]: Successfully created account for user {0} {1}", account.FirstName, account.LastName); + //else + // m_log.InfoFormat("[USER CLIENT]: failed to create user {0} {1}", account.FirstName, account.LastName); - account = m_Connector.GetUserAccount(UUID.Zero, user1); + //System.Console.WriteLine("\n"); + + //account = m_Connector.GetUserAccount(UUID.Zero, user1); + //if (account == null) + // m_log.InfoFormat("[USER CLIENT]: Unable to retrieve accouny by UUID for {0}", user1); + //else + //{ + // m_log.InfoFormat("[USER CLIENT]: Account retrieved correctly: userID={0}; FirstName={1}; LastName={2}; Email={3}", + // account.PrincipalID, account.FirstName, account.LastName, account.Email); + // foreach (KeyValuePair kvp in account.ServiceURLs) + // m_log.DebugFormat("\t {0} -> {1}", kvp.Key, kvp.Value); + //} + + //System.Console.WriteLine("\n"); + + UserAccount account = m_Connector.GetUserAccount(UUID.Zero, first, last); if (account == null) - m_log.InfoFormat("[USER CLIENT]: Unable to retrieve accouny by UUID for {0}", user1); + m_log.InfoFormat("[USER CLIENT]: Unable to retrieve accouny by name "); else { m_log.InfoFormat("[USER CLIENT]: Account retrieved correctly: userID={0}; FirstName={1}; LastName={2}; Email={3}", @@ -90,10 +104,9 @@ namespace OpenSim.Tests.Clients.PresenceClient } System.Console.WriteLine("\n"); - - account = m_Connector.GetUserAccount(UUID.Zero, first, last); + account = m_Connector.GetUserAccount(UUID.Zero, email); if (account == null) - m_log.InfoFormat("[USER CLIENT]: Unable to retrieve accouny by name for {0}", user1); + m_log.InfoFormat("[USER CLIENT]: Unable to retrieve accouny by email"); else { m_log.InfoFormat("[USER CLIENT]: Account retrieved correctly: userID={0}; FirstName={1}; LastName={2}; Email={3}", @@ -103,9 +116,9 @@ namespace OpenSim.Tests.Clients.PresenceClient } System.Console.WriteLine("\n"); - account = m_Connector.GetUserAccount(UUID.Zero, email); + account = m_Connector.GetUserAccount(UUID.Zero, user1); if (account == null) - m_log.InfoFormat("[USER CLIENT]: Unable to retrieve accouny by email for {0}", user1); + m_log.InfoFormat("[USER CLIENT]: Unable to retrieve accouny by UUID for {0}", user1); else { m_log.InfoFormat("[USER CLIENT]: Account retrieved correctly: userID={0}; FirstName={1}; LastName={2}; Email={3}", @@ -114,6 +127,17 @@ namespace OpenSim.Tests.Clients.PresenceClient m_log.DebugFormat("\t {0} -> {1}", kvp.Key, kvp.Value); } + System.Console.WriteLine("\n"); + account = m_Connector.GetUserAccount(UUID.Zero, "DoesNot", "Exist"); + if (account == null) + m_log.InfoFormat("[USER CLIENT]: Unable to retrieve account 'DoesNot Exist'"); + else + { + m_log.InfoFormat("[USER CLIENT]: Account 'DoesNot Exist' retrieved correctly. REALLY??? userID={0}; FirstName={1}; LastName={2}; Email={3}", + account.PrincipalID, account.FirstName, account.LastName, account.Email); + foreach (KeyValuePair kvp in account.ServiceURLs) + m_log.DebugFormat("\t {0} -> {1}", kvp.Key, kvp.Value); + } } } -- cgit v1.1