aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs37
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}