diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 8056030..08e7dd2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -38,7 +38,6 @@ using OpenMetaverse; | |||
38 | using Mono.Addins; | 38 | using Mono.Addins; |
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Servers.HttpServer; | 40 | using OpenSim.Framework.Servers.HttpServer; |
41 | using OpenSim.Framework.Communications; | ||
42 | using OpenSim.Framework.Servers; | 41 | using OpenSim.Framework.Servers; |
43 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
44 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
@@ -94,6 +93,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
94 | protected Dictionary<UUID, UserFriendData> m_Friends = new Dictionary<UUID, UserFriendData>(); | 93 | protected Dictionary<UUID, UserFriendData> m_Friends = new Dictionary<UUID, UserFriendData>(); |
95 | 94 | ||
96 | /// <summary> | 95 | /// <summary> |
96 | /// Maintain a record of clients that need to notify about their online status. This only | ||
97 | /// needs to be done on login. Subsequent online/offline friend changes are sent by a different mechanism. | ||
98 | /// </summary> | ||
99 | protected HashSet<UUID> m_NeedsToNotifyStatus = new HashSet<UUID>(); | ||
100 | |||
101 | /// <summary> | ||
97 | /// Maintain a record of viewers that need to be sent notifications for friends that are online. This only | 102 | /// Maintain a record of viewers that need to be sent notifications for friends that are online. This only |
98 | /// needs to be done on login. Subsequent online/offline friend changes are sent by a different mechanism. | 103 | /// needs to be done on login. Subsequent online/offline friend changes are sent by a different mechanism. |
99 | /// </summary> | 104 | /// </summary> |
@@ -324,6 +329,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
324 | private void OnMakeRootAgent(ScenePresence sp) | 329 | private void OnMakeRootAgent(ScenePresence sp) |
325 | { | 330 | { |
326 | RecacheFriends(sp.ControllingClient); | 331 | RecacheFriends(sp.ControllingClient); |
332 | |||
333 | lock (m_NeedsToNotifyStatus) | ||
334 | { | ||
335 | if (m_NeedsToNotifyStatus.Remove(sp.UUID)) | ||
336 | { | ||
337 | // Inform the friends that this user is online. This can only be done once the client is a Root Agent. | ||
338 | StatusChange(sp.UUID, true); | ||
339 | } | ||
340 | } | ||
327 | } | 341 | } |
328 | 342 | ||
329 | private void OnClientLogin(IClientAPI client) | 343 | private void OnClientLogin(IClientAPI client) |
@@ -331,8 +345,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
331 | UUID agentID = client.AgentId; | 345 | UUID agentID = client.AgentId; |
332 | 346 | ||
333 | //m_log.DebugFormat("[XXX]: OnClientLogin!"); | 347 | //m_log.DebugFormat("[XXX]: OnClientLogin!"); |
334 | // Inform the friends that this user is online | 348 | |
335 | StatusChange(agentID, true); | 349 | // Register that we need to send this user's status to friends. This can only be done |
350 | // once the client becomes a Root Agent, because as part of sending out the presence | ||
351 | // we also get back the presence of the HG friends, and we need to send that to the | ||
352 | // client, but that can only be done when the client is a Root Agent. | ||
353 | lock (m_NeedsToNotifyStatus) | ||
354 | m_NeedsToNotifyStatus.Add(agentID); | ||
336 | 355 | ||
337 | // Register that we need to send the list of online friends to this user | 356 | // Register that we need to send the list of online friends to this user |
338 | lock (m_NeedsListOfOnlineFriends) | 357 | lock (m_NeedsListOfOnlineFriends) |
@@ -371,7 +390,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
371 | foreach (string fid in outstanding) | 390 | foreach (string fid in outstanding) |
372 | { | 391 | { |
373 | UUID fromAgentID; | 392 | UUID fromAgentID; |
374 | string firstname = "Unknown", lastname = "User"; | 393 | string firstname = "Unknown", lastname = "UserFMSFOIN"; |
375 | if (!GetAgentInfo(client.Scene.RegionInfo.ScopeID, fid, out fromAgentID, out firstname, out lastname)) | 394 | if (!GetAgentInfo(client.Scene.RegionInfo.ScopeID, fid, out fromAgentID, out firstname, out lastname)) |
376 | { | 395 | { |
377 | m_log.DebugFormat("[FRIENDS MODULE]: skipping malformed friend {0}", fid); | 396 | m_log.DebugFormat("[FRIENDS MODULE]: skipping malformed friend {0}", fid); |
@@ -397,7 +416,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
397 | 416 | ||
398 | protected virtual bool GetAgentInfo(UUID scopeID, string fid, out UUID agentID, out string first, out string last) | 417 | protected virtual bool GetAgentInfo(UUID scopeID, string fid, out UUID agentID, out string first, out string last) |
399 | { | 418 | { |
400 | first = "Unknown"; last = "User"; | 419 | first = "Unknown"; last = "UserFMGAI"; |
401 | if (!UUID.TryParse(fid, out agentID)) | 420 | if (!UUID.TryParse(fid, out agentID)) |
402 | return false; | 421 | return false; |
403 | 422 | ||
@@ -491,13 +510,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
491 | 510 | ||
492 | // Notify about this user status | 511 | // Notify about this user status |
493 | StatusNotify(friendList, agentID, online); | 512 | StatusNotify(friendList, agentID, online); |
494 | } | 513 | }, null, "FriendsModule.StatusChange" |
495 | ); | 514 | ); |
496 | } | 515 | } |
497 | } | 516 | } |
498 | 517 | ||
499 | protected virtual void StatusNotify(List<FriendInfo> friendList, UUID userID, bool online) | 518 | protected virtual void StatusNotify(List<FriendInfo> friendList, UUID userID, bool online) |
500 | { | 519 | { |
520 | //m_log.DebugFormat("[FRIENDS]: Entering StatusNotify for {0}", userID); | ||
521 | |||
501 | List<string> friendStringIds = friendList.ConvertAll<string>(friend => friend.Friend); | 522 | List<string> friendStringIds = friendList.ConvertAll<string>(friend => friend.Friend); |
502 | List<string> remoteFriendStringIds = new List<string>(); | 523 | List<string> remoteFriendStringIds = new List<string>(); |
503 | foreach (string friendStringId in friendStringIds) | 524 | foreach (string friendStringId in friendStringIds) |
@@ -523,12 +544,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
523 | foreach (PresenceInfo friendSession in friendSessions) | 544 | foreach (PresenceInfo friendSession in friendSessions) |
524 | { | 545 | { |
525 | // let's guard against sessions-gone-bad | 546 | // let's guard against sessions-gone-bad |
526 | if (friendSession.RegionID != UUID.Zero) | 547 | if (friendSession != null && friendSession.RegionID != UUID.Zero) |
527 | { | 548 | { |
549 | //m_log.DebugFormat("[FRIENDS]: Get region {0}", friendSession.RegionID); | ||
528 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 550 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); |
529 | //m_log.DebugFormat("[FRIENDS]: Remote Notify to region {0}", region.RegionName); | 551 | if (region != null) |
530 | m_FriendsSimConnector.StatusNotify(region, userID, friendSession.UserID, online); | 552 | { |
553 | m_FriendsSimConnector.StatusNotify(region, userID, friendSession.UserID, online); | ||
554 | } | ||
531 | } | 555 | } |
556 | //else | ||
557 | // m_log.DebugFormat("[FRIENDS]: friend session is null or the region is UUID.Zero"); | ||
532 | } | 558 | } |
533 | } | 559 | } |
534 | 560 | ||
@@ -685,7 +711,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
685 | // | 711 | // |
686 | 712 | ||
687 | // Try local | 713 | // Try local |
688 | if (LocalFriendshipTerminated(exfriendID)) | 714 | if (LocalFriendshipTerminated(client.AgentId, exfriendID)) |
689 | return; | 715 | return; |
690 | 716 | ||
691 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { exfriendID.ToString() }); | 717 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { exfriendID.ToString() }); |
@@ -827,13 +853,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
827 | return false; | 853 | return false; |
828 | } | 854 | } |
829 | 855 | ||
830 | public bool LocalFriendshipTerminated(UUID exfriendID) | 856 | public bool LocalFriendshipTerminated(UUID userID, UUID exfriendID) |
831 | { | 857 | { |
832 | IClientAPI friendClient = LocateClientObject(exfriendID); | 858 | IClientAPI friendClient = LocateClientObject(exfriendID); |
833 | if (friendClient != null) | 859 | if (friendClient != null) |
834 | { | 860 | { |
835 | // the friend in this sim as root agent | 861 | // the friend in this sim as root agent |
836 | friendClient.SendTerminateFriend(exfriendID); | 862 | friendClient.SendTerminateFriend(userID); |
837 | // update local cache | 863 | // update local cache |
838 | RecacheFriends(friendClient); | 864 | RecacheFriends(friendClient); |
839 | // we're done | 865 | // we're done |