From 321d45882b50291c68b1e8c51d3b076a57249707 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 30 Dec 2021 20:40:11 +0000 Subject: [PATCH] (HG)MessageTransferModule: allow direct send to child agents again --- .../InstantMessage/HGMessageTransferModule.cs | 36 +++++++++------ .../InstantMessage/MessageTransferModule.cs | 44 +++++++++---------- 2 files changed, 43 insertions(+), 37 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs index 69f2b16535..317da100d8 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs @@ -140,26 +140,36 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { UUID toAgentID = new UUID(im.toAgentID); - // Try root avatar only first + ScenePresence achildsp = null; + // Try root avatar first foreach (Scene scene in m_Scenes) { -// m_log.DebugFormat( -// "[HG INSTANT MESSAGE]: Looking for root agent {0} in {1}", -// toAgentID.ToString(), scene.RegionInfo.RegionName); + //m_log.DebugFormat( + // "[HG INSTANT MESSAGE]: Looking for root agent {0} in {1}", + // toAgentID.ToString(), scene.RegionInfo.RegionName); ScenePresence sp = scene.GetScenePresence(toAgentID); - if (sp != null && !sp.IsChildAgent && !sp.IsDeleted) + if (sp != null && !sp.IsDeleted) { - // Local message -// m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); - sp.ControllingClient.SendInstantMessage(im); - - // Message sent - result(true); - return; + if(sp.IsChildAgent) + achildsp = sp; + else + { + // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); + sp.ControllingClient.SendInstantMessage(im); + result(true); + return; + } } } + if(achildsp != null) + { + // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID); + achildsp.ControllingClient.SendInstantMessage(im); + result(true); + return; + } -// m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to {0} via XMLRPC", im.toAgentID); + // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to {0} via XMLRPC", im.toAgentID); // Is the user a local user? string url = string.Empty; bool foreigner = false; diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 4cda976b09..a61f890c48 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -141,40 +141,36 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { UUID toAgentID = new UUID(im.toAgentID); - if (toAgentID == UUID.Zero) - return; - - IClientAPI client = null; - - // Try root avatar only first + ScenePresence achildsp = null; + // Try root avatar first foreach (Scene scene in m_Scenes) { + //m_log.DebugFormat( + // "[HG INSTANT MESSAGE]: Looking for root agent {0} in {1}", + // toAgentID.ToString(), scene.RegionInfo.RegionName); ScenePresence sp = scene.GetScenePresence(toAgentID); - if (sp != null && !sp.IsDeleted && sp.ControllingClient.IsActive) + if (sp != null && !sp.IsDeleted) { - // actualy don't send via child agents - // ims can be complex things, and not sure viewers will not mess up - if(sp.IsChildAgent) - continue; - - client = sp.ControllingClient; - if(!sp.IsChildAgent) - break; + if (sp.IsChildAgent) + achildsp = sp; + else + { + // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", sp.Name, toAgentID); + sp.ControllingClient.SendInstantMessage(im); + result(true); + return; + } } } - - if(client != null) + if (achildsp != null) { - // Local message -// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", sp.Name, toAgentID); - - client.SendInstantMessage(im); - - // Message sent + // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", sp.Name, toAgentID); + achildsp.ControllingClient.SendInstantMessage(im); result(true); return; } -// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to {0} via XMLRPC", im.toAgentID); + + //m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to {0} via XMLRPC", im.toAgentID); SendGridInstantMessageViaXMLRPC(im, result); }