aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorDiva Canto2011-06-07 19:36:04 -0700
committerDiva Canto2011-06-07 19:36:04 -0700
commit3307db5d4aedec5cc31541e9a28a95abdd4999d0 (patch)
tree86d7b644e3b2cb1c77fa6e2b5c9ea7223e8e64f8 /OpenSim
parentThis makes the display names work better for foreigners (diff)
downloadopensim-SC_OLD-3307db5d4aedec5cc31541e9a28a95abdd4999d0.zip
opensim-SC_OLD-3307db5d4aedec5cc31541e9a28a95abdd4999d0.tar.gz
opensim-SC_OLD-3307db5d4aedec5cc31541e9a28a95abdd4999d0.tar.bz2
opensim-SC_OLD-3307db5d4aedec5cc31541e9a28a95abdd4999d0.tar.xz
This hopefully fixes all issues with online/offline notifications across grids. http://opensimulator.org/mantis/view.php?id=5528
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs11
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs16
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs55
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs28
-rw-r--r--OpenSim/Services/Interfaces/IHypergridServices.cs3
6 files changed, 99 insertions, 16 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index f82716d..daee4ca 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -830,10 +830,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
830 830
831 public bool LocalStatusNotification(UUID userID, UUID friendID, bool online) 831 public bool LocalStatusNotification(UUID userID, UUID friendID, bool online)
832 { 832 {
833 m_log.DebugFormat("[FRIENDS]: Local Status Notify {0} that user {1} is {2}", friendID, userID, online);
833 IClientAPI friendClient = LocateClientObject(friendID); 834 IClientAPI friendClient = LocateClientObject(friendID);
834 if (friendClient != null) 835 if (friendClient != null)
835 { 836 {
836 //m_log.DebugFormat("[FRIENDS]: Local Status Notify {0} that user {1} is {2}", friendID, userID, online);
837 // the friend in this sim as root agent 837 // the friend in this sim as root agent
838 if (online) 838 if (online)
839 friendClient.SendAgentOnline(new UUID[] { userID }); 839 friendClient.SendAgentOnline(new UUID[] { userID });
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
index ddf9289..b9d6719 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
@@ -75,7 +75,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
75 /// <param name="friendID">friend whose status changed</param> 75 /// <param name="friendID">friend whose status changed</param>
76 /// <param name="online">status</param> 76 /// <param name="online">status</param>
77 /// <returns></returns> 77 /// <returns></returns>
78 public bool StatusNotify(UUID userID, UUID friendID, bool online) 78 public bool StatusNotify(UUID friendID, UUID userID, bool online)
79 { 79 {
80 return LocalStatusNotification(friendID, userID, online); 80 return LocalStatusNotification(friendID, userID, online);
81 } 81 }
@@ -279,7 +279,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
279 foreach (FriendInfo f in kvp.Value) 279 foreach (FriendInfo f in kvp.Value)
280 ids.Add(f.Friend); 280 ids.Add(f.Friend);
281 UserAgentServiceConnector uConn = new UserAgentServiceConnector(kvp.Key); 281 UserAgentServiceConnector uConn = new UserAgentServiceConnector(kvp.Key);
282 uConn.StatusNotification(ids, userID, online); 282 List<UUID> friendsOnline = uConn.StatusNotification(ids, userID, online);
283 // need to debug this here
284 if (online)
285 {
286 IClientAPI client = LocateClientObject(userID);
287 if (client != null)
288 client.SendAgentOnline(friendsOnline.ToArray());
289 }
283 } 290 }
284 } 291 }
285 } 292 }
diff --git a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
index 2022d8a..72a4aea 100644
--- a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
@@ -237,10 +237,20 @@ namespace OpenSim.Server.Handlers.Hypergrid
237 bool online = false; 237 bool online = false;
238 bool.TryParse(requestData["online"].ToString(), out online); 238 bool.TryParse(requestData["online"].ToString(), out online);
239 239
240 hash["result"] = "true";
241
242 // let's spawn a thread for this, because it may take a long time... 240 // let's spawn a thread for this, because it may take a long time...
243 Util.FireAndForget(delegate { m_HomeUsersService.StatusNotification(ids, userID, online); }); 241 List<UUID> friendsOnline = m_HomeUsersService.StatusNotification(ids, userID, online);
242 if (friendsOnline.Count > 0)
243 {
244 int i = 0;
245 foreach (UUID id in friendsOnline)
246 {
247 hash["friend_" + i.ToString()] = id.ToString();
248 i++;
249 }
250 }
251 else
252 hash["result"] = "No Friends Online";
253
244 } 254 }
245 255
246 XmlRpcResponse response = new XmlRpcResponse(); 256 XmlRpcResponse response = new XmlRpcResponse();
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index 046f755..853e524 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -404,7 +404,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
404 GetBoolResponse(request, out reason); 404 GetBoolResponse(request, out reason);
405 } 405 }
406 406
407 public void StatusNotification(List<string> friends, UUID userID, bool online) 407 public List<UUID> StatusNotification(List<string> friends, UUID userID, bool online)
408 { 408 {
409 Hashtable hash = new Hashtable(); 409 Hashtable hash = new Hashtable();
410 hash["userID"] = userID.ToString(); 410 hash["userID"] = userID.ToString();
@@ -421,8 +421,59 @@ namespace OpenSim.Services.Connectors.Hypergrid
421 421
422 XmlRpcRequest request = new XmlRpcRequest("status_notification", paramList); 422 XmlRpcRequest request = new XmlRpcRequest("status_notification", paramList);
423 string reason = string.Empty; 423 string reason = string.Empty;
424 GetBoolResponse(request, out reason);
425 424
425 // Send and get reply
426 List<UUID> friendsOnline = new List<UUID>();
427 XmlRpcResponse response = null;
428 try
429 {
430 response = request.Send(m_ServerURL, 10000);
431 }
432 catch (Exception e)
433 {
434 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL);
435 reason = "Exception: " + e.Message;
436 return friendsOnline;
437 }
438
439 if (response.IsFault)
440 {
441 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString);
442 reason = "XMLRPC Fault";
443 return friendsOnline;
444 }
445
446 hash = (Hashtable)response.Value;
447 //foreach (Object o in hash)
448 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
449 try
450 {
451 if (hash == null)
452 {
453 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
454 reason = "Internal error 1";
455 return friendsOnline;
456 }
457
458 // Here is the actual response
459 foreach (object key in hash.Keys)
460 {
461 if (key is string && ((string)key).StartsWith("friend_") && hash[key] != null)
462 {
463 UUID uuid;
464 if (UUID.TryParse(hash[key].ToString(), out uuid))
465 friendsOnline.Add(uuid);
466 }
467 }
468
469 }
470 catch (Exception e)
471 {
472 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
473 reason = "Exception: " + e.Message;
474 }
475
476 return friendsOnline;
426 } 477 }
427 478
428 public List<UUID> GetOnlineFriends(UUID userID, List<string> friends) 479 public List<UUID> GetOnlineFriends(UUID userID, List<string> friends)
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 8d78f97..29d8b3d 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -324,14 +324,16 @@ namespace OpenSim.Services.HypergridService
324 return false; 324 return false;
325 } 325 }
326 326
327 public void StatusNotification(List<string> friends, UUID foreignUserID, bool online) 327 public List<UUID> StatusNotification(List<string> friends, UUID foreignUserID, bool online)
328 { 328 {
329 if (m_FriendsService == null || m_PresenceService == null) 329 if (m_FriendsService == null || m_PresenceService == null)
330 { 330 {
331 m_log.WarnFormat("[USER AGENT SERVICE]: Unable to perform status notifications because friends or presence services are missing"); 331 m_log.WarnFormat("[USER AGENT SERVICE]: Unable to perform status notifications because friends or presence services are missing");
332 return; 332 return new List<UUID>();
333 } 333 }
334 334
335 List<UUID> localFriendsOnline = new List<UUID>();
336
335 m_log.DebugFormat("[USER AGENT SERVICE]: Status notification: foreign user {0} wants to notify {1} local friends", foreignUserID, friends.Count); 337 m_log.DebugFormat("[USER AGENT SERVICE]: Status notification: foreign user {0} wants to notify {1} local friends", foreignUserID, friends.Count);
336 338
337 // First, let's double check that the reported friends are, indeed, friends of that user 339 // First, let's double check that the reported friends are, indeed, friends of that user
@@ -372,8 +374,12 @@ namespace OpenSim.Services.HypergridService
372 374
373 if (friendSession != null) 375 if (friendSession != null)
374 { 376 {
375 ForwardStatusNotificationToSim(friendSession.RegionID, friendSession.UserID, foreignUserID, online); 377 ForwardStatusNotificationToSim(friendSession.RegionID, foreignUserID, friendSession.UserID, online);
376 usersToBeNotified.Remove(friendSession.UserID.ToString()); 378 usersToBeNotified.Remove(friendSession.UserID.ToString());
379 UUID id;
380 if (UUID.TryParse(friendSession.UserID, out id))
381 localFriendsOnline.Add(id);
382
377 } 383 }
378 } 384 }
379 385
@@ -388,9 +394,17 @@ namespace OpenSim.Services.HypergridService
388 m_log.WarnFormat("[USER AGENT SERVICE]: User {0} is visiting {1}. HG Status notifications still not implemented.", user, url); 394 m_log.WarnFormat("[USER AGENT SERVICE]: User {0} is visiting {1}. HG Status notifications still not implemented.", user, url);
389 } 395 }
390 } 396 }
397
398 // and finally, let's send the online friends
399 if (online)
400 {
401 return localFriendsOnline;
402 }
403 else
404 return new List<UUID>();
391 } 405 }
392 406
393 protected void ForwardStatusNotificationToSim(UUID regionID, string user, UUID foreignUserID, bool online) 407 protected void ForwardStatusNotificationToSim(UUID regionID, UUID foreignUserID, string user, bool online)
394 { 408 {
395 UUID userID; 409 UUID userID;
396 if (UUID.TryParse(user, out userID)) 410 if (UUID.TryParse(user, out userID))
@@ -398,15 +412,15 @@ namespace OpenSim.Services.HypergridService
398 if (m_FriendsLocalSimConnector != null) 412 if (m_FriendsLocalSimConnector != null)
399 { 413 {
400 m_log.DebugFormat("[USER AGENT SERVICE]: Local Notify, user {0} is {1}", foreignUserID, (online ? "online" : "offline")); 414 m_log.DebugFormat("[USER AGENT SERVICE]: Local Notify, user {0} is {1}", foreignUserID, (online ? "online" : "offline"));
401 m_FriendsLocalSimConnector.StatusNotify(userID, foreignUserID, online); 415 m_FriendsLocalSimConnector.StatusNotify(foreignUserID, userID, online);
402 } 416 }
403 else 417 else
404 { 418 {
405 GridRegion region = m_GridService.GetRegionByUUID(UUID.Zero /* !!! */, regionID); 419 GridRegion region = m_GridService.GetRegionByUUID(UUID.Zero /* !!! */, regionID);
406 if (region != null) 420 if (region != null)
407 { 421 {
408 m_log.DebugFormat("[USER AGENT SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, user, foreignUserID, (online ? "online" : "offline")); 422 m_log.DebugFormat("[USER AGENT SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, foreignUserID, (online ? "online" : "offline"));
409 m_FriendsSimConnector.StatusNotify(region, userID, foreignUserID, online); 423 m_FriendsSimConnector.StatusNotify(region, foreignUserID, userID, online);
410 } 424 }
411 } 425 }
412 } 426 }
diff --git a/OpenSim/Services/Interfaces/IHypergridServices.cs b/OpenSim/Services/Interfaces/IHypergridServices.cs
index 3c6fedf..220caef 100644
--- a/OpenSim/Services/Interfaces/IHypergridServices.cs
+++ b/OpenSim/Services/Interfaces/IHypergridServices.cs
@@ -61,7 +61,8 @@ namespace OpenSim.Services.Interfaces
61 // on behalf of the userID 61 // on behalf of the userID
62 string GetUUI(UUID userID, UUID targetUserID); 62 string GetUUI(UUID userID, UUID targetUserID);
63 63
64 void StatusNotification(List<string> friends, UUID userID, bool online); 64 // Returns the local friends online
65 List<UUID> StatusNotification(List<string> friends, UUID userID, bool online);
65 //List<UUID> GetOnlineFriends(UUID userID, List<string> friends); 66 //List<UUID> GetOnlineFriends(UUID userID, List<string> friends);
66 67
67 bool AgentIsComingHome(UUID sessionID, string thisGridExternalName); 68 bool AgentIsComingHome(UUID sessionID, string thisGridExternalName);