mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 10:15:33 +08:00
mantis 9212: a few changes to Lure and message transfer
This commit is contained in:
@@ -26,9 +26,7 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
@@ -54,10 +52,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected bool m_Enabled = false;
|
||||
protected List<Scene> m_Scenes = new List<Scene>();
|
||||
protected List<Scene> m_Scenes = [];
|
||||
|
||||
protected IInstantMessage m_IMService;
|
||||
protected Dictionary<UUID, object> m_UserLocationMap = new Dictionary<UUID, object>();
|
||||
protected Dictionary<UUID, object> m_UserLocationMap = new();
|
||||
|
||||
public event UndeliveredMessage OnUndeliveredMessage;
|
||||
|
||||
@@ -66,8 +64,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_uMan == null)
|
||||
m_uMan = m_Scenes[0].RequestModuleInterface<IUserManagement>();
|
||||
m_uMan ??= m_Scenes[0].RequestModuleInterface<IUserManagement>();
|
||||
return m_uMan;
|
||||
}
|
||||
}
|
||||
@@ -81,7 +78,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
return;
|
||||
}
|
||||
|
||||
InstantMessageServerConnector imServer = new InstantMessageServerConnector(config, MainServer.Instance, this);
|
||||
InstantMessageServerConnector imServer = new(config, MainServer.Instance, this);
|
||||
m_IMService = imServer.GetService();
|
||||
m_Enabled = true;
|
||||
}
|
||||
@@ -93,7 +90,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
|
||||
lock (m_Scenes)
|
||||
{
|
||||
m_log.DebugFormat("[HG MESSAGE TRANSFER]: Message transfer module {0} active", Name);
|
||||
m_log.Debug($"[HG MESSAGE TRANSFER]: Message transfer module {Name} active");
|
||||
scene.RegisterModuleInterface<IMessageTransferModule>(this);
|
||||
m_Scenes.Add(scene);
|
||||
}
|
||||
@@ -132,9 +129,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public void SendInstantMessage(GridInstantMessage im, MessageResultNotification result)
|
||||
public void SendInstantMessage(GridInstantMessage im, MessageResultNotification result, bool ToRootOnly = false)
|
||||
{
|
||||
UUID toAgentID = new UUID(im.toAgentID);
|
||||
UUID toAgentID = new(im.toAgentID);
|
||||
if (toAgentID.IsZero())
|
||||
return;
|
||||
|
||||
@@ -159,7 +156,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
}
|
||||
}
|
||||
}
|
||||
if(achildsp != null)
|
||||
if (!ToRootOnly && achildsp != null)
|
||||
{
|
||||
// m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID);
|
||||
achildsp.ControllingClient.SendInstantMessage(im);
|
||||
|
||||
@@ -51,9 +51,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private bool m_Enabled = false;
|
||||
protected string m_MessageKey = String.Empty;
|
||||
protected string m_MessageKey = string.Empty;
|
||||
protected List<Scene> m_Scenes = new List<Scene>();
|
||||
protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>();
|
||||
protected Dictionary<UUID, UUID> m_UserRegionMap = new();
|
||||
|
||||
public event UndeliveredMessage OnUndeliveredMessage;
|
||||
|
||||
@@ -64,8 +64,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_PresenceService == null)
|
||||
m_PresenceService = m_Scenes[0].RequestModuleInterface<IPresenceService>();
|
||||
m_PresenceService ??= m_Scenes[0].RequestModuleInterface<IPresenceService>();
|
||||
return m_PresenceService;
|
||||
}
|
||||
}
|
||||
@@ -80,12 +79,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
return;
|
||||
}
|
||||
|
||||
m_MessageKey = cnf.GetString("MessageKey", String.Empty);
|
||||
m_MessageKey = cnf.GetString("MessageKey", string.Empty);
|
||||
}
|
||||
m_log.Debug("[MESSAGE TRANSFER]: Module enabled");
|
||||
m_Enabled = true;
|
||||
|
||||
IMXMLRPCSendWorkers = new ObjectJobEngine(DoSendIMviaXMLRPC, "IMXMLRPCSendWorkers", 1000, 3);
|
||||
IMXMLRPCSendWorkers = new ObjectJobEngine(SendGridInstantMessageViaXMLRPCAsync, "IMXMLRPCSendWorkers", 1000, 3);
|
||||
}
|
||||
|
||||
public virtual void AddRegion(Scene scene)
|
||||
@@ -138,7 +137,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public virtual void SendInstantMessage(GridInstantMessage im, MessageResultNotification result)
|
||||
public virtual void SendInstantMessage(GridInstantMessage im, MessageResultNotification result, bool ToRootOnly = false)
|
||||
{
|
||||
UUID toAgentID = new UUID(im.toAgentID);
|
||||
if (toAgentID.IsZero())
|
||||
@@ -165,14 +164,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
}
|
||||
}
|
||||
}
|
||||
if (achildsp != null)
|
||||
if (!ToRootOnly && achildsp != null)
|
||||
{
|
||||
// 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);
|
||||
|
||||
SendGridInstantMessageViaXMLRPC(im, result);
|
||||
|
||||
@@ -45,23 +45,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
|
||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HGLureModule")]
|
||||
public class HGLureModule : ISharedRegionModule
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private readonly List<Scene> m_scenes = new List<Scene>();
|
||||
private readonly List<Scene> m_scenes = [];
|
||||
|
||||
private IMessageTransferModule m_TransferModule = null;
|
||||
private bool m_Enabled = false;
|
||||
|
||||
private GridInfo m_thisGridInfo;
|
||||
|
||||
private readonly ExpiringCacheOS<UUID, GridInstantMessage> m_PendingLures = new ExpiringCacheOS<UUID, GridInstantMessage>(3600000);
|
||||
private readonly ExpiringCacheOS<UUID, GridInstantMessage> m_PendingLures = new(3600000);
|
||||
|
||||
public void Initialise(IConfigSource config)
|
||||
{
|
||||
if (config.Configs["Messaging"] != null)
|
||||
{
|
||||
if (config.Configs["Messaging"].GetString("LureModule", string.Empty) == "HGLureModule")
|
||||
if (config.Configs["Messaging"].GetString("LureModule", string.Empty) == Name)
|
||||
{
|
||||
m_Enabled = true;
|
||||
}
|
||||
@@ -90,9 +89,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
|
||||
|
||||
if (m_TransferModule == null)
|
||||
{
|
||||
m_TransferModule =
|
||||
scene.RequestModuleInterface<IMessageTransferModule>();
|
||||
|
||||
m_TransferModule = scene.RequestModuleInterface<IMessageTransferModule>();
|
||||
if (m_TransferModule == null)
|
||||
{
|
||||
m_log.Error("[LURE MODULE]: No message transfer module, lures will not work!");
|
||||
@@ -148,8 +145,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
|
||||
{
|
||||
if (im.dialog == (byte)InstantMessageDialog.RequestLure)
|
||||
{
|
||||
if (m_TransferModule != null)
|
||||
m_TransferModule.SendInstantMessage(im, delegate (bool success) { });
|
||||
m_TransferModule?.SendInstantMessage(im, delegate (bool success) { }, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +154,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
|
||||
if (im.dialog == (byte)InstantMessageDialog.RequestTeleport
|
||||
|| im.dialog == (byte)InstantMessageDialog.GodLikeRequestTeleport)
|
||||
{
|
||||
UUID sessionID = new UUID(im.imSessionID);
|
||||
UUID sessionID = new(im.imSessionID);
|
||||
|
||||
if (!m_PendingLures.Contains(sessionID))
|
||||
{
|
||||
@@ -168,22 +164,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
|
||||
|
||||
// Forward. We do this, because the IM module explicitly rejects
|
||||
// IMs of this type
|
||||
if (m_TransferModule != null)
|
||||
m_TransferModule.SendInstantMessage(im, delegate(bool success) { });
|
||||
m_TransferModule?.SendInstantMessage(im, delegate(bool success) { }, true);
|
||||
}
|
||||
else if (im.dialog == (byte)InstantMessageDialog.RequestLure)
|
||||
{
|
||||
if (m_TransferModule != null)
|
||||
m_TransferModule.SendInstantMessage(im, delegate (bool success) { });
|
||||
m_TransferModule?.SendInstantMessage(im, delegate (bool success) { }, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnStartLure(byte lureType, string message, UUID targetid, IClientAPI client)
|
||||
{
|
||||
if (!(client.Scene is Scene))
|
||||
return;
|
||||
if (client.Scene is not Scene scene)
|
||||
return;
|
||||
|
||||
Scene scene = (Scene)(client.Scene);
|
||||
ScenePresence presence = scene.GetScenePresence(client.AgentId);
|
||||
|
||||
message += "@" + m_thisGridInfo.GateKeeperURLNoEndSlash;
|
||||
@@ -192,29 +185,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
|
||||
|
||||
UUID sessionID = UUID.Random();
|
||||
|
||||
GridInstantMessage m = new GridInstantMessage(scene, client.AgentId,
|
||||
GridInstantMessage m = new(scene, client.AgentId,
|
||||
client.FirstName+" "+client.LastName, targetid,
|
||||
(byte)InstantMessageDialog.RequestTeleport, false,
|
||||
message, sessionID, false, presence.AbsolutePosition,
|
||||
Array.Empty<byte>(), true);
|
||||
[], true);
|
||||
m.RegionID = client.Scene.RegionInfo.RegionID.Guid;
|
||||
|
||||
m_log.DebugFormat("[HG LURE MODULE]: RequestTeleport sessionID={0}, regionID={1}, message={2}", m.imSessionID, m.RegionID, m.message);
|
||||
m_log.Debug($"[HG LURE MODULE]: RequestTeleport sessionID={m.imSessionID}, regionID={m.RegionID}, message={m.message}");
|
||||
m_PendingLures.Add(sessionID, m, 7200000); // 2 hours
|
||||
|
||||
if (m_TransferModule != null)
|
||||
{
|
||||
m_TransferModule.SendInstantMessage(m,
|
||||
delegate(bool success) { });
|
||||
}
|
||||
m_TransferModule?.SendInstantMessage(m, delegate(bool success) { }, true);
|
||||
}
|
||||
|
||||
public void OnTeleportLureRequest(UUID lureID, uint teleportFlags, IClientAPI client)
|
||||
{
|
||||
if (!(client.Scene is Scene))
|
||||
if (client.Scene is not Scene)
|
||||
return;
|
||||
|
||||
//Scene scene = (Scene)(client.Scene);
|
||||
if (m_PendingLures.TryGetValue(lureID, out GridInstantMessage im))
|
||||
{
|
||||
m_PendingLures.Remove(lureID);
|
||||
@@ -228,26 +216,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
|
||||
private void Lure(IClientAPI client, uint teleportflags, GridInstantMessage im)
|
||||
{
|
||||
Scene scene = client.Scene as Scene;
|
||||
UUID regionID = new UUID(im.RegionID);
|
||||
UUID regionID = new(im.RegionID);
|
||||
GridRegion region = scene.GridService.GetRegionByUUID(scene.RegionInfo.ScopeID, regionID);
|
||||
if (region != null)
|
||||
scene.RequestTeleportLocation(client, region.RegionHandle, im.Position + new Vector3(0.5f, 0.5f, 0f), Vector3.UnitX, teleportflags);
|
||||
else // we don't have that region here. Check if it's HG
|
||||
{
|
||||
string[] parts = im.message.Split(new char[] { '@' });
|
||||
string[] parts = im.message.Split(['@']);
|
||||
if (parts.Length > 1)
|
||||
{
|
||||
string url = parts[parts.Length - 1]; // the last part
|
||||
if (m_thisGridInfo.IsLocalGrid(url, true) == 0)
|
||||
{
|
||||
m_log.DebugFormat("[HG LURE MODULE]: Luring agent to grid {0} region {1} position {2}", url, im.RegionID, im.Position);
|
||||
m_log.Debug($"[HG LURE MODULE]: Luring agent to grid {url} region {im.RegionID} position {im.Position}");
|
||||
GatekeeperServiceConnector gConn = new GatekeeperServiceConnector();
|
||||
GridRegion gatekeeper = new GridRegion();
|
||||
gatekeeper.ServerURI = url;
|
||||
GridRegion gatekeeper = new GridRegion { ServerURI = url };
|
||||
string homeURI = scene.GetAgentHomeURI(client.AgentId);
|
||||
|
||||
string message;
|
||||
GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, regionID, client.AgentId, homeURI, out message);
|
||||
GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, regionID, client.AgentId, homeURI, out string message);
|
||||
if (finalDestination != null)
|
||||
{
|
||||
ScenePresence sp = scene.GetScenePresence(client.AgentId);
|
||||
@@ -265,7 +251,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.InfoFormat("[HG LURE MODULE]: Lure failed: {0}", message);
|
||||
m_log.Info("$[HG LURE MODULE]: Lure failed: {message}");
|
||||
client.SendAgentAlertMessage(message, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,10 +41,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
|
||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LureModule")]
|
||||
public class LureModule : ISharedRegionModule
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private readonly List<Scene> m_scenes = new List<Scene>();
|
||||
private readonly List<Scene> m_scenes = [];
|
||||
|
||||
private IMessageTransferModule m_TransferModule = null;
|
||||
private bool m_Enabled = false;
|
||||
@@ -53,9 +52,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
|
||||
{
|
||||
if (config.Configs["Messaging"] != null)
|
||||
{
|
||||
if (config.Configs["Messaging"].GetString(
|
||||
"LureModule", "LureModule") ==
|
||||
"LureModule")
|
||||
if (config.Configs["Messaging"].GetString("LureModule", "LureModule") == Name)
|
||||
{
|
||||
m_Enabled = true;
|
||||
m_log.DebugFormat("[LURE MODULE]: {0} enabled", Name);
|
||||
@@ -95,11 +92,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
|
||||
m_Enabled = false;
|
||||
m_scenes.Clear();
|
||||
scene.EventManager.OnNewClient -= OnNewClient;
|
||||
scene.EventManager.OnIncomingInstantMessage -=
|
||||
OnGridInstantMessage;
|
||||
scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
@@ -111,8 +106,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
|
||||
{
|
||||
m_scenes.Remove(scene);
|
||||
scene.EventManager.OnNewClient -= OnNewClient;
|
||||
scene.EventManager.OnIncomingInstantMessage -=
|
||||
OnGridInstantMessage;
|
||||
scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +146,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
|
||||
|
||||
public void OnStartLure(byte lureType, string message, UUID targetid, IClientAPI client)
|
||||
{
|
||||
if (!(client.Scene is Scene))
|
||||
if (client.Scene is not Scene)
|
||||
return;
|
||||
|
||||
Scene scene = (Scene)(client.Scene);
|
||||
@@ -170,7 +164,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
|
||||
(uint)presence.AbsolutePosition.Y,
|
||||
(uint)presence.AbsolutePosition.Z + 2);
|
||||
|
||||
m_log.DebugFormat("[LURE MODULE]: TP invite with message {0}, type {1}", message, lureType);
|
||||
m_log.Debug($"[LURE MODULE]: TP invite with message {message}, type {lureType}");
|
||||
|
||||
GridInstantMessage m;
|
||||
|
||||
@@ -200,25 +194,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
|
||||
|
||||
public void OnTeleportLureRequest(UUID lureID, uint teleportFlags, IClientAPI client)
|
||||
{
|
||||
if (!(client.Scene is Scene))
|
||||
if (client.Scene is not Scene scene)
|
||||
return;
|
||||
|
||||
Scene scene = (Scene)(client.Scene);
|
||||
Util.ParseFakeParcelID(lureID, out ulong handle, out uint x, out uint y, out uint z);
|
||||
|
||||
ulong handle = 0;
|
||||
uint x = 128;
|
||||
uint y = 128;
|
||||
uint z = 70;
|
||||
|
||||
Util.ParseFakeParcelID(lureID, out handle, out x, out y, out z);
|
||||
|
||||
Vector3 position = new Vector3();
|
||||
position.X = (float)x;
|
||||
position.Y = (float)y;
|
||||
position.Z = (float)z;
|
||||
|
||||
scene.RequestTeleportLocation(client, handle, position,
|
||||
Vector3.Zero, teleportFlags);
|
||||
Vector3 position = new(x , y , z);
|
||||
scene.RequestTeleportLocation(client, handle, position, Vector3.Zero, teleportFlags);
|
||||
}
|
||||
|
||||
private void OnGridInstantMessage(GridInstantMessage msg)
|
||||
@@ -230,11 +212,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
|
||||
msg.dialog != (byte)InstantMessageDialog.RequestLure)
|
||||
return;
|
||||
|
||||
if (m_TransferModule != null)
|
||||
{
|
||||
m_TransferModule.SendInstantMessage(msg,
|
||||
delegate(bool success) { });
|
||||
}
|
||||
m_TransferModule?.SendInstantMessage(msg, delegate(bool success) { });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
/// </remarks>
|
||||
/// <param name="im"></param>
|
||||
/// <param name="result"></param>
|
||||
void SendInstantMessage(GridInstantMessage im, MessageResultNotification result);
|
||||
void SendInstantMessage(GridInstantMessage im, MessageResultNotification result, bool ToRootOnly = false);
|
||||
|
||||
/// <summary>
|
||||
/// Appropriately handle a known undeliverable message without attempting a send.
|
||||
|
||||
Reference in New Issue
Block a user