diff options
author | Diva Canto | 2011-05-23 19:45:39 -0700 |
---|---|---|
committer | Diva Canto | 2011-05-23 19:45:39 -0700 |
commit | 24f28d353427d1905ae1a46408841265379e29c3 (patch) | |
tree | 07234a5837632bbe0d1198bf282d023c9cd1fb43 /OpenSim/Services/Connectors/Hypergrid | |
parent | More on HG Friends. Added Delete(string, string) across the board. Added secu... (diff) | |
download | opensim-SC_OLD-24f28d353427d1905ae1a46408841265379e29c3.zip opensim-SC_OLD-24f28d353427d1905ae1a46408841265379e29c3.tar.gz opensim-SC_OLD-24f28d353427d1905ae1a46408841265379e29c3.tar.bz2 opensim-SC_OLD-24f28d353427d1905ae1a46408841265379e29c3.tar.xz |
HG friends: Status notifications working. Also initial logins get the online friends in other grids.
Diffstat (limited to 'OpenSim/Services/Connectors/Hypergrid')
-rw-r--r-- | OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index c40a347..46d30df 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs | |||
@@ -404,6 +404,97 @@ 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) | ||
408 | { | ||
409 | Hashtable hash = new Hashtable(); | ||
410 | hash["userID"] = userID.ToString(); | ||
411 | hash["online"] = online.ToString(); | ||
412 | int i = 0; | ||
413 | foreach (string s in friends) | ||
414 | { | ||
415 | hash["friend_" + i.ToString()] = s; | ||
416 | i++; | ||
417 | } | ||
418 | |||
419 | IList paramList = new ArrayList(); | ||
420 | paramList.Add(hash); | ||
421 | |||
422 | XmlRpcRequest request = new XmlRpcRequest("status_notification", paramList); | ||
423 | string reason = string.Empty; | ||
424 | GetBoolResponse(request, out reason); | ||
425 | |||
426 | } | ||
427 | |||
428 | public List<UUID> GetOnlineFriends(UUID userID, List<string> friends) | ||
429 | { | ||
430 | Hashtable hash = new Hashtable(); | ||
431 | hash["userID"] = userID.ToString(); | ||
432 | int i = 0; | ||
433 | foreach (string s in friends) | ||
434 | { | ||
435 | hash["friend_" + i.ToString()] = s; | ||
436 | i++; | ||
437 | } | ||
438 | |||
439 | IList paramList = new ArrayList(); | ||
440 | paramList.Add(hash); | ||
441 | |||
442 | XmlRpcRequest request = new XmlRpcRequest("get_online_friends", paramList); | ||
443 | string reason = string.Empty; | ||
444 | |||
445 | // Send and get reply | ||
446 | List<UUID> online = new List<UUID>(); | ||
447 | XmlRpcResponse response = null; | ||
448 | try | ||
449 | { | ||
450 | response = request.Send(m_ServerURL, 10000); | ||
451 | } | ||
452 | catch (Exception e) | ||
453 | { | ||
454 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL); | ||
455 | reason = "Exception: " + e.Message; | ||
456 | return online; | ||
457 | } | ||
458 | |||
459 | if (response.IsFault) | ||
460 | { | ||
461 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString); | ||
462 | reason = "XMLRPC Fault"; | ||
463 | return online; | ||
464 | } | ||
465 | |||
466 | hash = (Hashtable)response.Value; | ||
467 | //foreach (Object o in hash) | ||
468 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
469 | try | ||
470 | { | ||
471 | if (hash == null) | ||
472 | { | ||
473 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got null response from {0}! THIS IS BAAAAD", m_ServerURL); | ||
474 | reason = "Internal error 1"; | ||
475 | return online; | ||
476 | } | ||
477 | |||
478 | // Here is the actual response | ||
479 | foreach (object key in hash.Keys) | ||
480 | { | ||
481 | if (key is string && ((string)key).StartsWith("friend_") && hash[key] != null) | ||
482 | { | ||
483 | UUID uuid; | ||
484 | if (UUID.TryParse(hash[key].ToString(), out uuid)) | ||
485 | online.Add(uuid); | ||
486 | } | ||
487 | } | ||
488 | |||
489 | } | ||
490 | catch (Exception e) | ||
491 | { | ||
492 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response."); | ||
493 | reason = "Exception: " + e.Message; | ||
494 | } | ||
495 | |||
496 | return online; | ||
497 | } | ||
407 | 498 | ||
408 | private bool GetBoolResponse(XmlRpcRequest request, out string reason) | 499 | private bool GetBoolResponse(XmlRpcRequest request, out string reason) |
409 | { | 500 | { |