Added local lookup before we ask the messaging server.

Still not tested. May contain bugs.
0.6.1-post-fixes
Homer Horwitz 2008-11-26 19:50:03 +00:00
parent c85e2a0fb0
commit 557559abd3
1 changed files with 26 additions and 6 deletions

View File

@ -143,12 +143,32 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
PresenceInfo[] result = new PresenceInfo[users.Length]; PresenceInfo[] result = new PresenceInfo[users.Length];
if (m_Gridmode) if (m_Gridmode)
{ {
// TODO process local info first and only do a server lookup if necessary. // first check the local information
Dictionary<UUID, FriendRegionInfo> infos = m_initialScene.GetFriendRegionInfos(new List<UUID>(users)); List<UUID> uuids = new List<UUID>(); // the uuids to check remotely
for (int i = 0; i < users.Length; ++i) List<int> indices = new List<int>(); // just for performance.
lock (m_RootAgents)
{
for (int i = 0; i < uuids.Count; ++i)
{
Scene scene;
if (m_RootAgents.TryGetValue(users[i], out scene))
{
result[i] = new PresenceInfo(users[i], scene.RegionInfo.RegionID);
}
else
{
uuids.Add(users[i]);
indices.Add(i);
}
}
}
// now we have filtered out all the local root agents. The rest we have to request info about
Dictionary<UUID, FriendRegionInfo> infos = m_initialScene.GetFriendRegionInfos(uuids);
for (int i = 0; i < uuids.Count; ++i)
{ {
FriendRegionInfo info; FriendRegionInfo info;
if (infos.TryGetValue(users[i], out info) && info.isOnline) if (infos.TryGetValue(uuids[i], out info) && info.isOnline)
{ {
UUID regionID = info.regionID; UUID regionID = info.regionID;
if (regionID == UUID.Zero) if (regionID == UUID.Zero)
@ -158,9 +178,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
RegionInfo regionInfo = m_initialScene.RequestNeighbouringRegionInfo(info.regionHandle); RegionInfo regionInfo = m_initialScene.RequestNeighbouringRegionInfo(info.regionHandle);
regionID = regionInfo.RegionID; regionID = regionInfo.RegionID;
} }
result[i] = new PresenceInfo(users[i], regionID); result[indices[i]] = new PresenceInfo(uuids[i], regionID);
} }
else result[i] = new PresenceInfo(users[i], UUID.Zero); else result[indices[i]] = new PresenceInfo(uuids[i], UUID.Zero);
} }
} }
else else