* Finished SimulationServiceConnector

* Started rerouting calls to UserService.
* Compiles. May run.
This commit is contained in:
Diva Canto
2010-01-07 15:53:55 -08:00
parent 39293758f1
commit f11a97f12d
17 changed files with 359 additions and 128 deletions

View File

@@ -37,6 +37,8 @@ using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{
@@ -46,10 +48,21 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
private bool m_Enabled = false;
protected List<Scene> m_Scenes = new List<Scene>();
protected Dictionary<UUID, ulong> m_UserRegionMap = new Dictionary<UUID, ulong>();
protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>();
public event UndeliveredMessage OnUndeliveredMessage;
private IPresenceService m_PresenceService;
protected IPresenceService PresenceService
{
get
{
if (m_PresenceService == null)
m_PresenceService = m_Scenes[0].RequestModuleInterface<IPresenceService>();
return m_PresenceService;
}
}
public virtual void Initialise(IConfigSource config)
{
IConfig cnf = config.Configs["Messaging"];
@@ -416,7 +429,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
/// <summary>
/// delegate for sending a grid instant message asynchronously
/// </summary>
public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, ulong prevRegionHandle);
public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID);
protected virtual void GridInstantMessageCompleted(IAsyncResult iar)
{
@@ -430,7 +443,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{
GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync;
d.BeginInvoke(im, result, 0, GridInstantMessageCompleted, d);
d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d);
}
/// <summary>
@@ -445,11 +458,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
/// Pass in 0 the first time this method is called. It will be called recursively with the last
/// regionhandle tried
/// </param>
protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, ulong prevRegionHandle)
protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID)
{
UUID toAgentID = new UUID(im.toAgentID);
UserAgentData upd = null;
PresenceInfo upd = null;
bool lookupAgent = false;
@@ -457,13 +470,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{
if (m_UserRegionMap.ContainsKey(toAgentID))
{
upd = new UserAgentData();
upd.AgentOnline = true;
upd.Handle = m_UserRegionMap[toAgentID];
upd = new PresenceInfo();
upd.Online = true;
upd.RegionID = m_UserRegionMap[toAgentID];
// We need to compare the current regionhandle with the previous region handle
// or the recursive loop will never end because it will never try to lookup the agent again
if (prevRegionHandle == upd.Handle)
if (prevRegionID == upd.RegionID)
{
lookupAgent = true;
}
@@ -479,14 +492,23 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
if (lookupAgent)
{
// Non-cached user agent lookup.
upd = m_Scenes[0].CommsManager.UserService.GetAgentByUUID(toAgentID);
PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() });
if (presences != null)
{
foreach (PresenceInfo p in presences)
if (p.Online)
{
upd = presences[0];
break;
}
}
if (upd != null)
{
// check if we've tried this before..
// This is one way to end the recursive loop
//
if (upd.Handle == prevRegionHandle)
if (upd.RegionID == prevRegionID)
{
m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
HandleUndeliveredMessage(im, result);
@@ -503,12 +525,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
if (upd != null)
{
if (upd.AgentOnline)
if (upd.Online)
{
uint x = 0, y = 0;
Utils.LongToUInts(upd.Handle, out x, out y);
GridRegion reginfo = m_Scenes[0].GridService.GetRegionByPosition(m_Scenes[0].RegionInfo.ScopeID,
(int)x, (int)y);
GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID,
upd.RegionID);
if (reginfo != null)
{
Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im);
@@ -524,11 +544,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{
if (m_UserRegionMap.ContainsKey(toAgentID))
{
m_UserRegionMap[toAgentID] = upd.Handle;
m_UserRegionMap[toAgentID] = upd.RegionID;
}
else
{
m_UserRegionMap.Add(toAgentID, upd.Handle);
m_UserRegionMap.Add(toAgentID, upd.RegionID);
}
}
result(true);
@@ -543,12 +563,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
// This is recursive!!!!!
SendGridInstantMessageViaXMLRPCAsync(im, result,
upd.Handle);
upd.RegionID);
}
}
else
{
m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.Handle);
m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID);
HandleUndeliveredMessage(im, result);
}
}