aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs62
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs6
2 files changed, 21 insertions, 47 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index d1a1af0..f3982ea 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -57,7 +57,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
57 { 57 {
58 public UUID PrincipalID; 58 public UUID PrincipalID;
59 public FriendInfo[] Friends; 59 public FriendInfo[] Friends;
60 public int Refcount;
61 60
62 public bool IsFriend(string friend) 61 public bool IsFriend(string friend)
63 { 62 {
@@ -255,6 +254,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
255 254
256 private void OnNewClient(IClientAPI client) 255 private void OnNewClient(IClientAPI client)
257 { 256 {
257 if (client.SceneAgent.IsChildAgent)
258 return;
259
258 client.OnInstantMessage += OnInstantMessage; 260 client.OnInstantMessage += OnInstantMessage;
259 client.OnApproveFriendRequest += OnApproveFriendRequest; 261 client.OnApproveFriendRequest += OnApproveFriendRequest;
260 client.OnDenyFriendRequest += OnDenyFriendRequest; 262 client.OnDenyFriendRequest += OnDenyFriendRequest;
@@ -281,23 +283,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
281 UUID agentID = client.AgentId; 283 UUID agentID = client.AgentId;
282 lock (m_Friends) 284 lock (m_Friends)
283 { 285 {
284 UserFriendData friendsData; 286 UserFriendData friendsData = new UserFriendData();
285 if (m_Friends.TryGetValue(agentID, out friendsData)) 287 friendsData.PrincipalID = agentID;
286 { 288 friendsData.Friends = GetFriendsFromService(client);
287 friendsData.Refcount++;
288 return false;
289 }
290 else
291 {
292 friendsData = new UserFriendData();
293 friendsData.PrincipalID = agentID;
294 friendsData.Friends = GetFriendsFromService(client);
295 friendsData.Refcount = 1;
296 289
297 m_Friends[agentID] = friendsData; 290 m_Friends[agentID] = friendsData;
298 return true;
299 }
300 } 291 }
292
293 return true;
301 } 294 }
302 295
303 private void OnClientClosed(UUID agentID, Scene scene) 296 private void OnClientClosed(UUID agentID, Scene scene)
@@ -307,23 +300,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
307 { 300 {
308 // do this for root agents closing out 301 // do this for root agents closing out
309 StatusChange(agentID, false); 302 StatusChange(agentID, false);
310 }
311 303
312 lock (m_Friends) 304 lock (m_Friends)
313 { 305 m_Friends.Remove(agentID);
314 UserFriendData friendsData;
315 if (m_Friends.TryGetValue(agentID, out friendsData))
316 {
317 friendsData.Refcount--;
318 if (friendsData.Refcount <= 0)
319 m_Friends.Remove(agentID);
320 }
321 } 306 }
322 } 307 }
323 308
324 private void OnMakeRootAgent(ScenePresence sp) 309 private void OnMakeRootAgent(ScenePresence sp)
325 { 310 {
326 RecacheFriends(sp.ControllingClient); 311 // FIXME: Ideally, we want to avoid doing this here since it sits the EventManager.OnMakeRootAgent event
312 // is on the critical path for transferring an avatar from one region to another.
313 CacheFriends(sp.ControllingClient);
327 } 314 }
328 315
329 private void OnClientLogin(IClientAPI client) 316 private void OnClientLogin(IClientAPI client)
@@ -623,7 +610,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
623 StoreFriendships(client.AgentId, friendID); 610 StoreFriendships(client.AgentId, friendID);
624 611
625 // Update the local cache. 612 // Update the local cache.
626 RecacheFriends(client); 613 CacheFriends(client);
627 614
628 // 615 //
629 // Notify the friend 616 // Notify the friend
@@ -685,7 +672,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
685 client.SendAlertMessage("Unable to terminate friendship on this sim."); 672 client.SendAlertMessage("Unable to terminate friendship on this sim.");
686 673
687 // Update local cache 674 // Update local cache
688 RecacheFriends(client); 675 CacheFriends(client);
689 676
690 client.SendTerminateFriend(exfriendID); 677 client.SendTerminateFriend(exfriendID);
691 678
@@ -799,7 +786,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
799 friendClient.SendInstantMessage(im); 786 friendClient.SendInstantMessage(im);
800 787
801 // Update the local cache 788 // Update the local cache
802 RecacheFriends(friendClient); 789 CacheFriends(friendClient);
803 790
804 // we're done 791 // we're done
805 return true; 792 return true;
@@ -832,7 +819,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
832 // the friend in this sim as root agent 819 // the friend in this sim as root agent
833 friendClient.SendTerminateFriend(exfriendID); 820 friendClient.SendTerminateFriend(exfriendID);
834 // update local cache 821 // update local cache
835 RecacheFriends(friendClient); 822 CacheFriends(friendClient);
836 // we're done 823 // we're done
837 return true; 824 return true;
838 } 825 }
@@ -933,19 +920,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
933 return FriendsService.GetFriends(client.AgentId); 920 return FriendsService.GetFriends(client.AgentId);
934 } 921 }
935 922
936 protected void RecacheFriends(IClientAPI client)
937 {
938 // FIXME: Ideally, we want to avoid doing this here since it sits the EventManager.OnMakeRootAgent event
939 // is on the critical path for transferring an avatar from one region to another.
940 UUID agentID = client.AgentId;
941 lock (m_Friends)
942 {
943 UserFriendData friendsData;
944 if (m_Friends.TryGetValue(agentID, out friendsData))
945 friendsData.Friends = GetFriendsFromService(client);
946 }
947 }
948
949 /// <summary> 923 /// <summary>
950 /// Are friends cached on this simulator for a particular user? 924 /// Are friends cached on this simulator for a particular user?
951 /// </summary> 925 /// </summary>
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
index e50a84a..7bc3018 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
@@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
121 { 121 {
122 UUID agentID = client.AgentId; 122 UUID agentID = client.AgentId;
123 // we do this only for the root agent 123 // we do this only for the root agent
124 if (m_Friends[agentID].Refcount == 1) 124 if (!client.SceneAgent.IsChildAgent)
125 { 125 {
126 // We need to preload the user management cache with the names 126 // We need to preload the user management cache with the names
127 // of foreign friends, just like we do with SOPs' creators 127 // of foreign friends, just like we do with SOPs' creators
@@ -426,14 +426,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
426 agentClientCircuit = ((Scene)(agentClient.Scene)).AuthenticateHandler.GetAgentCircuitData(agentClient.CircuitCode); 426 agentClientCircuit = ((Scene)(agentClient.Scene)).AuthenticateHandler.GetAgentCircuitData(agentClient.CircuitCode);
427 agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit); 427 agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit);
428 agentFriendService = agentClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); 428 agentFriendService = agentClientCircuit.ServiceURLs["FriendsServerURI"].ToString();
429 RecacheFriends(agentClient); 429 CacheFriends(agentClient);
430 } 430 }
431 if (friendClient != null) 431 if (friendClient != null)
432 { 432 {
433 friendClientCircuit = ((Scene)(friendClient.Scene)).AuthenticateHandler.GetAgentCircuitData(friendClient.CircuitCode); 433 friendClientCircuit = ((Scene)(friendClient.Scene)).AuthenticateHandler.GetAgentCircuitData(friendClient.CircuitCode);
434 friendUUI = Util.ProduceUserUniversalIdentifier(friendClientCircuit); 434 friendUUI = Util.ProduceUserUniversalIdentifier(friendClientCircuit);
435 friendFriendService = friendClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); 435 friendFriendService = friendClientCircuit.ServiceURLs["FriendsServerURI"].ToString();
436 RecacheFriends(friendClient); 436 CacheFriends(friendClient);
437 } 437 }
438 438
439 m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}", 439 m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}",