aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorDiva Canto2010-06-11 06:32:24 -0700
committerDiva Canto2010-06-11 06:32:24 -0700
commit7f349d61cb8251a1c13811f5ff7bd95b2311706c (patch)
tree257f053c6eca8842c521b65f90b039f4cab4ab14 /OpenSim/Region
parentBug fix on friends notifications. OnClientClose and OnLogout ordering are unp... (diff)
downloadopensim-SC-7f349d61cb8251a1c13811f5ff7bd95b2311706c.zip
opensim-SC-7f349d61cb8251a1c13811f5ff7bd95b2311706c.tar.gz
opensim-SC-7f349d61cb8251a1c13811f5ff7bd95b2311706c.tar.bz2
opensim-SC-7f349d61cb8251a1c13811f5ff7bd95b2311706c.tar.xz
Better friends notification: get rid of OnLogout and use OnClientClose for sending notifications. This takes care of crashed sessions. Also, made the notifications themselves asynchronous.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs37
1 files changed, 14 insertions, 23 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 4f0487b..80982fd 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -220,8 +220,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
220 220
221 client.OnGrantUserRights += OnGrantUserRights; 221 client.OnGrantUserRights += OnGrantUserRights;
222 222
223 client.OnLogout += OnLogout;
224
225 lock (m_Friends) 223 lock (m_Friends)
226 { 224 {
227 if (m_Friends.ContainsKey(client.AgentId)) 225 if (m_Friends.ContainsKey(client.AgentId))
@@ -240,36 +238,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
240 m_Friends.Add(client.AgentId, newFriends); 238 m_Friends.Add(client.AgentId, newFriends);
241 } 239 }
242 240
243 //StatusChange(client.AgentId, true);
244 } 241 }
245 242
246 private void OnClientClosed(UUID agentID, Scene scene) 243 private void OnClientClosed(UUID agentID, Scene scene)
247 { 244 {
248 ScenePresence sp = scene.GetScenePresence(agentID); 245 ScenePresence sp = scene.GetScenePresence(agentID);
246 if (sp != null && !sp.IsChildAgent)
247 // do this for root agents closing out
248 StatusChange(agentID, false);
249
249 lock (m_Friends) 250 lock (m_Friends)
250 if (m_Friends.ContainsKey(agentID)) 251 if (m_Friends.ContainsKey(agentID))
251 { 252 {
252 if (m_Friends[agentID].Refcount == 1) 253 if (m_Friends[agentID].Refcount == 1)
253 { 254 m_Friends.Remove(agentID);
254 if (sp != null && sp.IsChildAgent)
255 // we do this only for child agents
256 // Root agents' closing = logout; that's
257 // processed with OnLogout
258 {
259 m_Friends.Remove(agentID);
260 }
261 }
262 else 255 else
263 m_Friends[agentID].Refcount--; 256 m_Friends[agentID].Refcount--;
264 } 257 }
265 } 258 }
266 259
267 private void OnLogout(IClientAPI client)
268 {
269 StatusChange(client.AgentId, false);
270 m_Friends.Remove(client.AgentId);
271 }
272
273 private void OnMakeRootAgent(ScenePresence sp) 260 private void OnMakeRootAgent(ScenePresence sp)
274 { 261 {
275 UUID agentID = sp.ControllingClient.AgentId; 262 UUID agentID = sp.ControllingClient.AgentId;
@@ -457,12 +444,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
457 if (((fi.MyFlags & 1) != 0) && (fi.TheirFlags != -1)) 444 if (((fi.MyFlags & 1) != 0) && (fi.TheirFlags != -1))
458 friendList.Add(fi); 445 friendList.Add(fi);
459 } 446 }
460 foreach (FriendInfo fi in friendList) 447
448 Util.FireAndForget(delegate
461 { 449 {
462 //m_log.DebugFormat("[FRIENDS]: Notifying {0}", fi.PrincipalID); 450 foreach (FriendInfo fi in friendList)
463 // Notify about this user status 451 {
464 StatusNotify(fi, agentID, online); 452 //m_log.DebugFormat("[FRIENDS]: Notifying {0}", fi.PrincipalID);
465 } 453 // Notify about this user status
454 StatusNotify(fi, agentID, online);
455 }
456 });
466 } 457 }
467 else 458 else
468 m_log.WarnFormat("[FRIENDS]: {0} not found in cache", agentID); 459 m_log.WarnFormat("[FRIENDS]: {0} not found in cache", agentID);