From 6d2893be67fd725090b69f5f31c0985c3d211135 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Thu, 3 Apr 2014 12:47:20 +0300 Subject: [PATCH] When teleporting using Hypergrid, show more informative error messages in case of error --- .../CoreModules/Avatar/Lure/HGLureModule.cs | 13 ++++++++++- .../EntityTransfer/EntityTransferModule.cs | 15 ++++++++----- .../EntityTransfer/HGEntityTransferModule.cs | 22 ++++++++++++++----- .../Handlers/Hypergrid/HypergridHandlers.cs | 9 +++++++- .../Hypergrid/GatekeeperServiceConnector.cs | 13 ++++++++++- .../HypergridService/GatekeeperService.cs | 13 ++++++++++- .../Services/Interfaces/IHypergridServices.cs | 2 +- .../Services/LLLoginService/LLLoginService.cs | 3 ++- 8 files changed, 74 insertions(+), 16 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs index a34f2d21fb..317f0e93ac 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs @@ -239,16 +239,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure GatekeeperServiceConnector gConn = new GatekeeperServiceConnector(); GridRegion gatekeeper = new GridRegion(); gatekeeper.ServerURI = url; - GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(im.RegionID)); + string message; + GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(im.RegionID), out message); if (finalDestination != null) { ScenePresence sp = scene.GetScenePresence(client.AgentId); IEntityTransferModule transferMod = scene.RequestModuleInterface(); if (transferMod != null && sp != null) + { + if (message != null) + sp.ControllingClient.SendAgentAlertMessage(message, true); + transferMod.DoTeleport( sp, gatekeeper, finalDestination, im.Position + new Vector3(0.5f, 0.5f, 0f), Vector3.UnitX, teleportflags); + } + } + else + { + m_log.InfoFormat("[HG LURE MODULE]: Lure failed: {0}", message); + client.SendAgentAlertMessage(message, true); } } } diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index caeb4f8cf1..92ea62c614 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -529,14 +529,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (reg != null) { - finalDestination = GetFinalDestination(reg); + string message; + finalDestination = GetFinalDestination(reg, out message); if (finalDestination == null) { - m_log.WarnFormat( "{0} Final destination is having problems. Unable to teleport {1} {2}", - LogHeader, sp.Name, sp.UUID); + m_log.WarnFormat( "{0} Final destination is having problems. Unable to teleport {1} {2}: {3}", + LogHeader, sp.Name, sp.UUID, message); - sp.ControllingClient.SendTeleportFailed("Problem at destination"); + sp.ControllingClient.SendTeleportFailed(message); return; } @@ -557,6 +558,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return; } + if (message != null) + sp.ControllingClient.SendAgentAlertMessage(message, true); + // // This is it // @@ -1327,8 +1331,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer scene.SendKillObject(new List { localID }); } - protected virtual GridRegion GetFinalDestination(GridRegion region) + protected virtual GridRegion GetFinalDestination(GridRegion region, out string message) { + message = null; return region; } diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index e354522624..fa05c9050f 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -225,19 +225,20 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer #region HG overrides of IEntiryTransferModule - protected override GridRegion GetFinalDestination(GridRegion region) + protected override GridRegion GetFinalDestination(GridRegion region, out string message) { int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, region.RegionID); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: region {0} flags: {1}", region.RegionName, flags); + message = null; if ((flags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0) { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Destination region is hyperlink"); - GridRegion real_destination = m_GatekeeperConnector.GetHyperlinkRegion(region, region.RegionID); + GridRegion real_destination = m_GatekeeperConnector.GetHyperlinkRegion(region, region.RegionID, out message); if (real_destination != null) - m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: GetFinalDestination serveruri -> {0}", real_destination.ServerURI); + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: GetFinalDestination: ServerURI={0}", real_destination.ServerURI); else - m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: GetHyperlinkRegion to Gatekeeper {0} failed", region.ServerURI); + m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: GetHyperlinkRegion of region {0} from Gatekeeper {1} failed: {2}", region.RegionID, region.ServerURI, message); return real_destination; } @@ -533,7 +534,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer GatekeeperServiceConnector gConn = new GatekeeperServiceConnector(); GridRegion gatekeeper = new GridRegion(); gatekeeper.ServerURI = lm.Gatekeeper; - GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(lm.RegionID)); + string message; + GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(lm.RegionID), out message); if (finalDestination != null) { @@ -541,9 +543,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer IEntityTransferModule transferMod = scene.RequestModuleInterface(); if (transferMod != null && sp != null) + { + if (message != null) + sp.ControllingClient.SendAgentAlertMessage(message, true); + transferMod.DoTeleport( sp, gatekeeper, finalDestination, lm.Position, Vector3.UnitX, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); + } + } + else + { + remoteClient.SendTeleportFailed(message); + return; } } diff --git a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs index f25e6e0cbe..a89d7f7c17 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs @@ -94,11 +94,14 @@ namespace OpenSim.Server.Handlers.Hypergrid UUID regionID = UUID.Zero; UUID.TryParse(regionID_str, out regionID); - GridRegion regInfo = m_GatekeeperService.GetHyperlinkRegion(regionID); + string message; + GridRegion regInfo = m_GatekeeperService.GetHyperlinkRegion(regionID, out message); Hashtable hash = new Hashtable(); if (regInfo == null) + { hash["result"] = "false"; + } else { hash["result"] = "true"; @@ -112,6 +115,10 @@ namespace OpenSim.Server.Handlers.Hypergrid hash["http_port"] = regInfo.HttpPort.ToString(); hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); } + + if (message != null) + hash["message"] = message; + XmlRpcResponse response = new XmlRpcResponse(); response.Value = hash; return response; diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index 5d7dcfd473..8b1cc27460 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs @@ -202,7 +202,7 @@ namespace OpenSim.Services.Connectors.Hypergrid return mapTile; } - public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID) + public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID, out string message) { Hashtable hash = new Hashtable(); hash["region_uuid"] = regionID.ToString(); @@ -219,12 +219,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; } @@ -236,6 +238,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(); @@ -305,6 +315,7 @@ 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; } diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index 7a0228b75e..e9d41c7891 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs @@ -204,15 +204,26 @@ namespace OpenSim.Services.HypergridService return true; } - public GridRegion GetHyperlinkRegion(UUID regionID) + public GridRegion GetHyperlinkRegion(UUID regionID, out string message) { m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to get hyperlink region {0}", regionID); + message = null; if (!m_AllowTeleportsToAnyRegion) + { // Don't even check the given regionID + message = "Teleporting to the default region."; return m_DefaultGatewayRegion; + } GridRegion region = m_GridService.GetRegionByUUID(m_ScopeID, regionID); + + if (region == null) + { + message = "The teleport destination could not be found."; + return null; + } + return region; } diff --git a/OpenSim/Services/Interfaces/IHypergridServices.cs b/OpenSim/Services/Interfaces/IHypergridServices.cs index bece4c7b4a..a846badf40 100644 --- a/OpenSim/Services/Interfaces/IHypergridServices.cs +++ b/OpenSim/Services/Interfaces/IHypergridServices.cs @@ -37,7 +37,7 @@ namespace OpenSim.Services.Interfaces public interface IGatekeeperService { bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason); - GridRegion GetHyperlinkRegion(UUID regionID); + GridRegion GetHyperlinkRegion(UUID regionID, out string message); bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason); diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index b61b5e8466..6d6e3d65ae 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -750,9 +750,10 @@ namespace OpenSim.Services.LLLoginService UUID regionID; ulong handle; string imageURL = string.Empty, reason = string.Empty; + string message; if (m_GatekeeperConnector.LinkRegion(gatekeeper, out regionID, out handle, out domainName, out imageURL, out reason)) { - GridRegion destination = m_GatekeeperConnector.GetHyperlinkRegion(gatekeeper, regionID); + GridRegion destination = m_GatekeeperConnector.GetHyperlinkRegion(gatekeeper, regionID, out message); return destination; }