* Simply friends code by only sending notifications to a newly logged on user for other users who are online.
* No need to send offline notifications since the client assumes this (and future clients should be able to do the same).0.6.1-post-fixes
parent
b4680f653d
commit
890d8d4215
|
@ -755,17 +755,18 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
// TODO: If we ever switch to .NET >= 3, replace those Lists with HashSets.
|
// TODO: If we ever switch to .NET >= 3, replace those Lists with HashSets.
|
||||||
// I can't believe that we have Dictionaries, but no Sets, considering Java introduced them years ago...
|
// I can't believe that we have Dictionaries, but no Sets, considering Java introduced them years ago...
|
||||||
List<UUID> friendIDsToSendTo = new List<UUID>();
|
List<UUID> friendIDsToSendTo = new List<UUID>();
|
||||||
List<UUID> friendIDsToReceiveFromOffline = new List<UUID>();
|
List<UUID> candidateFriendIDsToReceive = new List<UUID>();
|
||||||
List<UUID> friendIDsToReceiveFromOnline = new List<UUID>();
|
|
||||||
foreach (FriendListItem item in friendList)
|
foreach (FriendListItem item in friendList)
|
||||||
{
|
{
|
||||||
if (((item.FriendListOwnerPerms | item.FriendPerms) & (uint)FriendRights.CanSeeOnline) != 0)
|
if (((item.FriendListOwnerPerms | item.FriendPerms) & (uint)FriendRights.CanSeeOnline) != 0)
|
||||||
{
|
{
|
||||||
// friend is allowed to see my presence => add
|
// friend is allowed to see my presence => add
|
||||||
if ((item.FriendListOwnerPerms & (uint)FriendRights.CanSeeOnline) != 0) friendIDsToSendTo.Add(item.Friend);
|
if ((item.FriendListOwnerPerms & (uint)FriendRights.CanSeeOnline) != 0)
|
||||||
|
friendIDsToSendTo.Add(item.Friend);
|
||||||
|
|
||||||
// I'm allowed to see friend's presence => add as offline, we might reconsider in a momnet...
|
if ((item.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0)
|
||||||
if ((item.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0) friendIDsToReceiveFromOffline.Add(item.Friend);
|
candidateFriendIDsToReceive.Add(item.Friend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -780,18 +781,20 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
{
|
{
|
||||||
// build a list of friends to look up region-information and on-/offline-state for
|
// build a list of friends to look up region-information and on-/offline-state for
|
||||||
List<UUID> friendIDsToLookup = new List<UUID>(friendIDsToSendTo);
|
List<UUID> friendIDsToLookup = new List<UUID>(friendIDsToSendTo);
|
||||||
foreach (UUID uuid in friendIDsToReceiveFromOffline)
|
foreach (UUID uuid in candidateFriendIDsToReceive)
|
||||||
{
|
{
|
||||||
if (!friendIDsToLookup.Contains(uuid)) friendIDsToLookup.Add(uuid);
|
if (!friendIDsToLookup.Contains(uuid)) friendIDsToLookup.Add(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.DebugFormat("[FRIEND]: {0} to lookup, {1} to send to, {2} to receive from for agent {3}",
|
m_log.DebugFormat(
|
||||||
friendIDsToLookup.Count, friendIDsToSendTo.Count, friendIDsToReceiveFromOffline.Count, client.Name);
|
"[FRIEND]: {0} to lookup, {1} to send to, {2} candidates to receive from for agent {3}",
|
||||||
|
friendIDsToLookup.Count, friendIDsToSendTo.Count, candidateFriendIDsToReceive.Count, client.Name);
|
||||||
|
|
||||||
// we have to fetch FriendRegionInfos, as the (cached) FriendListItems don't
|
// we have to fetch FriendRegionInfos, as the (cached) FriendListItems don't
|
||||||
// necessarily contain the correct online state...
|
// necessarily contain the correct online state...
|
||||||
Dictionary<UUID, FriendRegionInfo> friendRegions = m_initialScene.GetFriendRegionInfos(friendIDsToLookup);
|
Dictionary<UUID, FriendRegionInfo> friendRegions = m_initialScene.GetFriendRegionInfos(friendIDsToLookup);
|
||||||
m_log.DebugFormat("[FRIEND]: Found {0} regionInfos for {1} friends of {2}",
|
m_log.DebugFormat(
|
||||||
|
"[FRIEND]: Found {0} regionInfos for {1} friends of {2}",
|
||||||
friendRegions.Count, friendIDsToLookup.Count, client.Name);
|
friendRegions.Count, friendIDsToLookup.Count, client.Name);
|
||||||
|
|
||||||
// argument for SendAgentOn/Offline; we shouldn't generate that repeatedly within loops.
|
// argument for SendAgentOn/Offline; we shouldn't generate that repeatedly within loops.
|
||||||
|
@ -800,26 +803,26 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
// first, send to friend presence state to me, if I'm online...
|
// first, send to friend presence state to me, if I'm online...
|
||||||
if (iAmOnline)
|
if (iAmOnline)
|
||||||
{
|
{
|
||||||
for (int i = friendIDsToReceiveFromOffline.Count - 1; i >= 0; --i)
|
List<UUID> friendIDsToReceive = new List<UUID>();
|
||||||
|
|
||||||
|
for (int i = candidateFriendIDsToReceive.Count - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
UUID uuid = friendIDsToReceiveFromOffline[i];
|
UUID uuid = candidateFriendIDsToReceive[i];
|
||||||
FriendRegionInfo info;
|
FriendRegionInfo info;
|
||||||
if (friendRegions.TryGetValue(uuid, out info) && info != null && info.isOnline)
|
if (friendRegions.TryGetValue(uuid, out info) && info != null && info.isOnline)
|
||||||
{
|
{
|
||||||
friendIDsToReceiveFromOffline.RemoveAt(i);
|
friendIDsToReceive.Add(uuid);
|
||||||
friendIDsToReceiveFromOnline.Add(uuid);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.DebugFormat("[FRIEND]: Sending {0} offline and {1} online friends to {2}",
|
m_log.DebugFormat(
|
||||||
friendIDsToReceiveFromOffline.Count, friendIDsToReceiveFromOnline.Count, client.Name);
|
"[FRIEND]: Sending {0} online friends to {1}", friendIDsToReceive.Count, client.Name);
|
||||||
|
|
||||||
if (friendIDsToReceiveFromOffline.Count > 0) client.SendAgentOffline(friendIDsToReceiveFromOffline.ToArray());
|
if (friendIDsToReceive.Count > 0)
|
||||||
if (friendIDsToReceiveFromOnline.Count > 0) client.SendAgentOnline(friendIDsToReceiveFromOnline.ToArray());
|
client.SendAgentOnline(friendIDsToReceive.ToArray());
|
||||||
|
|
||||||
// clear them for a possible second iteration; we don't have to repeat this
|
// clear them for a possible second iteration; we don't have to repeat this
|
||||||
friendIDsToReceiveFromOffline.Clear();
|
candidateFriendIDsToReceive.Clear();
|
||||||
friendIDsToReceiveFromOnline.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// now, send my presence state to my friends
|
// now, send my presence state to my friends
|
||||||
|
|
Loading…
Reference in New Issue