From 134f86e8d5c414409631b25b8c6f0ee45fbd8631 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 3 Nov 2016 21:44:39 +1000 Subject: Initial update to OpenSim 0.8.2.1 source code. --- .../Hypergrid/GatekeeperServiceConnector.cs | 99 ++-- .../Hypergrid/HGFriendsServicesConnector.cs | 2 +- .../Connectors/Hypergrid/HeloServicesConnector.cs | 57 +- .../Hypergrid/UserAgentServiceConnector.cs | 591 ++++++--------------- 4 files changed, 227 insertions(+), 522 deletions(-) (limited to 'OpenSim/Services/Connectors/Hypergrid') diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index 5bcff48..b1663ee 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs @@ -53,7 +53,8 @@ namespace OpenSim.Services.Connectors.Hypergrid private IAssetService m_AssetService; - public GatekeeperServiceConnector() : base() + public GatekeeperServiceConnector() + : base() { } @@ -123,11 +124,13 @@ namespace OpenSim.Services.Connectors.Hypergrid realHandle = Convert.ToUInt64((string)hash["handle"]); //m_log.Debug(">> HERE, realHandle: " + realHandle); } - if (hash["region_image"] != null) { + if (hash["region_image"] != null) + { imageURL = (string)hash["region_image"]; //m_log.Debug(">> HERE, imageURL: " + imageURL); } - if (hash["external_name"] != null) { + if (hash["external_name"] != null) + { externalName = (string)hash["external_name"]; //m_log.Debug(">> HERE, externalName: " + externalName); } @@ -178,7 +181,7 @@ namespace OpenSim.Services.Connectors.Hypergrid //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); imageData = OpenJPEG.EncodeFromImage(bitmap, true); } - + AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString()); // !!! for now @@ -199,10 +202,16 @@ namespace OpenSim.Services.Connectors.Hypergrid return mapTile; } - public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID) + public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID, UUID agentID, string agentHomeURI, out string message) { Hashtable hash = new Hashtable(); hash["region_uuid"] = regionID.ToString(); + if (agentID != UUID.Zero) + { + hash["agent_id"] = agentID.ToString(); + if (agentHomeURI != null) + hash["agent_home_uri"] = agentHomeURI; + } IList paramList = new ArrayList(); paramList.Add(hash); @@ -216,12 +225,14 @@ namespace OpenSim.Services.Connectors.Hypergrid } catch (Exception e) { + message = "Error contacting grid."; m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Exception " + e.Message); return null; } if (response.IsFault) { + message = "Error contacting grid."; m_log.ErrorFormat("[GATEKEEPER SERVICE CONNECTOR]: remote call returned an error: {0}", response.FaultString); return null; } @@ -233,6 +244,14 @@ namespace OpenSim.Services.Connectors.Hypergrid { bool success = false; Boolean.TryParse((string)hash["result"], out success); + + if (hash["message"] != null) + message = (string)hash["message"]; + else if (success) + message = null; + else + message = "The teleport destination could not be found."; // probably the dest grid is old and doesn't send 'message', but the most common problem is that the region is unavailable + if (success) { GridRegion region = new GridRegion(); @@ -252,12 +271,25 @@ namespace OpenSim.Services.Connectors.Hypergrid region.RegionLocY = n; //m_log.Debug(">> HERE, y: " + region.RegionLocY); } + if (hash["size_x"] != null) + { + Int32.TryParse((string)hash["size_x"], out n); + region.RegionSizeX = n; + //m_log.Debug(">> HERE, x: " + region.RegionLocX); + } + if (hash["size_y"] != null) + { + Int32.TryParse((string)hash["size_y"], out n); + region.RegionSizeY = n; + //m_log.Debug(">> HERE, y: " + region.RegionLocY); + } if (hash["region_name"] != null) { region.RegionName = (string)hash["region_name"]; //m_log.Debug(">> HERE, region_name: " + region.RegionName); } - if (hash["hostname"] != null) { + if (hash["hostname"] != null) + { region.ExternalHostName = (string)hash["hostname"]; //m_log.Debug(">> HERE, hostname: " + region.ExternalHostName); } @@ -275,10 +307,10 @@ namespace OpenSim.Services.Connectors.Hypergrid region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); //m_log.Debug(">> HERE, internal_port: " + region.InternalEndPoint); } - + if (hash["server_uri"] != null) { - region.ServerURI = (string) hash["server_uri"]; + region.ServerURI = (string)hash["server_uri"]; //m_log.Debug(">> HERE, server_uri: " + region.ServerURI); } @@ -289,61 +321,12 @@ namespace OpenSim.Services.Connectors.Hypergrid } catch (Exception e) { + message = "Error parsing response from grid."; m_log.Error("[GATEKEEPER SERVICE CONNECTOR]: Got exception while parsing hyperlink response " + e.StackTrace); return null; } return null; } - - public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason) - { - // m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: CreateAgent start"); - - myipaddress = String.Empty; - reason = String.Empty; - - if (destination == null) - { - m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Given destination is null"); - return false; - } - - string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/"; - - try - { - OSDMap args = aCircuit.PackAgentCircuitData(); - - args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); - args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); - args["destination_name"] = OSD.FromString(destination.RegionName); - args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); - args["teleport_flags"] = OSD.FromString(flags.ToString()); - - OSDMap result = WebUtil.PostToService(uri, args, 80000); - if (result["Success"].AsBoolean()) - { - OSDMap unpacked = (OSDMap)result["_Result"]; - - if (unpacked != null) - { - reason = unpacked["reason"].AsString(); - myipaddress = unpacked["your_ip"].AsString(); - return unpacked["success"].AsBoolean(); - } - } - - reason = result["Message"] != null ? result["Message"].AsString() : "error"; - return false; - } - catch (Exception e) - { - m_log.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e.ToString()); - reason = e.Message; - } - - return false; - } } } diff --git a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs index e984a54..622d4e1 100644 --- a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs @@ -277,7 +277,7 @@ namespace OpenSim.Services.Connectors.Hypergrid { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), 15); } catch (Exception e) { diff --git a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs index 5c50936..b5e6d69 100644 --- a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs @@ -47,16 +47,22 @@ namespace OpenSim.Services.Connectors public HeloServicesConnector(string serverURI) { - if (!serverURI.EndsWith("=")) - m_ServerURI = serverURI.TrimEnd('/') + "/helo/"; - else + try { - // Simian sends malformed urls like this: - // http://valley.virtualportland.org/simtest/Grid/?id= - // - try + Uri uri; + + if (!serverURI.EndsWith("=")) + { + // Let's check if this is a valid URI, because it may not be + uri = new Uri(serverURI); + m_ServerURI = serverURI.TrimEnd('/') + "/helo/"; + } + else { - Uri uri = new Uri(serverURI + "xxx"); + // Simian sends malformed urls like this: + // http://valley.virtualportland.org/simtest/Grid/?id= + // + uri = new Uri(serverURI + "xxx"); if (uri.Query == string.Empty) m_ServerURI = serverURI.TrimEnd('/') + "/helo/"; else @@ -66,26 +72,34 @@ namespace OpenSim.Services.Connectors m_ServerURI = m_ServerURI.TrimEnd('/') + "/helo/"; } } - catch (UriFormatException) - { - m_log.WarnFormat("[HELO SERVICE]: Malformed URL {0}", serverURI); - } + + } + catch (UriFormatException) + { + m_log.WarnFormat("[HELO SERVICE]: Malformed URL {0}", serverURI); } } - public virtual string Helo() { - HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI); - // Eventually we need to switch to HEAD - /* req.Method = "HEAD"; */ + if (String.IsNullOrEmpty(m_ServerURI)) + { + m_log.WarnFormat("[HELO SERVICE]: Unable to invoke HELO due to empty URL"); + return String.Empty; + } try { - WebResponse response = req.GetResponse(); - if (response.Headers.Get("X-Handlers-Provided") == null) // just in case this ever returns a null - return string.Empty; - return response.Headers.Get("X-Handlers-Provided"); + HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI); + // Eventually we need to switch to HEAD + /* req.Method = "HEAD"; */ + + using (WebResponse response = req.GetResponse()) + { + if (response.Headers.Get("X-Handlers-Provided") == null) // just in case this ever returns a null + return string.Empty; + return response.Headers.Get("X-Handlers-Provided"); + } } catch (Exception e) { @@ -95,6 +109,5 @@ namespace OpenSim.Services.Connectors // fail return string.Empty; } - } -} +} \ No newline at end of file diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index 2f263ae..8abd046 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs @@ -44,13 +44,15 @@ using Nini.Config; namespace OpenSim.Services.Connectors.Hypergrid { - public class UserAgentServiceConnector : IUserAgentService + public class UserAgentServiceConnector : SimulationServiceConnector, IUserAgentService { private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - string m_ServerURL; + private string m_ServerURLHost; + private string m_ServerURL; + private GridRegion m_Gatekeeper; public UserAgentServiceConnector(string url) : this(url, true) { @@ -58,7 +60,7 @@ namespace OpenSim.Services.Connectors.Hypergrid public UserAgentServiceConnector(string url, bool dnsLookup) { - m_ServerURL = url; + m_ServerURL = m_ServerURLHost = url; if (dnsLookup) { @@ -74,10 +76,11 @@ namespace OpenSim.Services.Connectors.Hypergrid } catch (Exception e) { - m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", m_ServerURL, e.Message); + m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", url, e.Message); } } - m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL); + + //m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL); } public UserAgentServiceConnector(IConfigSource config) @@ -97,16 +100,23 @@ namespace OpenSim.Services.Connectors.Hypergrid m_log.Error("[USER AGENT CONNECTOR]: No Server URI named in section UserAgentService"); throw new Exception("UserAgent connector init error"); } - m_ServerURL = serviceURI; + + m_ServerURL = m_ServerURLHost = serviceURI; if (!m_ServerURL.EndsWith("/")) m_ServerURL += "/"; - m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL); + //m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0}", m_ServerURL); } + protected override string AgentPath() + { + return "homeagent/"; + } - // The Login service calls this interface with a non-null [client] ipaddress - public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress, out string reason) + // The Login service calls this interface with fromLogin=true + // Sims call it with fromLogin=false + // Either way, this is verified by the handler + public bool LoginAgentToGrid(GridRegion source, AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, bool fromLogin, out string reason) { reason = String.Empty; @@ -117,151 +127,34 @@ namespace OpenSim.Services.Connectors.Hypergrid return false; } - string uri = m_ServerURL + "homeagent/" + aCircuit.AgentID + "/"; - - Console.WriteLine(" >>> LoginAgentToGrid <<< " + uri); - - HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); - AgentCreateRequest.Method = "POST"; - AgentCreateRequest.ContentType = "application/json"; - AgentCreateRequest.Timeout = 10000; - //AgentCreateRequest.KeepAlive = false; - //AgentCreateRequest.Headers.Add("Authorization", authKey); - - // Fill it in - OSDMap args = PackCreateAgentArguments(aCircuit, gatekeeper, destination, ipaddress); - - string strBuffer = ""; - byte[] buffer = new byte[1]; - try - { - strBuffer = OSDParser.SerializeJsonString(args); - Encoding str = Util.UTF8; - buffer = str.GetBytes(strBuffer); - - } - catch (Exception e) - { - m_log.WarnFormat("[USER AGENT CONNECTOR]: Exception thrown on serialization of ChildCreate: {0}", e.Message); - // ignore. buffer will be empty, caller should check. - } - - Stream os = null; - try - { // send the Post - AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send - os = AgentCreateRequest.GetRequestStream(); - os.Write(buffer, 0, strBuffer.Length); //Send it - m_log.InfoFormat("[USER AGENT CONNECTOR]: Posted CreateAgent request to remote sim {0}, region {1}, x={2} y={3}", - uri, destination.RegionName, destination.RegionLocX, destination.RegionLocY); - } - //catch (WebException ex) - catch - { - //m_log.InfoFormat("[USER AGENT CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message); - reason = "cannot contact remote region"; - return false; - } - finally - { - if (os != null) - os.Close(); - } - - // Let's wait for the response - //m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); + GridRegion home = new GridRegion(); + home.ServerURI = m_ServerURL; + home.RegionID = destination.RegionID; + home.RegionLocX = destination.RegionLocX; + home.RegionLocY = destination.RegionLocY; - WebResponse webResponse = null; - StreamReader sr = null; - try - { - webResponse = AgentCreateRequest.GetResponse(); - if (webResponse == null) - { - m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post"); - } - else - { + m_Gatekeeper = gatekeeper; - sr = new StreamReader(webResponse.GetResponseStream()); - string response = sr.ReadToEnd().Trim(); - m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response); - - if (!String.IsNullOrEmpty(response)) - { - try - { - // we assume we got an OSDMap back - OSDMap r = Util.GetOSDMap(response); - bool success = r["success"].AsBoolean(); - reason = r["reason"].AsString(); - return success; - } - catch (NullReferenceException e) - { - m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message); - - // check for old style response - if (response.ToLower().StartsWith("true")) - return true; - - return false; - } - } - } - } - catch (WebException ex) - { - m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); - reason = "Destination did not reply"; - return false; - } - finally - { - if (sr != null) - sr.Close(); - } - - return true; + Console.WriteLine(" >>> LoginAgentToGrid <<< " + home.ServerURI); + uint flags = fromLogin ? (uint)TeleportFlags.ViaLogin : (uint)TeleportFlags.ViaHome; + return CreateAgent(source, home, aCircuit, flags, out reason); } // The simulators call this interface - public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason) + public bool LoginAgentToGrid(GridRegion source, AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason) { - return LoginAgentToGrid(aCircuit, gatekeeper, destination, null, out reason); + return LoginAgentToGrid(source, aCircuit, gatekeeper, destination, false, out reason); } - protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress) + protected override void PackData(OSDMap args, GridRegion source, AgentCircuitData aCircuit, GridRegion destination, uint flags) { - OSDMap args = null; - try - { - args = aCircuit.PackAgentCircuitData(); - } - catch (Exception e) - { - m_log.Debug("[USER AGENT CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message); - } - - // Add the input arguments - args["gatekeeper_serveruri"] = OSD.FromString(gatekeeper.ServerURI); - args["gatekeeper_host"] = OSD.FromString(gatekeeper.ExternalHostName); - args["gatekeeper_port"] = OSD.FromString(gatekeeper.HttpPort.ToString()); - args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); - args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); - args["destination_name"] = OSD.FromString(destination.RegionName); - args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); + base.PackData(args, source, aCircuit, destination, flags); + args["gatekeeper_serveruri"] = OSD.FromString(m_Gatekeeper.ServerURI); + args["gatekeeper_host"] = OSD.FromString(m_Gatekeeper.ExternalHostName); + args["gatekeeper_port"] = OSD.FromString(m_Gatekeeper.HttpPort.ToString()); args["destination_serveruri"] = OSD.FromString(destination.ServerURI); - - // 10/3/2010 - // I added the client_ip up to the regular AgentCircuitData, so this doesn't need to be here. - // This need cleaning elsewhere... - //if (ipaddress != null) - // args["client_ip"] = OSD.FromString(ipaddress.Address.ToString()); - - return args; } public void SetClientToken(UUID sessionID, string token) @@ -269,96 +162,111 @@ namespace OpenSim.Services.Connectors.Hypergrid // no-op } - public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) + private Hashtable CallServer(string methodName, Hashtable hash) { - position = Vector3.UnitY; lookAt = Vector3.UnitY; - - Hashtable hash = new Hashtable(); - hash["userID"] = userID.ToString(); - IList paramList = new ArrayList(); paramList.Add(hash); - XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList); + XmlRpcRequest request = new XmlRpcRequest(methodName, paramList); + + // Send and get reply XmlRpcResponse response = null; try { response = request.Send(m_ServerURL, 10000); } - catch (Exception) + catch (Exception e) { - return null; + m_log.DebugFormat("[USER AGENT CONNECTOR]: {0} call to {1} failed: {2}", methodName, m_ServerURLHost, e.Message); + throw; } if (response.IsFault) { - return null; + throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned an error: {2}", methodName, m_ServerURLHost, response.FaultString)); } hash = (Hashtable)response.Value; - //foreach (Object o in hash) - // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); - try + + if (hash == null) { - bool success = false; - Boolean.TryParse((string)hash["result"], out success); - if (success) - { - GridRegion region = new GridRegion(); + throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned null", methodName, m_ServerURLHost)); + } - UUID.TryParse((string)hash["uuid"], out region.RegionID); - //m_log.Debug(">> HERE, uuid: " + region.RegionID); - int n = 0; - if (hash["x"] != null) - { - Int32.TryParse((string)hash["x"], out n); - region.RegionLocX = n; - //m_log.Debug(">> HERE, x: " + region.RegionLocX); - } - if (hash["y"] != null) - { - Int32.TryParse((string)hash["y"], out n); - region.RegionLocY = n; - //m_log.Debug(">> HERE, y: " + region.RegionLocY); - } - if (hash["region_name"] != null) - { - region.RegionName = (string)hash["region_name"]; - //m_log.Debug(">> HERE, name: " + region.RegionName); - } - if (hash["hostname"] != null) - region.ExternalHostName = (string)hash["hostname"]; - if (hash["http_port"] != null) - { - uint p = 0; - UInt32.TryParse((string)hash["http_port"], out p); - region.HttpPort = p; - } - if (hash.ContainsKey("server_uri") && hash["server_uri"] != null) - region.ServerURI = (string)hash["server_uri"]; + return hash; + } - if (hash["internal_port"] != null) - { - int p = 0; - Int32.TryParse((string)hash["internal_port"], out p); - region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); - } - if (hash["position"] != null) - Vector3.TryParse((string)hash["position"], out position); - if (hash["lookAt"] != null) - Vector3.TryParse((string)hash["lookAt"], out lookAt); + public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) + { + position = Vector3.UnitY; lookAt = Vector3.UnitY; - // Successful return - return region; - } + Hashtable hash = new Hashtable(); + hash["userID"] = userID.ToString(); + + hash = CallServer("get_home_region", hash); + + bool success; + if (!Boolean.TryParse((string)hash["result"], out success) || !success) + return null; + + GridRegion region = new GridRegion(); + UUID.TryParse((string)hash["uuid"], out region.RegionID); + //m_log.Debug(">> HERE, uuid: " + region.RegionID); + int n = 0; + if (hash["x"] != null) + { + Int32.TryParse((string)hash["x"], out n); + region.RegionLocX = n; + //m_log.Debug(">> HERE, x: " + region.RegionLocX); } - catch (Exception) + if (hash["y"] != null) { - return null; + Int32.TryParse((string)hash["y"], out n); + region.RegionLocY = n; + //m_log.Debug(">> HERE, y: " + region.RegionLocY); + } + if (hash["size_x"] != null) + { + Int32.TryParse((string)hash["size_x"], out n); + region.RegionSizeX = n; + //m_log.Debug(">> HERE, x: " + region.RegionLocX); } + if (hash["size_y"] != null) + { + Int32.TryParse((string)hash["size_y"], out n); + region.RegionSizeY = n; + //m_log.Debug(">> HERE, y: " + region.RegionLocY); + } + if (hash["region_name"] != null) + { + region.RegionName = (string)hash["region_name"]; + //m_log.Debug(">> HERE, name: " + region.RegionName); + } + if (hash["hostname"] != null) + region.ExternalHostName = (string)hash["hostname"]; + if (hash["http_port"] != null) + { + uint p = 0; + UInt32.TryParse((string)hash["http_port"], out p); + region.HttpPort = p; + } + if (hash.ContainsKey("server_uri") && hash["server_uri"] != null) + region.ServerURI = (string)hash["server_uri"]; - return null; + if (hash["internal_port"] != null) + { + int p = 0; + Int32.TryParse((string)hash["internal_port"], out p); + region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); + } + if (hash["position"] != null) + Vector3.TryParse((string)hash["position"], out position); + if (hash["lookAt"] != null) + Vector3.TryParse((string)hash["lookAt"], out lookAt); + + // Successful return + return region; } public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName) @@ -445,14 +353,14 @@ namespace OpenSim.Services.Connectors.Hypergrid } catch { - m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for StatusNotification", m_ServerURL); + m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for StatusNotification", m_ServerURLHost); // reason = "Exception: " + e.Message; return friendsOnline; } if (response.IsFault) { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for StatusNotification returned an error: {1}", m_ServerURL, response.FaultString); + m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for StatusNotification returned an error: {1}", m_ServerURLHost, response.FaultString); // reason = "XMLRPC Fault"; return friendsOnline; } @@ -464,7 +372,7 @@ namespace OpenSim.Services.Connectors.Hypergrid { if (hash == null) { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURL); + m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURLHost); // reason = "Internal error 1"; return friendsOnline; } @@ -517,14 +425,14 @@ namespace OpenSim.Services.Connectors.Hypergrid } catch { - m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetOnlineFriends", m_ServerURL); + m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetOnlineFriends", m_ServerURLHost); // reason = "Exception: " + e.Message; return online; } if (response.IsFault) { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetOnlineFriends returned an error: {1}", m_ServerURL, response.FaultString); + m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetOnlineFriends returned an error: {1}", m_ServerURLHost, response.FaultString); // reason = "XMLRPC Fault"; return online; } @@ -536,7 +444,7 @@ namespace OpenSim.Services.Connectors.Hypergrid { if (hash == null) { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURL); + m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURLHost); // reason = "Internal error 1"; return online; } @@ -567,51 +475,17 @@ namespace OpenSim.Services.Connectors.Hypergrid Hashtable hash = new Hashtable(); hash["userID"] = userID.ToString(); - IList paramList = new ArrayList(); - paramList.Add(hash); - - XmlRpcRequest request = new XmlRpcRequest("get_user_info", paramList); + hash = CallServer("get_user_info", hash); Dictionary info = new Dictionary(); - XmlRpcResponse response = null; - try - { - response = request.Send(m_ServerURL, 10000); - } - catch - { - m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUserInfo", m_ServerURL); - return info; - } - if (response.IsFault) + foreach (object key in hash.Keys) { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetServerURLs returned an error: {1}", m_ServerURL, response.FaultString); - return info; - } - - hash = (Hashtable)response.Value; - try - { - if (hash == null) - { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUserInfo Got null response from {0}! THIS IS BAAAAD", m_ServerURL); - return info; - } - - // Here is the actual response - foreach (object key in hash.Keys) + if (hash[key] != null) { - if (hash[key] != null) - { - info.Add(key.ToString(), hash[key]); - } + info.Add(key.ToString(), hash[key]); } } - catch - { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response."); - } return info; } @@ -621,60 +495,16 @@ namespace OpenSim.Services.Connectors.Hypergrid Hashtable hash = new Hashtable(); hash["userID"] = userID.ToString(); - IList paramList = new ArrayList(); - paramList.Add(hash); - - XmlRpcRequest request = new XmlRpcRequest("get_server_urls", paramList); -// string reason = string.Empty; - - // Send and get reply - Dictionary serverURLs = new Dictionary(); - XmlRpcResponse response = null; - try - { - response = request.Send(m_ServerURL, 10000); - } - catch - { - m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetServerURLs", m_ServerURL); -// reason = "Exception: " + e.Message; - return serverURLs; - } - - if (response.IsFault) - { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetServerURLs returned an error: {1}", m_ServerURL, response.FaultString); -// reason = "XMLRPC Fault"; - return serverURLs; - } - - hash = (Hashtable)response.Value; - //foreach (Object o in hash) - // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); - try + hash = CallServer("get_server_urls", hash); + + Dictionary serverURLs = new Dictionary(); + foreach (object key in hash.Keys) { - if (hash == null) + if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null) { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetServerURLs Got null response from {0}! THIS IS BAAAAD", m_ServerURL); -// reason = "Internal error 1"; - return serverURLs; + string serverType = key.ToString().Substring(4); // remove "SRV_" + serverURLs.Add(serverType, hash[key].ToString()); } - - // Here is the actual response - foreach (object key in hash.Keys) - { - if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null) - { - string serverType = key.ToString().Substring(4); // remove "SRV_" - serverURLs.Add(serverType, hash[key].ToString()); - } - } - - } - catch - { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response."); -// reason = "Exception: " + e.Message; } return serverURLs; @@ -685,55 +515,13 @@ namespace OpenSim.Services.Connectors.Hypergrid Hashtable hash = new Hashtable(); hash["userID"] = userID.ToString(); - IList paramList = new ArrayList(); - paramList.Add(hash); + hash = CallServer("locate_user", hash); - XmlRpcRequest request = new XmlRpcRequest("locate_user", paramList); -// string reason = string.Empty; - - // Send and get reply string url = string.Empty; - XmlRpcResponse response = null; - try - { - response = request.Send(m_ServerURL, 10000); - } - catch - { - m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for LocateUser", m_ServerURL); -// reason = "Exception: " + e.Message; - return url; - } - if (response.IsFault) - { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for LocateUser returned an error: {1}", m_ServerURL, response.FaultString); -// reason = "XMLRPC Fault"; - return url; - } - - hash = (Hashtable)response.Value; - //foreach (Object o in hash) - // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); - try - { - if (hash == null) - { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: LocateUser Got null response from {0}! THIS IS BAAAAD", m_ServerURL); -// reason = "Internal error 1"; - return url; - } - - // Here's the actual response - if (hash.ContainsKey("URL")) - url = hash["URL"].ToString(); - - } - catch - { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response."); -// reason = "Exception: " + e.Message; - } + // Here's the actual response + if (hash.ContainsKey("URL")) + url = hash["URL"].ToString(); return url; } @@ -744,55 +532,13 @@ namespace OpenSim.Services.Connectors.Hypergrid hash["userID"] = userID.ToString(); hash["targetUserID"] = targetUserID.ToString(); - IList paramList = new ArrayList(); - paramList.Add(hash); - - XmlRpcRequest request = new XmlRpcRequest("get_uui", paramList); -// string reason = string.Empty; + hash = CallServer("get_uui", hash); - // Send and get reply string uui = string.Empty; - XmlRpcResponse response = null; - try - { - response = request.Send(m_ServerURL, 10000); - } - catch - { - m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUI", m_ServerURL); -// reason = "Exception: " + e.Message; - return uui; - } - - if (response.IsFault) - { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUI returned an error: {1}", m_ServerURL, response.FaultString); -// reason = "XMLRPC Fault"; - return uui; - } - - hash = (Hashtable)response.Value; - //foreach (Object o in hash) - // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); - try - { - if (hash == null) - { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUI Got null response from {0}! THIS IS BAAAAD", m_ServerURL); -// reason = "Internal error 1"; - return uui; - } - // Here's the actual response - if (hash.ContainsKey("UUI")) - uui = hash["UUI"].ToString(); - - } - catch - { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetUUI response."); -// reason = "Exception: " + e.Message; - } + // Here's the actual response + if (hash.ContainsKey("UUI")) + uui = hash["UUI"].ToString(); return uui; } @@ -803,54 +549,17 @@ namespace OpenSim.Services.Connectors.Hypergrid hash["first"] = first; hash["last"] = last; - IList paramList = new ArrayList(); - paramList.Add(hash); + hash = CallServer("get_uuid", hash); - XmlRpcRequest request = new XmlRpcRequest("get_uuid", paramList); - // string reason = string.Empty; - - // Send and get reply - UUID uuid = UUID.Zero; - XmlRpcResponse response = null; - try - { - response = request.Send(m_ServerURL, 10000); - } - catch + if (!hash.ContainsKey("UUID")) { - m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUID", m_ServerURL); - // reason = "Exception: " + e.Message; - return uuid; + throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} didn't return a UUID", m_ServerURLHost)); } - if (response.IsFault) - { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUID returned an error: {1}", m_ServerURL, response.FaultString); - // reason = "XMLRPC Fault"; - return uuid; - } - - hash = (Hashtable)response.Value; - //foreach (Object o in hash) - // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); - try - { - if (hash == null) - { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUDI Got null response from {0}! THIS IS BAAAAD", m_ServerURL); - // reason = "Internal error 1"; - return uuid; - } - - // Here's the actual response - if (hash.ContainsKey("UUID")) - UUID.TryParse(hash["UUID"].ToString(), out uuid); - - } - catch + UUID uuid; + if (!UUID.TryParse(hash["UUID"].ToString(), out uuid)) { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on UUID response."); - // reason = "Exception: " + e.Message; + throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} returned an invalid UUID: {1}", m_ServerURLHost, hash["UUID"].ToString())); } return uuid; @@ -858,7 +567,7 @@ namespace OpenSim.Services.Connectors.Hypergrid private bool GetBoolResponse(XmlRpcRequest request, out string reason) { - //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURL); + //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURLHost); XmlRpcResponse response = null; try { @@ -866,14 +575,14 @@ namespace OpenSim.Services.Connectors.Hypergrid } catch (Exception e) { - m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetBoolResponse", m_ServerURL); + m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetBoolResponse", m_ServerURLHost); reason = "Exception: " + e.Message; return false; } if (response.IsFault) { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetBoolResponse returned an error: {1}", m_ServerURL, response.FaultString); + m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetBoolResponse returned an error: {1}", m_ServerURLHost, response.FaultString); reason = "XMLRPC Fault"; return false; } @@ -885,7 +594,7 @@ namespace OpenSim.Services.Connectors.Hypergrid { if (hash == null) { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got null response from {0}! THIS IS BAAAAD", m_ServerURL); + m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got null response from {0}! THIS IS BAAAAD", m_ServerURLHost); reason = "Internal error 1"; return false; } @@ -896,7 +605,7 @@ namespace OpenSim.Services.Connectors.Hypergrid else { reason = "Internal error 2"; - m_log.WarnFormat("[USER AGENT CONNECTOR]: response from {0} does not have expected key 'result'", m_ServerURL); + m_log.WarnFormat("[USER AGENT CONNECTOR]: response from {0} does not have expected key 'result'", m_ServerURLHost); } return success; -- cgit v1.1