diff options
author | Melanie | 2010-06-11 17:46:29 +0100 |
---|---|---|
committer | Melanie | 2010-06-11 17:46:29 +0100 |
commit | aa2f5bdd77b6694b5fd4547a881f339f4679933e (patch) | |
tree | 664a8658067f6f9c0e0c3e9befd1f79aba733293 /OpenSim/Region/CoreModules/Avatar | |
parent | Remove cmGetAvatarList() (diff) | |
parent | Rename CM files to LS (diff) | |
download | opensim-SC-aa2f5bdd77b6694b5fd4547a881f339f4679933e.zip opensim-SC-aa2f5bdd77b6694b5fd4547a881f339f4679933e.tar.gz opensim-SC-aa2f5bdd77b6694b5fd4547a881f339f4679933e.tar.bz2 opensim-SC-aa2f5bdd77b6694b5fd4547a881f339f4679933e.tar.xz |
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 84 |
1 files changed, 32 insertions, 52 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 2979e29..4c01985 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -221,8 +221,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
221 | 221 | ||
222 | client.OnGrantUserRights += OnGrantUserRights; | 222 | client.OnGrantUserRights += OnGrantUserRights; |
223 | 223 | ||
224 | client.OnLogout += OnLogout; | ||
225 | |||
226 | lock (m_Friends) | 224 | lock (m_Friends) |
227 | { | 225 | { |
228 | if (m_Friends.ContainsKey(client.AgentId)) | 226 | if (m_Friends.ContainsKey(client.AgentId)) |
@@ -241,11 +239,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
241 | m_Friends.Add(client.AgentId, newFriends); | 239 | m_Friends.Add(client.AgentId, newFriends); |
242 | } | 240 | } |
243 | 241 | ||
244 | //StatusChange(client.AgentId, true); | ||
245 | } | 242 | } |
246 | 243 | ||
247 | private void OnClientClosed(UUID agentID, Scene scene) | 244 | private void OnClientClosed(UUID agentID, Scene scene) |
248 | { | 245 | { |
246 | ScenePresence sp = scene.GetScenePresence(agentID); | ||
247 | if (sp != null && !sp.IsChildAgent) | ||
248 | // do this for root agents closing out | ||
249 | StatusChange(agentID, false); | ||
250 | |||
249 | lock (m_Friends) | 251 | lock (m_Friends) |
250 | if (m_Friends.ContainsKey(agentID)) | 252 | if (m_Friends.ContainsKey(agentID)) |
251 | { | 253 | { |
@@ -256,23 +258,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
256 | } | 258 | } |
257 | } | 259 | } |
258 | 260 | ||
259 | private void OnLogout(IClientAPI client) | ||
260 | { | ||
261 | StatusChange(client.AgentId, false); | ||
262 | m_Friends.Remove(client.AgentId); | ||
263 | } | ||
264 | |||
265 | private void OnMakeRootAgent(ScenePresence sp) | 261 | private void OnMakeRootAgent(ScenePresence sp) |
266 | { | 262 | { |
267 | UUID agentID = sp.ControllingClient.AgentId; | 263 | UUID agentID = sp.ControllingClient.AgentId; |
268 | 264 | ||
269 | if (m_Friends.ContainsKey(agentID)) | 265 | if (m_Friends.ContainsKey(agentID)) |
270 | { | 266 | { |
271 | if (m_Friends[agentID].RegionID == UUID.Zero) | 267 | // This is probably an overkill, but just |
272 | { | 268 | // to make sure we have the latest and greatest |
273 | m_Friends[agentID].Friends = | 269 | // friends list -- always pull OnMakeRoot |
270 | m_Friends[agentID].Friends = | ||
274 | m_FriendsService.GetFriends(agentID); | 271 | m_FriendsService.GetFriends(agentID); |
275 | } | 272 | |
276 | m_Friends[agentID].RegionID = | 273 | m_Friends[agentID].RegionID = |
277 | sp.ControllingClient.Scene.RegionInfo.RegionID; | 274 | sp.ControllingClient.Scene.RegionInfo.RegionID; |
278 | } | 275 | } |
@@ -438,56 +435,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
438 | /// <param name="online"></param> | 435 | /// <param name="online"></param> |
439 | private void StatusChange(UUID agentID, bool online) | 436 | private void StatusChange(UUID agentID, bool online) |
440 | { | 437 | { |
438 | //m_log.DebugFormat("[FRIENDS]: StatusChange {0}", online); | ||
441 | if (m_Friends.ContainsKey(agentID)) | 439 | if (m_Friends.ContainsKey(agentID)) |
442 | { | 440 | { |
441 | //m_log.DebugFormat("[FRIENDS]: # of friends: {0}", m_Friends[agentID].Friends.Length); | ||
443 | List<FriendInfo> friendList = new List<FriendInfo>(); | 442 | List<FriendInfo> friendList = new List<FriendInfo>(); |
444 | foreach (FriendInfo fi in m_Friends[agentID].Friends) | 443 | foreach (FriendInfo fi in m_Friends[agentID].Friends) |
445 | { | 444 | { |
446 | if (((fi.MyFlags & 1) != 0) && (fi.TheirFlags != -1)) | 445 | if (((fi.MyFlags & 1) != 0) && (fi.TheirFlags != -1)) |
447 | friendList.Add(fi); | 446 | friendList.Add(fi); |
448 | } | 447 | } |
449 | /* | ||
450 | foreach (FriendInfo fi in friendList) | ||
451 | { | ||
452 | // Notify about this user status | ||
453 | StatusNotify(fi, agentID, online); | ||
454 | } | ||
455 | */ | ||
456 | 448 | ||
457 | StatusNotifyMass(friendList, agentID, online); | 449 | Util.FireAndForget(delegate |
458 | } | ||
459 | } | ||
460 | |||
461 | private void StatusNotifyMass(List<FriendInfo> friendList, UUID userID, bool online) | ||
462 | { | ||
463 | int fct = friendList.Count; | ||
464 | string[] friendIDs = new string[fct]; | ||
465 | int notlocal = 0; | ||
466 | for (int x = 0 ; x < fct ; x++) | ||
467 | { | ||
468 | UUID friendID = UUID.Zero; | ||
469 | if (UUID.TryParse(friendList[x].Friend, out friendID)) | ||
470 | { | 450 | { |
471 | if (!LocalStatusNotification(userID, friendID, online)) | 451 | foreach (FriendInfo fi in friendList) |
472 | { | 452 | { |
473 | friendIDs[notlocal++] = friendID.ToString(); | 453 | //m_log.DebugFormat("[FRIENDS]: Notifying {0}", fi.PrincipalID); |
454 | // Notify about this user status | ||
455 | StatusNotify(fi, agentID, online); | ||
474 | } | 456 | } |
475 | } | 457 | }); |
476 | } | ||
477 | |||
478 | PresenceInfo[] friendSessions = PresenceService.GetAgents(friendIDs); | ||
479 | |||
480 | for (int x = 0; x < friendSessions.GetLength(0); x++) | ||
481 | { | ||
482 | if (friendIDs.Length <= x) | ||
483 | continue; | ||
484 | PresenceInfo friendSession = friendSessions[x]; | ||
485 | if (friendSession != null) | ||
486 | { | ||
487 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | ||
488 | m_FriendsSimConnector.StatusNotify(region, userID, new UUID(friendIDs[x]), online); | ||
489 | } | ||
490 | } | 458 | } |
459 | else | ||
460 | m_log.WarnFormat("[FRIENDS]: {0} not found in cache", agentID); | ||
491 | } | 461 | } |
492 | 462 | ||
493 | private void StatusNotify(FriendInfo friend, UUID userID, bool online) | 463 | private void StatusNotify(FriendInfo friend, UUID userID, bool online) |
@@ -504,16 +474,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
504 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); | 474 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); |
505 | if (friendSessions != null && friendSessions.Length > 0) | 475 | if (friendSessions != null && friendSessions.Length > 0) |
506 | { | 476 | { |
507 | PresenceInfo friendSession = friendSessions[0]; | 477 | PresenceInfo friendSession = null; |
478 | foreach (PresenceInfo pinfo in friendSessions) | ||
479 | if (pinfo.RegionID != UUID.Zero) // let's guard against sessions-gone-bad | ||
480 | { | ||
481 | friendSession = pinfo; | ||
482 | break; | ||
483 | } | ||
484 | |||
508 | if (friendSession != null) | 485 | if (friendSession != null) |
509 | { | 486 | { |
510 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 487 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); |
488 | //m_log.DebugFormat("[FRIENDS]: Remote Notify to region {0}", region.RegionName); | ||
511 | m_FriendsSimConnector.StatusNotify(region, userID, friendID, online); | 489 | m_FriendsSimConnector.StatusNotify(region, userID, friendID, online); |
512 | } | 490 | } |
513 | } | 491 | } |
514 | 492 | ||
515 | // Friend is not online. Ignore. | 493 | // Friend is not online. Ignore. |
516 | } | 494 | } |
495 | else | ||
496 | m_log.WarnFormat("[FRIENDS]: Error parsing friend ID {0}", friend.Friend); | ||
517 | } | 497 | } |
518 | 498 | ||
519 | private void OnInstantMessage(IClientAPI client, GridInstantMessage im) | 499 | private void OnInstantMessage(IClientAPI client, GridInstantMessage im) |
@@ -800,7 +780,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
800 | IClientAPI friendClient = LocateClientObject(friendID); | 780 | IClientAPI friendClient = LocateClientObject(friendID); |
801 | if (friendClient != null) | 781 | if (friendClient != null) |
802 | { | 782 | { |
803 | //m_log.DebugFormat("[FRIENDS]: Notify {0} that user {1} is {2}", friend.Friend, userID, online); | 783 | //m_log.DebugFormat("[FRIENDS]: Local Status Notify {0} that user {1} is {2}", friendID, userID, online); |
804 | // the friend in this sim as root agent | 784 | // the friend in this sim as root agent |
805 | if (online) | 785 | if (online) |
806 | friendClient.SendAgentOnline(new UUID[] { userID }); | 786 | friendClient.SendAgentOnline(new UUID[] { userID }); |