From 4696a9c95eaf87e5cb43cdba008d3f41a949d629 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 2 Jun 2011 08:13:54 -0700 Subject: [PATCH] Bug fix on HG IM. --- .../InstantMessage/HGMessageTransferModule.cs | 8 ++++-- .../HGInstantMessageService.cs | 26 +++++++++---------- .../Services/Interfaces/IHypergridServices.cs | 2 +- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs index e0c404bba1..4de197e10d 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs @@ -187,12 +187,16 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage // Is the user a local user? UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, toAgentID); string url = string.Empty; + bool foreigner = false; if (account == null) // foreign user + { url = UserManagementModule.GetUserServerURL(toAgentID, "IMServerURI"); + foreigner = true; + } Util.FireAndForget(delegate { - bool success = m_IMService.OutgoingInstantMessage(im, url); + bool success = m_IMService.OutgoingInstantMessage(im, url, foreigner); if (!success && account == null) { // One last chance @@ -203,7 +207,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage UUID id; string u = string.Empty, first = string.Empty, last = string.Empty, secret = string.Empty; if (Util.ParseUniversalUserIdentifier(recipientUUI, out id, out u, out first, out last, out secret)) { - success = m_IMService.OutgoingInstantMessage(im, u); + success = m_IMService.OutgoingInstantMessage(im, u, true); if (success) UserManagementModule.AddUser(toAgentID, u + ";" + first + " " + last); } diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs index dd5fd71baf..4f68e551d1 100644 --- a/OpenSim/Services/HypergridService/HGInstantMessageService.cs +++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs @@ -115,23 +115,23 @@ namespace OpenSim.Services.HypergridService return m_IMSimConnector.SendInstantMessage(im); } else - return TrySendInstantMessage(im, "", true); + return TrySendInstantMessage(im, "", true, false); } - public bool OutgoingInstantMessage(GridInstantMessage im, string url) + public bool OutgoingInstantMessage(GridInstantMessage im, string url, bool foreigner) { m_log.DebugFormat("[HG IM SERVICE]: Sending message from {0} to {1}@{2}", im.fromAgentID, im.toAgentID, url); if (url != string.Empty) - return TrySendInstantMessage(im, url, true); + return TrySendInstantMessage(im, url, true, foreigner); else { PresenceInfo upd = new PresenceInfo(); upd.RegionID = UUID.Zero; - return TrySendInstantMessage(im, upd, true); + return TrySendInstantMessage(im, upd, true, foreigner); } } - protected bool TrySendInstantMessage(GridInstantMessage im, object previousLocation, bool firstTime) + protected bool TrySendInstantMessage(GridInstantMessage im, object previousLocation, bool firstTime, bool foreigner) { UUID toAgentID = new UUID(im.toAgentID); @@ -185,7 +185,7 @@ namespace OpenSim.Services.HypergridService } } - if (upd == null) + if (upd == null && !foreigner) { // 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"); @@ -213,25 +213,25 @@ namespace OpenSim.Services.HypergridService // ok, the user is around somewhere. Let's send back the reply with "success" // even though the IM may still fail. Just don't keep the caller waiting for // the entire time we're trying to deliver the IM - return SendIMToRegion(upd, im, toAgentID); + return SendIMToRegion(upd, im, toAgentID, foreigner); } else if (url != string.Empty) { // ok, the user is around somewhere. Let's send back the reply with "success" // even though the IM may still fail. Just don't keep the caller waiting for // the entire time we're trying to deliver the IM - return ForwardIMToGrid(url, im, toAgentID); + return ForwardIMToGrid(url, im, toAgentID, foreigner); } else if (firstTime && previousLocation is string && (string)previousLocation != string.Empty) { - return ForwardIMToGrid((string)previousLocation, im, toAgentID); + return ForwardIMToGrid((string)previousLocation, im, toAgentID, foreigner); } else m_log.DebugFormat("[HG IM SERVICE]: Unable to locate user {0}", toAgentID); return false; } - bool SendIMToRegion(PresenceInfo upd, GridInstantMessage im, UUID toAgentID) + bool SendIMToRegion(PresenceInfo upd, GridInstantMessage im, UUID toAgentID, bool foreigner) { bool imresult = false; GridRegion reginfo = null; @@ -277,11 +277,11 @@ namespace OpenSim.Services.HypergridService // The version that spawns the thread is SendGridInstantMessageViaXMLRPC // This is recursive!!!!! - return TrySendInstantMessage(im, upd, false); + return TrySendInstantMessage(im, upd, false, foreigner); } } - bool ForwardIMToGrid(string url, GridInstantMessage im, UUID toAgentID) + bool ForwardIMToGrid(string url, GridInstantMessage im, UUID toAgentID, bool foreigner) { if (InstantMessageServiceConnector.SendInstantMessage(url, im)) { @@ -309,7 +309,7 @@ namespace OpenSim.Services.HypergridService // The version that spawns the thread is SendGridInstantMessageViaXMLRPC // This is recursive!!!!! - return TrySendInstantMessage(im, url, false); + return TrySendInstantMessage(im, url, false, foreigner); } } diff --git a/OpenSim/Services/Interfaces/IHypergridServices.cs b/OpenSim/Services/Interfaces/IHypergridServices.cs index 753c20523c..82ec8ceee5 100644 --- a/OpenSim/Services/Interfaces/IHypergridServices.cs +++ b/OpenSim/Services/Interfaces/IHypergridServices.cs @@ -72,7 +72,7 @@ namespace OpenSim.Services.Interfaces public interface IInstantMessage { bool IncomingInstantMessage(GridInstantMessage im); - bool OutgoingInstantMessage(GridInstantMessage im, string url); + bool OutgoingInstantMessage(GridInstantMessage im, string url, bool foreigner); } public interface IFriendsSimConnector {