aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs')
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs395
1 files changed, 94 insertions, 301 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index 20397a1..f869060 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -78,7 +78,8 @@ namespace OpenSim.Services.Connectors.Hypergrid
78 m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", m_ServerURL, e.Message); 78 m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", m_ServerURL, e.Message);
79 } 79 }
80 } 80 }
81 m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL); 81
82 //m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL);
82 } 83 }
83 84
84 public UserAgentServiceConnector(IConfigSource config) 85 public UserAgentServiceConnector(IConfigSource config)
@@ -190,108 +191,99 @@ namespace OpenSim.Services.Connectors.Hypergrid
190 // no-op 191 // no-op
191 } 192 }
192 193
193 public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) 194 private Hashtable CallServer(string methodName, Hashtable hash)
194 { 195 {
195 position = Vector3.UnitY; lookAt = Vector3.UnitY;
196
197 Hashtable hash = new Hashtable();
198 hash["userID"] = userID.ToString();
199
200 IList paramList = new ArrayList(); 196 IList paramList = new ArrayList();
201 paramList.Add(hash); 197 paramList.Add(hash);
202 198
203 XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList); 199 XmlRpcRequest request = new XmlRpcRequest(methodName, paramList);
200
201 // Send and get reply
204 XmlRpcResponse response = null; 202 XmlRpcResponse response = null;
205 try 203 try
206 { 204 {
207 response = request.Send(m_ServerURL, 10000); 205 response = request.Send(m_ServerURL, 10000);
208 } 206 }
209 catch (Exception) 207 catch (Exception e)
210 { 208 {
211 return null; 209 m_log.DebugFormat("[USER AGENT CONNECTOR]: {0} call to {1} failed: {2}", methodName, m_ServerURL, e.Message);
210 throw;
212 } 211 }
213 212
214 if (response.IsFault) 213 if (response.IsFault)
215 { 214 {
216 return null; 215 throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned an error: {2}", methodName, m_ServerURL, response.FaultString));
217 } 216 }
218 217
219 hash = (Hashtable)response.Value; 218 hash = (Hashtable)response.Value;
220 //foreach (Object o in hash) 219
221 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); 220 if (hash == null)
222 try
223 { 221 {
224 bool success = false; 222 throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned null", methodName, m_ServerURL));
225 Boolean.TryParse((string)hash["result"], out success); 223 }
226 if (success)
227 {
228 GridRegion region = new GridRegion();
229 224
230 UUID.TryParse((string)hash["uuid"], out region.RegionID); 225 return hash;
231 //m_log.Debug(">> HERE, uuid: " + region.RegionID); 226 }
232 int n = 0;
233 if (hash["x"] != null)
234 {
235 Int32.TryParse((string)hash["x"], out n);
236 region.RegionLocX = n;
237 //m_log.Debug(">> HERE, x: " + region.RegionLocX);
238 }
239 if (hash["y"] != null)
240 {
241 Int32.TryParse((string)hash["y"], out n);
242 region.RegionLocY = n;
243 //m_log.Debug(">> HERE, y: " + region.RegionLocY);
244 }
245 if (hash["size_x"] != null)
246 {
247 Int32.TryParse((string)hash["size_x"], out n);
248 region.RegionSizeX = n;
249 //m_log.Debug(">> HERE, x: " + region.RegionLocX);
250 }
251 if (hash["size_y"] != null)
252 {
253 Int32.TryParse((string)hash["size_y"], out n);
254 region.RegionSizeY = n;
255 //m_log.Debug(">> HERE, y: " + region.RegionLocY);
256 }
257 if (hash["region_name"] != null)
258 {
259 region.RegionName = (string)hash["region_name"];
260 //m_log.Debug(">> HERE, name: " + region.RegionName);
261 }
262 if (hash["hostname"] != null)
263 region.ExternalHostName = (string)hash["hostname"];
264 if (hash["http_port"] != null)
265 {
266 uint p = 0;
267 UInt32.TryParse((string)hash["http_port"], out p);
268 region.HttpPort = p;
269 }
270 if (hash.ContainsKey("server_uri") && hash["server_uri"] != null)
271 region.ServerURI = (string)hash["server_uri"];
272 227
273 if (hash["internal_port"] != null) 228 public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt)
274 { 229 {
275 int p = 0; 230 position = Vector3.UnitY; lookAt = Vector3.UnitY;
276 Int32.TryParse((string)hash["internal_port"], out p);
277 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
278 }
279 if (hash["position"] != null)
280 Vector3.TryParse((string)hash["position"], out position);
281 if (hash["lookAt"] != null)
282 Vector3.TryParse((string)hash["lookAt"], out lookAt);
283 231
284 // Successful return 232 Hashtable hash = new Hashtable();
285 return region; 233 hash["userID"] = userID.ToString();
286 } 234
235 hash = CallServer("get_home_region", hash);
287 236
237 bool success;
238 if (!Boolean.TryParse((string)hash["result"], out success) || !success)
239 return null;
240
241 GridRegion region = new GridRegion();
242
243 UUID.TryParse((string)hash["uuid"], out region.RegionID);
244 //m_log.Debug(">> HERE, uuid: " + region.RegionID);
245 int n = 0;
246 if (hash["x"] != null)
247 {
248 Int32.TryParse((string)hash["x"], out n);
249 region.RegionLocX = n;
250 //m_log.Debug(">> HERE, x: " + region.RegionLocX);
288 } 251 }
289 catch (Exception) 252 if (hash["y"] != null)
290 { 253 {
291 return null; 254 Int32.TryParse((string)hash["y"], out n);
255 region.RegionLocY = n;
256 //m_log.Debug(">> HERE, y: " + region.RegionLocY);
292 } 257 }
258 if (hash["region_name"] != null)
259 {
260 region.RegionName = (string)hash["region_name"];
261 //m_log.Debug(">> HERE, name: " + region.RegionName);
262 }
263 if (hash["hostname"] != null)
264 region.ExternalHostName = (string)hash["hostname"];
265 if (hash["http_port"] != null)
266 {
267 uint p = 0;
268 UInt32.TryParse((string)hash["http_port"], out p);
269 region.HttpPort = p;
270 }
271 if (hash.ContainsKey("server_uri") && hash["server_uri"] != null)
272 region.ServerURI = (string)hash["server_uri"];
273
274 if (hash["internal_port"] != null)
275 {
276 int p = 0;
277 Int32.TryParse((string)hash["internal_port"], out p);
278 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
279 }
280 if (hash["position"] != null)
281 Vector3.TryParse((string)hash["position"], out position);
282 if (hash["lookAt"] != null)
283 Vector3.TryParse((string)hash["lookAt"], out lookAt);
293 284
294 return null; 285 // Successful return
286 return region;
295 } 287 }
296 288
297 public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName) 289 public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName)
@@ -500,50 +492,16 @@ namespace OpenSim.Services.Connectors.Hypergrid
500 Hashtable hash = new Hashtable(); 492 Hashtable hash = new Hashtable();
501 hash["userID"] = userID.ToString(); 493 hash["userID"] = userID.ToString();
502 494
503 IList paramList = new ArrayList(); 495 hash = CallServer("get_user_info", hash);
504 paramList.Add(hash);
505
506 XmlRpcRequest request = new XmlRpcRequest("get_user_info", paramList);
507 496
508 Dictionary<string, object> info = new Dictionary<string, object>(); 497 Dictionary<string, object> info = new Dictionary<string, object>();
509 XmlRpcResponse response = null;
510 try
511 {
512 response = request.Send(m_ServerURL, 10000);
513 }
514 catch
515 {
516 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUserInfo", m_ServerURL);
517 return info;
518 }
519 498
520 if (response.IsFault) 499 foreach (object key in hash.Keys)
521 { 500 {
522 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetServerURLs returned an error: {1}", m_ServerURL, response.FaultString); 501 if (hash[key] != null)
523 return info;
524 }
525
526 hash = (Hashtable)response.Value;
527 try
528 {
529 if (hash == null)
530 { 502 {
531 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUserInfo Got null response from {0}! THIS IS BAAAAD", m_ServerURL); 503 info.Add(key.ToString(), hash[key]);
532 return info;
533 } 504 }
534
535 // Here is the actual response
536 foreach (object key in hash.Keys)
537 {
538 if (hash[key] != null)
539 {
540 info.Add(key.ToString(), hash[key]);
541 }
542 }
543 }
544 catch
545 {
546 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
547 } 505 }
548 506
549 return info; 507 return info;
@@ -554,60 +512,16 @@ namespace OpenSim.Services.Connectors.Hypergrid
554 Hashtable hash = new Hashtable(); 512 Hashtable hash = new Hashtable();
555 hash["userID"] = userID.ToString(); 513 hash["userID"] = userID.ToString();
556 514
557 IList paramList = new ArrayList(); 515 hash = CallServer("get_server_urls", hash);
558 paramList.Add(hash); 516
559 517 Dictionary<string, object> serverURLs = new Dictionary<string, object>();
560 XmlRpcRequest request = new XmlRpcRequest("get_server_urls", paramList); 518 foreach (object key in hash.Keys)
561// string reason = string.Empty;
562
563 // Send and get reply
564 Dictionary<string, object> serverURLs = new Dictionary<string,object>();
565 XmlRpcResponse response = null;
566 try
567 { 519 {
568 response = request.Send(m_ServerURL, 10000); 520 if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null)
569 }
570 catch
571 {
572 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetServerURLs for user {1}", m_ServerURL, userID);
573// reason = "Exception: " + e.Message;
574 return serverURLs;
575 }
576
577 if (response.IsFault)
578 {
579 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetServerURLs returned an error: {1}", m_ServerURL, response.FaultString);
580// reason = "XMLRPC Fault";
581 return serverURLs;
582 }
583
584 hash = (Hashtable)response.Value;
585 //foreach (Object o in hash)
586 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
587 try
588 {
589 if (hash == null)
590 {
591 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetServerURLs Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
592// reason = "Internal error 1";
593 return serverURLs;
594 }
595
596 // Here is the actual response
597 foreach (object key in hash.Keys)
598 { 521 {
599 if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null) 522 string serverType = key.ToString().Substring(4); // remove "SRV_"
600 { 523 serverURLs.Add(serverType, hash[key].ToString());
601 string serverType = key.ToString().Substring(4); // remove "SRV_"
602 serverURLs.Add(serverType, hash[key].ToString());
603 }
604 } 524 }
605
606 }
607 catch
608 {
609 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
610// reason = "Exception: " + e.Message;
611 } 525 }
612 526
613 return serverURLs; 527 return serverURLs;
@@ -618,55 +532,13 @@ namespace OpenSim.Services.Connectors.Hypergrid
618 Hashtable hash = new Hashtable(); 532 Hashtable hash = new Hashtable();
619 hash["userID"] = userID.ToString(); 533 hash["userID"] = userID.ToString();
620 534
621 IList paramList = new ArrayList(); 535 hash = CallServer("locate_user", hash);
622 paramList.Add(hash);
623
624 XmlRpcRequest request = new XmlRpcRequest("locate_user", paramList);
625// string reason = string.Empty;
626 536
627 // Send and get reply
628 string url = string.Empty; 537 string url = string.Empty;
629 XmlRpcResponse response = null;
630 try
631 {
632 response = request.Send(m_ServerURL, 10000);
633 }
634 catch
635 {
636 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for LocateUser", m_ServerURL);
637// reason = "Exception: " + e.Message;
638 return url;
639 }
640 538
641 if (response.IsFault) 539 // Here's the actual response
642 { 540 if (hash.ContainsKey("URL"))
643 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for LocateUser returned an error: {1}", m_ServerURL, response.FaultString); 541 url = hash["URL"].ToString();
644// reason = "XMLRPC Fault";
645 return url;
646 }
647
648 hash = (Hashtable)response.Value;
649 //foreach (Object o in hash)
650 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
651 try
652 {
653 if (hash == null)
654 {
655 m_log.ErrorFormat("[USER AGENT CONNECTOR]: LocateUser Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
656// reason = "Internal error 1";
657 return url;
658 }
659
660 // Here's the actual response
661 if (hash.ContainsKey("URL"))
662 url = hash["URL"].ToString();
663
664 }
665 catch
666 {
667 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response.");
668// reason = "Exception: " + e.Message;
669 }
670 542
671 return url; 543 return url;
672 } 544 }
@@ -677,55 +549,13 @@ namespace OpenSim.Services.Connectors.Hypergrid
677 hash["userID"] = userID.ToString(); 549 hash["userID"] = userID.ToString();
678 hash["targetUserID"] = targetUserID.ToString(); 550 hash["targetUserID"] = targetUserID.ToString();
679 551
680 IList paramList = new ArrayList(); 552 hash = CallServer("get_uui", hash);
681 paramList.Add(hash);
682
683 XmlRpcRequest request = new XmlRpcRequest("get_uui", paramList);
684// string reason = string.Empty;
685 553
686 // Send and get reply
687 string uui = string.Empty; 554 string uui = string.Empty;
688 XmlRpcResponse response = null;
689 try
690 {
691 response = request.Send(m_ServerURL, 10000);
692 }
693 catch
694 {
695 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUI", m_ServerURL);
696// reason = "Exception: " + e.Message;
697 return uui;
698 }
699 555
700 if (response.IsFault) 556 // Here's the actual response
701 { 557 if (hash.ContainsKey("UUI"))
702 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUI returned an error: {1}", m_ServerURL, response.FaultString); 558 uui = hash["UUI"].ToString();
703// reason = "XMLRPC Fault";
704 return uui;
705 }
706
707 hash = (Hashtable)response.Value;
708 //foreach (Object o in hash)
709 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
710 try
711 {
712 if (hash == null)
713 {
714 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUI Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
715// reason = "Internal error 1";
716 return uui;
717 }
718
719 // Here's the actual response
720 if (hash.ContainsKey("UUI"))
721 uui = hash["UUI"].ToString();
722
723 }
724 catch
725 {
726 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetUUI response.");
727// reason = "Exception: " + e.Message;
728 }
729 559
730 return uui; 560 return uui;
731 } 561 }
@@ -736,54 +566,17 @@ namespace OpenSim.Services.Connectors.Hypergrid
736 hash["first"] = first; 566 hash["first"] = first;
737 hash["last"] = last; 567 hash["last"] = last;
738 568
739 IList paramList = new ArrayList(); 569 hash = CallServer("get_uuid", hash);
740 paramList.Add(hash);
741
742 XmlRpcRequest request = new XmlRpcRequest("get_uuid", paramList);
743 // string reason = string.Empty;
744 570
745 // Send and get reply 571 if (!hash.ContainsKey("UUID"))
746 UUID uuid = UUID.Zero;
747 XmlRpcResponse response = null;
748 try
749 { 572 {
750 response = request.Send(m_ServerURL, 10000); 573 throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} didn't return a UUID", m_ServerURL));
751 }
752 catch
753 {
754 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUID", m_ServerURL);
755 // reason = "Exception: " + e.Message;
756 return uuid;
757 } 574 }
758 575
759 if (response.IsFault) 576 UUID uuid;
760 { 577 if (!UUID.TryParse(hash["UUID"].ToString(), out uuid))
761 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUID returned an error: {1}", m_ServerURL, response.FaultString);
762 // reason = "XMLRPC Fault";
763 return uuid;
764 }
765
766 hash = (Hashtable)response.Value;
767 //foreach (Object o in hash)
768 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
769 try
770 {
771 if (hash == null)
772 {
773 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUDI Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
774 // reason = "Internal error 1";
775 return uuid;
776 }
777
778 // Here's the actual response
779 if (hash.ContainsKey("UUID"))
780 UUID.TryParse(hash["UUID"].ToString(), out uuid);
781
782 }
783 catch
784 { 578 {
785 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on UUID response."); 579 throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} returned an invalid UUID: {1}", m_ServerURL, hash["UUID"].ToString()));
786 // reason = "Exception: " + e.Message;
787 } 580 }
788 581
789 return uuid; 582 return uuid;