diff options
author | Melanie | 2010-02-25 23:32:38 +0000 |
---|---|---|
committer | Melanie | 2010-02-25 23:32:38 +0000 |
commit | 1a3ad3ae80a3b01c08008e2aca0bfaccb497ac5c (patch) | |
tree | d6260e11d8fff8afb1dff6b18c19426fcc909dac | |
parent | Check flags on initial login (diff) | |
download | opensim-SC-1a3ad3ae80a3b01c08008e2aca0bfaccb497ac5c.zip opensim-SC-1a3ad3ae80a3b01c08008e2aca0bfaccb497ac5c.tar.gz opensim-SC-1a3ad3ae80a3b01c08008e2aca0bfaccb497ac5c.tar.bz2 opensim-SC-1a3ad3ae80a3b01c08008e2aca0bfaccb497ac5c.tar.xz |
Implement local online/offline notifications
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index e654b1f..8b15abb 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -56,6 +56,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
56 | public FriendInfo[] Friends; | 56 | public FriendInfo[] Friends; |
57 | public int Refcount; | 57 | public int Refcount; |
58 | public UUID RegionID; | 58 | public UUID RegionID; |
59 | |||
60 | public bool IsFriend(string friend) | ||
61 | { | ||
62 | foreach (FriendInfo fi in Friends) | ||
63 | { | ||
64 | if (fi.Friend == friend) | ||
65 | return true; | ||
66 | } | ||
67 | |||
68 | return false; | ||
69 | } | ||
59 | } | 70 | } |
60 | 71 | ||
61 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 72 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -267,6 +278,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
267 | newFriends.RegionID = UUID.Zero; | 278 | newFriends.RegionID = UUID.Zero; |
268 | 279 | ||
269 | m_Friends.Add(client.AgentId, newFriends); | 280 | m_Friends.Add(client.AgentId, newFriends); |
281 | |||
282 | StatusChange(client.AgentId, true); | ||
270 | } | 283 | } |
271 | 284 | ||
272 | private void OnClientClosed(UUID agentID, Scene scene) | 285 | private void OnClientClosed(UUID agentID, Scene scene) |
@@ -283,6 +296,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
283 | private void OnLogout(IClientAPI client) | 296 | private void OnLogout(IClientAPI client) |
284 | { | 297 | { |
285 | m_Friends.Remove(client.AgentId); | 298 | m_Friends.Remove(client.AgentId); |
299 | |||
300 | StatusChange(client.AgentId, false); | ||
286 | } | 301 | } |
287 | 302 | ||
288 | private void OnMakeRootAgent(ScenePresence sp) | 303 | private void OnMakeRootAgent(ScenePresence sp) |
@@ -378,5 +393,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
378 | } | 393 | } |
379 | return null; | 394 | return null; |
380 | } | 395 | } |
396 | |||
397 | private void StatusChange(UUID agentID, bool online) | ||
398 | { | ||
399 | foreach (UserFriendData fd in m_Friends.Values) | ||
400 | { | ||
401 | // Is this a root agent? If not, they will get updates | ||
402 | // through the root and this next check is redundant | ||
403 | // | ||
404 | if (fd.RegionID == UUID.Zero) | ||
405 | continue; | ||
406 | |||
407 | if (fd.IsFriend(agentID.ToString())) | ||
408 | { | ||
409 | UUID[] changed = new UUID[] { agentID }; | ||
410 | IClientAPI client = LocateClientObject(fd.PrincipalID); | ||
411 | if (online) | ||
412 | client.SendAgentOnline(changed); | ||
413 | else | ||
414 | client.SendAgentOffline(changed); | ||
415 | } | ||
416 | } | ||
417 | } | ||
381 | } | 418 | } |
382 | } | 419 | } |