Implement local online/offline notifications
parent
161d16405d
commit
1a3ad3ae80
|
@ -56,6 +56,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||||
public FriendInfo[] Friends;
|
public FriendInfo[] Friends;
|
||||||
public int Refcount;
|
public int Refcount;
|
||||||
public UUID RegionID;
|
public UUID RegionID;
|
||||||
|
|
||||||
|
public bool IsFriend(string friend)
|
||||||
|
{
|
||||||
|
foreach (FriendInfo fi in Friends)
|
||||||
|
{
|
||||||
|
if (fi.Friend == friend)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
@ -267,6 +278,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||||
newFriends.RegionID = UUID.Zero;
|
newFriends.RegionID = UUID.Zero;
|
||||||
|
|
||||||
m_Friends.Add(client.AgentId, newFriends);
|
m_Friends.Add(client.AgentId, newFriends);
|
||||||
|
|
||||||
|
StatusChange(client.AgentId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClientClosed(UUID agentID, Scene scene)
|
private void OnClientClosed(UUID agentID, Scene scene)
|
||||||
|
@ -283,6 +296,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||||
private void OnLogout(IClientAPI client)
|
private void OnLogout(IClientAPI client)
|
||||||
{
|
{
|
||||||
m_Friends.Remove(client.AgentId);
|
m_Friends.Remove(client.AgentId);
|
||||||
|
|
||||||
|
StatusChange(client.AgentId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMakeRootAgent(ScenePresence sp)
|
private void OnMakeRootAgent(ScenePresence sp)
|
||||||
|
@ -378,5 +393,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void StatusChange(UUID agentID, bool online)
|
||||||
|
{
|
||||||
|
foreach (UserFriendData fd in m_Friends.Values)
|
||||||
|
{
|
||||||
|
// Is this a root agent? If not, they will get updates
|
||||||
|
// through the root and this next check is redundant
|
||||||
|
//
|
||||||
|
if (fd.RegionID == UUID.Zero)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (fd.IsFriend(agentID.ToString()))
|
||||||
|
{
|
||||||
|
UUID[] changed = new UUID[] { agentID };
|
||||||
|
IClientAPI client = LocateClientObject(fd.PrincipalID);
|
||||||
|
if (online)
|
||||||
|
client.SendAgentOnline(changed);
|
||||||
|
else
|
||||||
|
client.SendAgentOffline(changed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue