From d72769930aebb14ae4bfee9803adb13fbb44eb8b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 8 May 2010 07:44:07 -0700 Subject: More cleaning on presence. Friends online/offline works again. --- .../Avatar/InstantMessage/MessageTransferModule.cs | 78 +++++++++------------- .../Avatar/InstantMessage/PresenceModule.cs | 22 +++--- 2 files changed, 39 insertions(+), 61 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/InstantMessage') diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index ad050a1..5d20e63 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -471,7 +471,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage if (m_UserRegionMap.ContainsKey(toAgentID)) { upd = new PresenceInfo(); - upd.Online = true; upd.RegionID = m_UserRegionMap[toAgentID]; // We need to compare the current regionhandle with the previous region handle @@ -493,15 +492,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { // Non-cached user agent lookup. PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() }); - if (presences != null) - { - foreach (PresenceInfo p in presences) - if (p.Online) - { - upd = presences[0]; - break; - } - } + if (presences != null && presences.Length > 0) + upd = presences[0]; if (upd != null) { @@ -525,61 +517,53 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage if (upd != null) { - if (upd.Online) + GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, + upd.RegionID); + if (reginfo != null) { - GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, - upd.RegionID); - if (reginfo != null) + Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); + // Not actually used anymore, left in for compatibility + // Remove at next interface change + // + msgdata["region_handle"] = 0; + bool imresult = doIMSending(reginfo, msgdata); + if (imresult) { - Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); - // Not actually used anymore, left in for compatibility - // Remove at next interface change - // - msgdata["region_handle"] = 0; - bool imresult = doIMSending(reginfo, msgdata); - if (imresult) + // IM delivery successful, so store the Agent's location in our local cache. + lock (m_UserRegionMap) { - // IM delivery successful, so store the Agent's location in our local cache. - lock (m_UserRegionMap) + if (m_UserRegionMap.ContainsKey(toAgentID)) { - if (m_UserRegionMap.ContainsKey(toAgentID)) - { - m_UserRegionMap[toAgentID] = upd.RegionID; - } - else - { - m_UserRegionMap.Add(toAgentID, upd.RegionID); - } + m_UserRegionMap[toAgentID] = upd.RegionID; + } + else + { + m_UserRegionMap.Add(toAgentID, upd.RegionID); } - result(true); - } - else - { - // try again, but lookup user this time. - // Warning, this must call the Async version - // of this method or we'll be making thousands of threads - // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync - // The version that spawns the thread is SendGridInstantMessageViaXMLRPC - - // This is recursive!!!!! - SendGridInstantMessageViaXMLRPCAsync(im, result, - upd.RegionID); } + result(true); } else { - m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID); - HandleUndeliveredMessage(im, result); + // try again, but lookup user this time. + // Warning, this must call the Async version + // of this method or we'll be making thousands of threads + // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync + // The version that spawns the thread is SendGridInstantMessageViaXMLRPC + + // This is recursive!!!!! + SendGridInstantMessageViaXMLRPCAsync(im, result, + upd.RegionID); } } else { + m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID); HandleUndeliveredMessage(im, result); } } else { - m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find user {0}", toAgentID); HandleUndeliveredMessage(im, result); } } diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs index bafad82..dd17f3c 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs @@ -133,20 +133,14 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage foreach (PresenceInfo pi in status) { UUID uuid = new UUID(pi.UserID); - if (pi.Online) - { - if (!online.Contains(uuid)) - { - online.Add(uuid); - if (offline.Contains(uuid)) - offline.Remove(uuid); - } - } - else - { - if (!online.Contains(uuid) && !offline.Contains(uuid)) - offline.Add(uuid); - } + if (!online.Contains(uuid)) + online.Add(uuid); + } + foreach (string s in args) + { + UUID uuid = new UUID(s); + if (!online.Contains(uuid) && !offline.Contains(uuid)) + offline.Add(uuid); } if (online.Count > 0) -- cgit v1.1