diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs new file mode 100644 index 0000000..61c6a30 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs | |||
@@ -0,0 +1,66 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Linq; | ||
4 | using System.Reflection; | ||
5 | using System.Text; | ||
6 | using OpenSim.Framework; | ||
7 | using OpenSim.Region.Framework.Interfaces; | ||
8 | using OpenSim.Services.Interfaces; | ||
9 | using OpenSim.Services.Connectors.Hypergrid; | ||
10 | using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; | ||
11 | |||
12 | using OpenMetaverse; | ||
13 | |||
14 | using log4net; | ||
15 | |||
16 | namespace OpenSim.Region.CoreModules.Avatar.Friends | ||
17 | { | ||
18 | public class HGStatusNotifier | ||
19 | { | ||
20 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
21 | |||
22 | private HGFriendsModule m_FriendsModule; | ||
23 | |||
24 | public HGStatusNotifier(HGFriendsModule friendsModule) | ||
25 | { | ||
26 | m_FriendsModule = friendsModule; | ||
27 | } | ||
28 | |||
29 | public void Notify(UUID userID, Dictionary<string, List<FriendInfo>> friendsPerDomain, bool online) | ||
30 | { | ||
31 | foreach (KeyValuePair<string, List<FriendInfo>> kvp in friendsPerDomain) | ||
32 | { | ||
33 | if (kvp.Key != "local") | ||
34 | { | ||
35 | // For the others, call the user agent service | ||
36 | List<string> ids = new List<string>(); | ||
37 | foreach (FriendInfo f in kvp.Value) | ||
38 | ids.Add(f.Friend); | ||
39 | |||
40 | if (ids.Count == 0) | ||
41 | continue; // no one to notify. caller don't do this | ||
42 | |||
43 | m_log.DebugFormat("[HG STATUS NOTIFIER]: Notifying {0} friends in {1}", ids.Count, kvp.Key); | ||
44 | // ASSUMPTION: we assume that all users for one home domain | ||
45 | // have exactly the same set of service URLs. | ||
46 | // If this is ever not true, we need to change this. | ||
47 | UUID friendID = UUID.Zero; String tmp = String.Empty; | ||
48 | if (Util.ParseUniversalUserIdentifier(ids[0], out friendID, out tmp, out tmp, out tmp, out tmp)) | ||
49 | { | ||
50 | string friendsServerURI = m_FriendsModule.UserManagementModule.GetUserServerURL(friendID, "FriendsServerURI"); | ||
51 | HGFriendsServicesConnector fConn = new HGFriendsServicesConnector(friendsServerURI); | ||
52 | |||
53 | List<UUID> friendsOnline = fConn.StatusNotification(ids, userID, online); | ||
54 | |||
55 | if (online && friendsOnline.Count > 0) | ||
56 | { | ||
57 | IClientAPI client = m_FriendsModule.LocateClientObject(userID); | ||
58 | if (client != null) | ||
59 | client.SendAgentOnline(friendsOnline.ToArray()); | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | } | ||
64 | } | ||
65 | } | ||
66 | } | ||