clockwerk-opensim – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 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 if (friendsServerURI != string.Empty)
52 {
53 HGFriendsServicesConnector fConn = new HGFriendsServicesConnector(friendsServerURI);
54  
55 List<UUID> friendsOnline = fConn.StatusNotification(ids, userID, online);
56  
57 if (online && friendsOnline.Count > 0)
58 {
59 IClientAPI client = m_FriendsModule.LocateClientObject(userID);
60 if (client != null)
61 client.SendAgentOnline(friendsOnline.ToArray());
62 }
63 }
64 }
65 }
66 }
67 }
68 }
69 }