diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 24ec435..8056030 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -28,12 +28,14 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Linq; | ||
31 | using System.Reflection; | 32 | using System.Reflection; |
32 | using System.Threading; | 33 | using System.Threading; |
33 | using log4net; | 34 | using log4net; |
34 | using Nini.Config; | 35 | using Nini.Config; |
35 | using Nwc.XmlRpc; | 36 | using Nwc.XmlRpc; |
36 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using Mono.Addins; | ||
37 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Servers.HttpServer; | 40 | using OpenSim.Framework.Servers.HttpServer; |
39 | using OpenSim.Framework.Communications; | 41 | using OpenSim.Framework.Communications; |
@@ -49,6 +51,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
49 | 51 | ||
50 | namespace OpenSim.Region.CoreModules.Avatar.Friends | 52 | namespace OpenSim.Region.CoreModules.Avatar.Friends |
51 | { | 53 | { |
54 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "FriendsModule")] | ||
52 | public class FriendsModule : ISharedRegionModule, IFriendsModule | 55 | public class FriendsModule : ISharedRegionModule, IFriendsModule |
53 | { | 56 | { |
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 57 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -482,9 +485,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
482 | Util.FireAndForget( | 485 | Util.FireAndForget( |
483 | delegate | 486 | delegate |
484 | { | 487 | { |
485 | m_log.DebugFormat( | 488 | // m_log.DebugFormat( |
486 | "[FRIENDS MODULE]: Notifying {0} friends of {1} of online status {2}", | 489 | // "[FRIENDS MODULE]: Notifying {0} friends of {1} of online status {2}", |
487 | friendList.Count, agentID, online); | 490 | // friendList.Count, agentID, online); |
488 | 491 | ||
489 | // Notify about this user status | 492 | // Notify about this user status |
490 | StatusNotify(friendList, agentID, online); | 493 | StatusNotify(friendList, agentID, online); |
@@ -495,42 +498,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
495 | 498 | ||
496 | protected virtual void StatusNotify(List<FriendInfo> friendList, UUID userID, bool online) | 499 | protected virtual void StatusNotify(List<FriendInfo> friendList, UUID userID, bool online) |
497 | { | 500 | { |
498 | foreach (FriendInfo friend in friendList) | 501 | List<string> friendStringIds = friendList.ConvertAll<string>(friend => friend.Friend); |
502 | List<string> remoteFriendStringIds = new List<string>(); | ||
503 | foreach (string friendStringId in friendStringIds) | ||
499 | { | 504 | { |
500 | UUID friendID; | 505 | UUID friendUuid; |
501 | if (UUID.TryParse(friend.Friend, out friendID)) | 506 | if (UUID.TryParse(friendStringId, out friendUuid)) |
502 | { | 507 | { |
503 | // Try local | 508 | if (LocalStatusNotification(userID, friendUuid, online)) |
504 | if (LocalStatusNotification(userID, friendID, online)) | ||
505 | continue; | 509 | continue; |
506 | 510 | ||
507 | // The friend is not here [as root]. Let's forward. | 511 | remoteFriendStringIds.Add(friendStringId); |
508 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); | ||
509 | if (friendSessions != null && friendSessions.Length > 0) | ||
510 | { | ||
511 | PresenceInfo friendSession = null; | ||
512 | foreach (PresenceInfo pinfo in friendSessions) | ||
513 | { | ||
514 | if (pinfo.RegionID != UUID.Zero) // let's guard against sessions-gone-bad | ||
515 | { | ||
516 | friendSession = pinfo; | ||
517 | break; | ||
518 | } | ||
519 | } | ||
520 | |||
521 | if (friendSession != null) | ||
522 | { | ||
523 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | ||
524 | //m_log.DebugFormat("[FRIENDS]: Remote Notify to region {0}", region.RegionName); | ||
525 | m_FriendsSimConnector.StatusNotify(region, userID, friendID, online); | ||
526 | } | ||
527 | } | ||
528 | |||
529 | // Friend is not online. Ignore. | ||
530 | } | 512 | } |
531 | else | 513 | else |
532 | { | 514 | { |
533 | m_log.WarnFormat("[FRIENDS]: Error parsing friend ID {0}", friend.Friend); | 515 | m_log.WarnFormat("[FRIENDS]: Error parsing friend ID {0}", friendStringId); |
516 | } | ||
517 | } | ||
518 | |||
519 | // We do this regrouping so that we can efficiently send a single request rather than one for each | ||
520 | // friend in what may be a very large friends list. | ||
521 | PresenceInfo[] friendSessions = PresenceService.GetAgents(remoteFriendStringIds.ToArray()); | ||
522 | |||
523 | foreach (PresenceInfo friendSession in friendSessions) | ||
524 | { | ||
525 | // let's guard against sessions-gone-bad | ||
526 | if (friendSession.RegionID != UUID.Zero) | ||
527 | { | ||
528 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | ||
529 | //m_log.DebugFormat("[FRIENDS]: Remote Notify to region {0}", region.RegionName); | ||
530 | m_FriendsSimConnector.StatusNotify(region, userID, friendSession.UserID, online); | ||
534 | } | 531 | } |
535 | } | 532 | } |
536 | } | 533 | } |