diff options
author | Diva Canto | 2011-06-07 19:36:04 -0700 |
---|---|---|
committer | Diva Canto | 2011-06-07 19:36:04 -0700 |
commit | 3307db5d4aedec5cc31541e9a28a95abdd4999d0 (patch) | |
tree | 86d7b644e3b2cb1c77fa6e2b5c9ea7223e8e64f8 /OpenSim/Services | |
parent | This makes the display names work better for foreigners (diff) | |
download | opensim-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/Services')
3 files changed, 76 insertions, 10 deletions
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); |