diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs | 274 |
1 files changed, 274 insertions, 0 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index c40a347..1c01563 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs | |||
@@ -404,6 +404,280 @@ 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]: GetOnlineFriends 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 | } | ||
498 | |||
499 | public Dictionary<string, object> GetServerURLs(UUID userID) | ||
500 | { | ||
501 | Hashtable hash = new Hashtable(); | ||
502 | hash["userID"] = userID.ToString(); | ||
503 | |||
504 | IList paramList = new ArrayList(); | ||
505 | paramList.Add(hash); | ||
506 | |||
507 | XmlRpcRequest request = new XmlRpcRequest("get_server_urls", paramList); | ||
508 | string reason = string.Empty; | ||
509 | |||
510 | // Send and get reply | ||
511 | Dictionary<string, object> serverURLs = new Dictionary<string,object>(); | ||
512 | XmlRpcResponse response = null; | ||
513 | try | ||
514 | { | ||
515 | response = request.Send(m_ServerURL, 10000); | ||
516 | } | ||
517 | catch (Exception e) | ||
518 | { | ||
519 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL); | ||
520 | reason = "Exception: " + e.Message; | ||
521 | return serverURLs; | ||
522 | } | ||
523 | |||
524 | if (response.IsFault) | ||
525 | { | ||
526 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString); | ||
527 | reason = "XMLRPC Fault"; | ||
528 | return serverURLs; | ||
529 | } | ||
530 | |||
531 | hash = (Hashtable)response.Value; | ||
532 | //foreach (Object o in hash) | ||
533 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
534 | try | ||
535 | { | ||
536 | if (hash == null) | ||
537 | { | ||
538 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetServerURLs Got null response from {0}! THIS IS BAAAAD", m_ServerURL); | ||
539 | reason = "Internal error 1"; | ||
540 | return serverURLs; | ||
541 | } | ||
542 | |||
543 | // Here is the actual response | ||
544 | foreach (object key in hash.Keys) | ||
545 | { | ||
546 | if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null) | ||
547 | { | ||
548 | string serverType = key.ToString().Substring(4); // remove "SRV_" | ||
549 | serverURLs.Add(serverType, hash[key].ToString()); | ||
550 | } | ||
551 | } | ||
552 | |||
553 | } | ||
554 | catch (Exception e) | ||
555 | { | ||
556 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response."); | ||
557 | reason = "Exception: " + e.Message; | ||
558 | } | ||
559 | |||
560 | return serverURLs; | ||
561 | } | ||
562 | |||
563 | public string LocateUser(UUID userID) | ||
564 | { | ||
565 | Hashtable hash = new Hashtable(); | ||
566 | hash["userID"] = userID.ToString(); | ||
567 | |||
568 | IList paramList = new ArrayList(); | ||
569 | paramList.Add(hash); | ||
570 | |||
571 | XmlRpcRequest request = new XmlRpcRequest("locate_user", paramList); | ||
572 | string reason = string.Empty; | ||
573 | |||
574 | // Send and get reply | ||
575 | string url = string.Empty; | ||
576 | XmlRpcResponse response = null; | ||
577 | try | ||
578 | { | ||
579 | m_log.DebugFormat("[XXX]: Calling locate_user on {0}", m_ServerURL); | ||
580 | response = request.Send(m_ServerURL, 10000); | ||
581 | } | ||
582 | catch (Exception e) | ||
583 | { | ||
584 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL); | ||
585 | reason = "Exception: " + e.Message; | ||
586 | return url; | ||
587 | } | ||
588 | |||
589 | if (response.IsFault) | ||
590 | { | ||
591 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString); | ||
592 | reason = "XMLRPC Fault"; | ||
593 | return url; | ||
594 | } | ||
595 | |||
596 | hash = (Hashtable)response.Value; | ||
597 | //foreach (Object o in hash) | ||
598 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
599 | try | ||
600 | { | ||
601 | if (hash == null) | ||
602 | { | ||
603 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: LocateUser Got null response from {0}! THIS IS BAAAAD", m_ServerURL); | ||
604 | reason = "Internal error 1"; | ||
605 | return url; | ||
606 | } | ||
607 | |||
608 | // Here's the actual response | ||
609 | if (hash.ContainsKey("URL")) | ||
610 | url = hash["URL"].ToString(); | ||
611 | |||
612 | } | ||
613 | catch (Exception e) | ||
614 | { | ||
615 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response."); | ||
616 | reason = "Exception: " + e.Message; | ||
617 | } | ||
618 | |||
619 | return url; | ||
620 | } | ||
621 | |||
622 | public string GetUUI(UUID userID, UUID targetUserID) | ||
623 | { | ||
624 | Hashtable hash = new Hashtable(); | ||
625 | hash["userID"] = userID.ToString(); | ||
626 | hash["targetUserID"] = targetUserID.ToString(); | ||
627 | |||
628 | IList paramList = new ArrayList(); | ||
629 | paramList.Add(hash); | ||
630 | |||
631 | XmlRpcRequest request = new XmlRpcRequest("get_uui", paramList); | ||
632 | string reason = string.Empty; | ||
633 | |||
634 | // Send and get reply | ||
635 | string uui = string.Empty; | ||
636 | XmlRpcResponse response = null; | ||
637 | try | ||
638 | { | ||
639 | m_log.DebugFormat("[XXX]: Calling get_uuid on {0}", m_ServerURL); | ||
640 | response = request.Send(m_ServerURL, 10000); | ||
641 | } | ||
642 | catch (Exception e) | ||
643 | { | ||
644 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL); | ||
645 | reason = "Exception: " + e.Message; | ||
646 | return uui; | ||
647 | } | ||
648 | |||
649 | if (response.IsFault) | ||
650 | { | ||
651 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString); | ||
652 | reason = "XMLRPC Fault"; | ||
653 | return uui; | ||
654 | } | ||
655 | |||
656 | hash = (Hashtable)response.Value; | ||
657 | //foreach (Object o in hash) | ||
658 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
659 | try | ||
660 | { | ||
661 | if (hash == null) | ||
662 | { | ||
663 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUI Got null response from {0}! THIS IS BAAAAD", m_ServerURL); | ||
664 | reason = "Internal error 1"; | ||
665 | return uui; | ||
666 | } | ||
667 | |||
668 | // Here's the actual response | ||
669 | if (hash.ContainsKey("UUI")) | ||
670 | uui = hash["UUI"].ToString(); | ||
671 | |||
672 | } | ||
673 | catch (Exception e) | ||
674 | { | ||
675 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response."); | ||
676 | reason = "Exception: " + e.Message; | ||
677 | } | ||
678 | |||
679 | return uui; | ||
680 | } | ||
407 | 681 | ||
408 | private bool GetBoolResponse(XmlRpcRequest request, out string reason) | 682 | private bool GetBoolResponse(XmlRpcRequest request, out string reason) |
409 | { | 683 | { |