do not send IMs via child agents

LSLKeyTest
UbitUmarov 2016-07-24 14:44:40 +01:00
parent f4eb1a8e1d
commit 96a5a053ef
2 changed files with 23 additions and 53 deletions

View File

@ -147,7 +147,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
// "[HG INSTANT MESSAGE]: Looking for root agent {0} in {1}", // "[HG INSTANT MESSAGE]: Looking for root agent {0} in {1}",
// toAgentID.ToString(), scene.RegionInfo.RegionName); // toAgentID.ToString(), scene.RegionInfo.RegionName);
ScenePresence sp = scene.GetScenePresence(toAgentID); ScenePresence sp = scene.GetScenePresence(toAgentID);
if (sp != null && !sp.IsChildAgent) if (sp != null && !sp.IsChildAgent && !sp.IsDeleted)
{ {
// Local message // Local message
// m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID);
@ -159,25 +159,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
} }
} }
// try child avatar second
foreach (Scene scene in m_Scenes)
{
// m_log.DebugFormat(
// "[HG INSTANT MESSAGE]: Looking for child of {0} in {1}",
// toAgentID, scene.RegionInfo.RegionName);
ScenePresence sp = scene.GetScenePresence(toAgentID);
if (sp != null)
{
// Local message
// m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID);
sp.ControllingClient.SendInstantMessage(im);
// Message sent
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? // Is the user a local user?
string url = string.Empty; string url = string.Empty;
@ -224,7 +205,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
foreach (Scene scene in m_Scenes) foreach (Scene scene in m_Scenes)
{ {
ScenePresence sp = scene.GetScenePresence(toAgentID); ScenePresence sp = scene.GetScenePresence(toAgentID);
if(sp != null && !sp.IsChildAgent) if(sp != null && !sp.IsChildAgent && !sp.IsDeleted)
{ {
scene.EventManager.TriggerIncomingInstantMessage(gim); scene.EventManager.TriggerIncomingInstantMessage(gim);
successful = true; successful = true;
@ -310,7 +291,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
foreach (Scene scene in m_Scenes) foreach (Scene scene in m_Scenes)
{ {
ScenePresence presence = scene.GetScenePresence(agentID); ScenePresence presence = scene.GetScenePresence(agentID);
if (presence != null && !presence.IsChildAgent) if (presence != null && !presence.IsChildAgent && !presence.IsDeleted)
return presence.ControllingClient; return presence.ControllingClient;
} }
} }

View File

@ -142,47 +142,36 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
if (toAgentID == UUID.Zero) if (toAgentID == UUID.Zero)
return; return;
IClientAPI client = null;
// Try root avatar only first // Try root avatar only first
foreach (Scene scene in m_Scenes) foreach (Scene scene in m_Scenes)
{ {
// m_log.DebugFormat(
// "[INSTANT MESSAGE]: Looking for root agent {0} in {1}",
// toAgentID.ToString(), scene.RegionInfo.RegionName);
ScenePresence sp = scene.GetScenePresence(toAgentID); ScenePresence sp = scene.GetScenePresence(toAgentID);
if (sp != null && !sp.IsChildAgent) if (sp != null && !sp.IsDeleted && sp.ControllingClient.IsActive)
{
// 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(client != null)
{ {
// Local message // Local message
// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", sp.Name, toAgentID); // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", sp.Name, toAgentID);
sp.ControllingClient.SendInstantMessage(im); client.SendInstantMessage(im);
// Message sent // Message sent
result(true); result(true);
return; return;
} }
}
// try child avatar second
foreach (Scene scene in m_Scenes)
{
// m_log.DebugFormat(
// "[INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName);
ScenePresence sp = scene.GetScenePresence(toAgentID);
if (sp != null)
{
// Local message
// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", sp.Name, toAgentID);
sp.ControllingClient.SendInstantMessage(im);
// Message sent
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); SendGridInstantMessageViaXMLRPC(im, result);