From 0c58a9e68074f3593920dc9f2356bbed96416497 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 26 May 2011 10:04:48 -0700 Subject: HG IM in grid mode working fairly well. Unknown target user references looked back in source user's User Agent service. --- .../HypergridService/HGInstantMessageService.cs | 22 ++++++++++++-------- .../Services/HypergridService/UserAgentService.cs | 24 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 8 deletions(-) (limited to 'OpenSim/Services/HypergridService') diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs index 6178ca1..ca0fd7f 100644 --- a/OpenSim/Services/HypergridService/HGInstantMessageService.cs +++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs @@ -64,8 +64,8 @@ namespace OpenSim.Services.HypergridService protected static IInstantMessageSimConnector m_IMSimConnector; - protected Dictionary m_UserLocationMap = new Dictionary(); - private ExpiringCache m_RegionCache; + protected static Dictionary m_UserLocationMap = new Dictionary(); + private static ExpiringCache m_RegionCache; public HGInstantMessageService(IConfigSource config) : this(config, null) @@ -155,6 +155,8 @@ namespace OpenSim.Services.HypergridService if (!firstTime) { lookupAgent = true; + upd = null; + url = string.Empty; } } else @@ -168,7 +170,6 @@ namespace OpenSim.Services.HypergridService // Are we needing to look-up an agent? if (lookupAgent) { - bool isPresent = false; // Non-cached user agent lookup. PresenceInfo[] presences = m_PresenceService.GetAgents(new string[] { toAgentID.ToString() }); if (presences != null && presences.Length > 0) @@ -177,17 +178,17 @@ namespace OpenSim.Services.HypergridService { if (p.RegionID != UUID.Zero) { + m_log.DebugFormat("[XXX]: Found presence in {0}", p.RegionID); upd = p; break; } - else - isPresent = true; } } - if (upd == null && isPresent) + if (upd == null) { // Let's check with the UAS if the user is elsewhere + m_log.DebugFormat("[HG IM SERVICE]: User is not present. Checking location with User Agent service"); url = m_UserAgentService.LocateUser(toAgentID); } @@ -197,10 +198,10 @@ namespace OpenSim.Services.HypergridService // This is one way to end the recursive loop // if (!firstTime && ((previousLocation is PresenceInfo && upd != null && upd.RegionID == ((PresenceInfo)previousLocation).RegionID) || - (previousLocation is string && previousLocation.Equals(url)))) + (previousLocation is string && upd == null && previousLocation.Equals(url)))) { // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); - m_log.DebugFormat("[XXX] Fail 1 {0} {1}", previousLocation, url); + m_log.DebugFormat("[HG IM SERVICE]: Fail 2 {0} {1}", previousLocation, url); return false; } @@ -242,9 +243,14 @@ namespace OpenSim.Services.HypergridService } if (reginfo != null) + { imresult = InstantMessageServiceConnector.SendInstantMessage(reginfo.ServerURI, im); + } else + { + m_log.DebugFormat("[HG IM SERVICE]: Failed to deliver message to {0}", reginfo.ServerURI); return false; + } if (imresult) { diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs index 59ad043..387547e 100644 --- a/OpenSim/Services/HypergridService/UserAgentService.cs +++ b/OpenSim/Services/HypergridService/UserAgentService.cs @@ -485,6 +485,30 @@ namespace OpenSim.Services.HypergridService return string.Empty; } + + public string GetUUI(UUID userID, UUID targetUserID) + { + // Let's see if it's a local user + UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, targetUserID); + if (account != null) + return targetUserID.ToString() + ";" + m_GridName + ";" + account.FirstName + " " + account.LastName ; + + // Let's try the list of friends + FriendInfo[] friends = m_FriendsService.GetFriends(userID); + if (friends != null && friends.Length > 0) + { + foreach (FriendInfo f in friends) + if (f.Friend.StartsWith(targetUserID.ToString())) + { + // Let's remove the secret + UUID id; string tmp = string.Empty, secret = string.Empty; + if (Util.ParseUniversalUserIdentifier(f.Friend, out id, out tmp, out tmp, out tmp, out secret)) + return f.Friend.Replace(secret, "0"); + } + } + + return string.Empty; + } } class TravelingAgentInfo -- cgit v1.1