HG Friends: pulled sim-bound notification code to HGStatusNotifier, so that we can better manage this traffic.
parent
8ad426f329
commit
d8bcb78b10
|
@ -212,7 +212,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
|||
scene.EventManager.OnClientLogin += OnClientLogin;
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
public virtual void RegionLoaded(Scene scene)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
|||
}
|
||||
|
||||
protected HGFriendsServicesConnector m_HGFriendsConnector = new HGFriendsServicesConnector();
|
||||
protected HGStatusNotifier m_StatusNotifier;
|
||||
|
||||
#region ISharedRegionModule
|
||||
public override string Name
|
||||
|
@ -78,6 +79,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
|||
scene.RegisterModuleInterface<IFriendsSimConnector>(this);
|
||||
}
|
||||
|
||||
public override void RegionLoaded(Scene scene)
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
if (m_StatusNotifier == null)
|
||||
m_StatusNotifier = new HGStatusNotifier(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFriendsSimConnector
|
||||
|
@ -230,25 +239,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
|||
if (friendsPerDomain.ContainsKey("local"))
|
||||
base.StatusNotify(friendsPerDomain["local"], userID, online);
|
||||
|
||||
foreach (KeyValuePair<string, List<FriendInfo>> kvp in friendsPerDomain)
|
||||
{
|
||||
if (kvp.Key != "local")
|
||||
{
|
||||
// For the others, call the user agent service
|
||||
List<string> ids = new List<string>();
|
||||
foreach (FriendInfo f in kvp.Value)
|
||||
ids.Add(f.Friend);
|
||||
UserAgentServiceConnector uConn = new UserAgentServiceConnector(kvp.Key);
|
||||
List<UUID> friendsOnline = uConn.StatusNotification(ids, userID, online);
|
||||
|
||||
if (online && friendsOnline.Count > 0)
|
||||
{
|
||||
IClientAPI client = LocateClientObject(userID);
|
||||
if (client != null)
|
||||
client.SendAgentOnline(friendsOnline.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
m_StatusNotifier.Notify(userID, friendsPerDomain, online);
|
||||
|
||||
// m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting StatusNotify for {0}", userID);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Services.Connectors.Hypergrid;
|
||||
using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
|
||||
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
{
|
||||
public class HGStatusNotifier
|
||||
{
|
||||
private HGFriendsModule m_FriendsModule;
|
||||
|
||||
public HGStatusNotifier(HGFriendsModule friendsModule)
|
||||
{
|
||||
m_FriendsModule = friendsModule;
|
||||
}
|
||||
|
||||
public void Notify(UUID userID, Dictionary<string, List<FriendInfo>> friendsPerDomain, bool online)
|
||||
{
|
||||
foreach (KeyValuePair<string, List<FriendInfo>> kvp in friendsPerDomain)
|
||||
{
|
||||
if (kvp.Key != "local")
|
||||
{
|
||||
// For the others, call the user agent service
|
||||
List<string> ids = new List<string>();
|
||||
foreach (FriendInfo f in kvp.Value)
|
||||
ids.Add(f.Friend);
|
||||
UserAgentServiceConnector uConn = new UserAgentServiceConnector(kvp.Key);
|
||||
List<UUID> friendsOnline = uConn.StatusNotification(ids, userID, online);
|
||||
|
||||
if (online && friendsOnline.Count > 0)
|
||||
{
|
||||
IClientAPI client = m_FriendsModule.LocateClientObject(userID);
|
||||
if (client != null)
|
||||
client.SendAgentOnline(friendsOnline.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue