diff options
author | Diva Canto | 2010-02-28 12:07:38 -0800 |
---|---|---|
committer | Diva Canto | 2010-02-28 12:07:38 -0800 |
commit | 5c5966545d14de43500b95109e8ce81058ebe2c3 (patch) | |
tree | 732f9f47668141b177a8f6e9e6e6d64aa0ee722d /OpenSim/Region/CoreModules | |
parent | Friends connectors finished. Status notification working across the board. On... (diff) | |
download | opensim-SC_OLD-5c5966545d14de43500b95109e8ce81058ebe2c3.zip opensim-SC_OLD-5c5966545d14de43500b95109e8ce81058ebe2c3.tar.gz opensim-SC_OLD-5c5966545d14de43500b95109e8ce81058ebe2c3.tar.bz2 opensim-SC_OLD-5c5966545d14de43500b95109e8ce81058ebe2c3.tar.xz |
Initial Online friends notification seems to be working reliably now. All this needs more testing, but everything is there.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index cc3a3ee..8aa5b91 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -79,6 +79,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
79 | protected Dictionary<UUID, UserFriendData> m_Friends = | 79 | protected Dictionary<UUID, UserFriendData> m_Friends = |
80 | new Dictionary<UUID, UserFriendData>(); | 80 | new Dictionary<UUID, UserFriendData>(); |
81 | 81 | ||
82 | protected List<UUID> m_NeedsListOfFriends = new List<UUID>(); | ||
83 | |||
82 | protected IPresenceService PresenceService | 84 | protected IPresenceService PresenceService |
83 | { | 85 | { |
84 | get | 86 | get |
@@ -170,6 +172,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
170 | scene.EventManager.OnClientClosed += OnClientClosed; | 172 | scene.EventManager.OnClientClosed += OnClientClosed; |
171 | scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; | 173 | scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; |
172 | scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; | 174 | scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; |
175 | scene.EventManager.OnClientLogin += OnClientLogin; | ||
173 | } | 176 | } |
174 | 177 | ||
175 | public void RegionLoaded(Scene scene) | 178 | public void RegionLoaded(Scene scene) |
@@ -220,7 +223,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
220 | client.OnGrantUserRights += OnGrantUserRights; | 223 | client.OnGrantUserRights += OnGrantUserRights; |
221 | 224 | ||
222 | client.OnLogout += OnLogout; | 225 | client.OnLogout += OnLogout; |
223 | client.OnEconomyDataRequest += SendPresence; | ||
224 | 226 | ||
225 | if (m_Friends.ContainsKey(client.AgentId)) | 227 | if (m_Friends.ContainsKey(client.AgentId)) |
226 | { | 228 | { |
@@ -285,30 +287,50 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
285 | } | 287 | } |
286 | } | 288 | } |
287 | 289 | ||
288 | private void SendPresence(UUID agentID) | 290 | private void OnClientLogin(IClientAPI client) |
289 | { | 291 | { |
292 | UUID agentID = client.AgentId; | ||
293 | |||
290 | // Inform the friends that this user is online | 294 | // Inform the friends that this user is online |
291 | StatusChange(agentID, true); | 295 | StatusChange(agentID, true); |
292 | 296 | ||
293 | // Now send the list of online friends to this user | 297 | // Register that we need to send the list of online friends to this user |
294 | if (!m_Friends.ContainsKey(agentID)) | 298 | lock (m_NeedsListOfFriends) |
295 | { | 299 | if (!m_NeedsListOfFriends.Contains(agentID)) |
296 | m_log.DebugFormat("[FRIENDS MODULE]: agent {0} not found in local cache", agentID); | 300 | { |
297 | return; | 301 | m_NeedsListOfFriends.Add(agentID); |
298 | } | 302 | } |
303 | } | ||
299 | 304 | ||
300 | IClientAPI client = LocateClientObject(agentID); | 305 | public void SendFriendsOnlineIfNeeded(IClientAPI client) |
301 | if (client == null) | 306 | { |
307 | UUID agentID = client.AgentId; | ||
308 | if (m_NeedsListOfFriends.Contains(agentID)) | ||
302 | { | 309 | { |
303 | m_log.DebugFormat("[FRIENDS MODULE]: agent's client {0} not found in local scene", agentID); | 310 | if (!m_Friends.ContainsKey(agentID)) |
304 | return; | 311 | { |
305 | } | 312 | m_log.DebugFormat("[FRIENDS MODULE]: agent {0} not found in local cache", agentID); |
313 | return; | ||
314 | } | ||
315 | |||
316 | client = LocateClientObject(agentID); | ||
317 | if (client == null) | ||
318 | { | ||
319 | m_log.DebugFormat("[FRIENDS MODULE]: agent's client {0} not found in local scene", agentID); | ||
320 | return; | ||
321 | } | ||
306 | 322 | ||
307 | List<UUID> online = GetOnlineFriends(agentID); | 323 | List<UUID> online = GetOnlineFriends(agentID); |
308 | 324 | ||
309 | m_log.DebugFormat("[FRIENDS]: User {0} in region {1} has {2} friends online", client.AgentId, client.Scene.RegionInfo.RegionName, online.Count); | 325 | if (online.Count > 0) |
310 | client.SendAgentOnline(online.ToArray()); | 326 | { |
327 | m_log.DebugFormat("[FRIENDS MODULE]: User {0} in region {1} has {2} friends online", client.AgentId, client.Scene.RegionInfo.RegionName, online.Count); | ||
328 | client.SendAgentOnline(online.ToArray()); | ||
329 | } | ||
311 | 330 | ||
331 | lock (m_NeedsListOfFriends) | ||
332 | m_NeedsListOfFriends.Remove(agentID); | ||
333 | } | ||
312 | } | 334 | } |
313 | 335 | ||
314 | List<UUID> GetOnlineFriends(UUID userID) | 336 | List<UUID> GetOnlineFriends(UUID userID) |