diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 92 |
1 files changed, 47 insertions, 45 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 7d94813..f82716d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -139,7 +139,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
139 | if (moduleConfig != null) | 139 | if (moduleConfig != null) |
140 | { | 140 | { |
141 | string name = moduleConfig.GetString("FriendsModule", "FriendsModule"); | 141 | string name = moduleConfig.GetString("FriendsModule", "FriendsModule"); |
142 | m_log.DebugFormat("[XXX] {0} compared to {1}", name, Name); | ||
143 | if (name == Name) | 142 | if (name == Name) |
144 | { | 143 | { |
145 | InitModule(config); | 144 | InitModule(config); |
@@ -183,7 +182,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
183 | { | 182 | { |
184 | } | 183 | } |
185 | 184 | ||
186 | public void AddRegion(Scene scene) | 185 | public virtual void AddRegion(Scene scene) |
187 | { | 186 | { |
188 | if (!m_Enabled) | 187 | if (!m_Enabled) |
189 | return; | 188 | return; |
@@ -302,6 +301,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
302 | { | 301 | { |
303 | UUID agentID = client.AgentId; | 302 | UUID agentID = client.AgentId; |
304 | 303 | ||
304 | //m_log.DebugFormat("[XXX]: OnClientLogin!"); | ||
305 | // Inform the friends that this user is online | 305 | // Inform the friends that this user is online |
306 | StatusChange(agentID, true); | 306 | StatusChange(agentID, true); |
307 | 307 | ||
@@ -405,19 +405,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
405 | } | 405 | } |
406 | 406 | ||
407 | if (friendList.Count > 0) | 407 | if (friendList.Count > 0) |
408 | { | 408 | GetOnlineFriends(userID, friendList, online); |
409 | PresenceInfo[] presence = PresenceService.GetAgents(friendList.ToArray()); | ||
410 | foreach (PresenceInfo pi in presence) | ||
411 | { | ||
412 | UUID presenceID; | ||
413 | if (UUID.TryParse(pi.UserID, out presenceID)) | ||
414 | online.Add(presenceID); | ||
415 | } | ||
416 | } | ||
417 | 409 | ||
418 | return online; | 410 | return online; |
419 | } | 411 | } |
420 | 412 | ||
413 | protected virtual void GetOnlineFriends(UUID userID, List<string> friendList, /*collector*/ List<UUID> online) | ||
414 | { | ||
415 | PresenceInfo[] presence = PresenceService.GetAgents(friendList.ToArray()); | ||
416 | foreach (PresenceInfo pi in presence) | ||
417 | { | ||
418 | UUID presenceID; | ||
419 | if (UUID.TryParse(pi.UserID, out presenceID)) | ||
420 | online.Add(presenceID); | ||
421 | } | ||
422 | } | ||
423 | |||
421 | /// <summary> | 424 | /// <summary> |
422 | /// Find the client for a ID | 425 | /// Find the client for a ID |
423 | /// </summary> | 426 | /// </summary> |
@@ -472,51 +475,51 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
472 | Util.FireAndForget( | 475 | Util.FireAndForget( |
473 | delegate | 476 | delegate |
474 | { | 477 | { |
475 | foreach (FriendInfo fi in friendList) | 478 | m_log.DebugFormat("[FRIENDS MODULE]: Notifying {0} friends", friendList.Count); |
476 | { | 479 | // Notify about this user status |
477 | //m_log.DebugFormat("[FRIENDS]: Notifying {0}", fi.PrincipalID); | 480 | StatusNotify(friendList, agentID, online); |
478 | // Notify about this user status | ||
479 | StatusNotify(fi, agentID, online); | ||
480 | } | ||
481 | } | 481 | } |
482 | ); | 482 | ); |
483 | } | 483 | } |
484 | } | 484 | } |
485 | 485 | ||
486 | private void StatusNotify(FriendInfo friend, UUID userID, bool online) | 486 | protected virtual void StatusNotify(List<FriendInfo> friendList, UUID userID, bool online) |
487 | { | 487 | { |
488 | UUID friendID; | 488 | foreach (FriendInfo friend in friendList) |
489 | if (UUID.TryParse(friend.Friend, out friendID)) | ||
490 | { | 489 | { |
491 | // Try local | 490 | UUID friendID; |
492 | if (LocalStatusNotification(userID, friendID, online)) | 491 | if (UUID.TryParse(friend.Friend, out friendID)) |
493 | return; | ||
494 | |||
495 | // The friend is not here [as root]. Let's forward. | ||
496 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); | ||
497 | if (friendSessions != null && friendSessions.Length > 0) | ||
498 | { | 492 | { |
499 | PresenceInfo friendSession = null; | 493 | // Try local |
500 | foreach (PresenceInfo pinfo in friendSessions) | 494 | if (LocalStatusNotification(userID, friendID, online)) |
501 | if (pinfo.RegionID != UUID.Zero) // let's guard against sessions-gone-bad | 495 | return; |
502 | { | ||
503 | friendSession = pinfo; | ||
504 | break; | ||
505 | } | ||
506 | 496 | ||
507 | if (friendSession != null) | 497 | // The friend is not here [as root]. Let's forward. |
498 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); | ||
499 | if (friendSessions != null && friendSessions.Length > 0) | ||
508 | { | 500 | { |
509 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 501 | PresenceInfo friendSession = null; |
510 | //m_log.DebugFormat("[FRIENDS]: Remote Notify to region {0}", region.RegionName); | 502 | foreach (PresenceInfo pinfo in friendSessions) |
511 | m_FriendsSimConnector.StatusNotify(region, userID, friendID, online); | 503 | if (pinfo.RegionID != UUID.Zero) // let's guard against sessions-gone-bad |
504 | { | ||
505 | friendSession = pinfo; | ||
506 | break; | ||
507 | } | ||
508 | |||
509 | if (friendSession != null) | ||
510 | { | ||
511 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | ||
512 | //m_log.DebugFormat("[FRIENDS]: Remote Notify to region {0}", region.RegionName); | ||
513 | m_FriendsSimConnector.StatusNotify(region, userID, friendID, online); | ||
514 | } | ||
512 | } | 515 | } |
513 | } | ||
514 | 516 | ||
515 | // Friend is not online. Ignore. | 517 | // Friend is not online. Ignore. |
516 | } | 518 | } |
517 | else | 519 | else |
518 | { | 520 | { |
519 | m_log.WarnFormat("[FRIENDS]: Error parsing friend ID {0}", friend.Friend); | 521 | m_log.WarnFormat("[FRIENDS]: Error parsing friend ID {0}", friend.Friend); |
522 | } | ||
520 | } | 523 | } |
521 | } | 524 | } |
522 | 525 | ||
@@ -670,7 +673,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
670 | FriendInfo[] friends = GetFriends(remoteClient.AgentId); | 673 | FriendInfo[] friends = GetFriends(remoteClient.AgentId); |
671 | if (friends.Length == 0) | 674 | if (friends.Length == 0) |
672 | { | 675 | { |
673 | m_log.DebugFormat("[XXX]: agent {0} has no friends", requester); | ||
674 | return; | 676 | return; |
675 | } | 677 | } |
676 | 678 | ||