From 262acf61c469cfd746958630c8842ab688118f09 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Sat, 7 Feb 2009 20:16:58 +0000 Subject: [PATCH] * Refactored UserLoginService.CustomiseResponse to be (almost) text-wide identical to LocalLoginService.CustomiseResponse in order to be able to pull them up. --- OpenSim/Grid/UserServer/UserLoginService.cs | 48 ++++++++++++++----- .../Communications/Local/LocalLoginService.cs | 39 +++++++++++---- 2 files changed, 67 insertions(+), 20 deletions(-) diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index dfc44ef85b..0caefb1d43 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -183,12 +183,17 @@ namespace OpenSim.Grid.UserServer // HomeLocation RegionProfileData homeInfo = null; // use the homeRegionID if it is stored already. If not, use the regionHandle as before - if (theUser.HomeRegionID != UUID.Zero) - homeInfo = RegionProfileData.RequestSimProfileData(theUser.HomeRegionID, - m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); + UUID homeRegionId = theUser.HomeRegionID; + ulong homeRegionHandle = theUser.HomeRegion; + if (homeRegionId != UUID.Zero) + { + homeInfo = GetRegionInfo(homeRegionId); + } else - homeInfo = RegionProfileData.RequestSimProfileData(theUser.HomeRegion, - m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); + { + homeInfo = GetRegionInfo(homeRegionHandle); + } + if (homeInfo != null) { response.Home = @@ -204,8 +209,8 @@ namespace OpenSim.Grid.UserServer // Emergency mode: Home-region isn't available, so we can't request the region info. // Use the stored home regionHandle instead. // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again - ulong regionX = theUser.HomeRegion >> 32; - ulong regionY = theUser.HomeRegion & 0xffffffff; + ulong regionX = homeRegionHandle >> 32; + ulong regionY = homeRegionHandle & 0xffffffff; response.Home = string.Format( "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", @@ -227,8 +232,8 @@ namespace OpenSim.Grid.UserServer } else if (startLocationRequest == "last") { - regionInfo = RegionProfileData.RequestSimProfileData(theUser.CurrentAgent.Region, - m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); + UUID lastRegion = theUser.CurrentAgent.Region; + regionInfo = GetRegionInfo(lastRegion); response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; } else @@ -242,8 +247,7 @@ namespace OpenSim.Grid.UserServer else { string region = uriMatch.Groups["region"].ToString(); - regionInfo = RegionProfileData.RequestSimProfileData(region, - m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); + regionInfo = RequestClosestRegion(region); if (regionInfo == null) { m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); @@ -280,7 +284,7 @@ namespace OpenSim.Grid.UserServer } m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); - regionInfo = RegionProfileData.RequestSimProfileData(defaultHandle, m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); + regionInfo = GetRegionInfo(defaultHandle); // Customise the response //response.Home = @@ -296,6 +300,26 @@ namespace OpenSim.Grid.UserServer return PrepareLoginToRegion(regionInfo, theUser, response); } + protected RegionProfileData RequestClosestRegion(string region) + { + return RegionProfileData.RequestSimProfileData(region, + m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); + } + + protected RegionProfileData GetRegionInfo(ulong homeRegionHandle) + { + return RegionProfileData.RequestSimProfileData(homeRegionHandle, + m_config.GridServerURL, m_config.GridSendKey, + m_config.GridRecvKey); + } + + protected RegionProfileData GetRegionInfo(UUID homeRegionId) + { + return RegionProfileData.RequestSimProfileData(homeRegionId, + m_config.GridServerURL, m_config.GridSendKey, + m_config.GridRecvKey); + } + /// /// Add active gestures of the user to the login response. /// diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs index 159773b955..5cd587d072 100644 --- a/OpenSim/Region/Communications/Local/LocalLoginService.cs +++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs @@ -145,10 +145,17 @@ namespace OpenSim.Region.Communications.Local RegionInfo homeInfo = null; // use the homeRegionID if it is stored already. If not, use the regionHandle as before - if (theUser.HomeRegionID != UUID.Zero) - homeInfo = m_gridService.RequestNeighbourInfo(theUser.HomeRegionID); + UUID homeRegionId = theUser.HomeRegionID; + ulong homeRegionHandle = theUser.HomeRegion; + if (homeRegionId != UUID.Zero) + { + homeInfo = GetRegionInfo(homeRegionId); + } else - homeInfo = m_gridService.RequestNeighbourInfo(theUser.HomeRegion); + { + homeInfo = GetRegionInfo(homeRegionHandle); + } + if (homeInfo != null) { response.Home = @@ -164,8 +171,8 @@ namespace OpenSim.Region.Communications.Local // Emergency mode: Home-region isn't available, so we can't request the region info. // Use the stored home regionHandle instead. // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again - ulong regionX = theUser.HomeRegion >> 32; - ulong regionY = theUser.HomeRegion & 0xffffffff; + ulong regionX = homeRegionHandle >> 32; + ulong regionY = homeRegionHandle & 0xffffffff; response.Home = string.Format( "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", @@ -188,7 +195,8 @@ namespace OpenSim.Region.Communications.Local } else if (startLocationRequest == "last") { - regionInfo = m_gridService.RequestNeighbourInfo(theUser.CurrentAgent.Region); + UUID lastRegion = theUser.CurrentAgent.Region; + regionInfo = GetRegionInfo(lastRegion); response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; } else @@ -202,7 +210,7 @@ namespace OpenSim.Region.Communications.Local else { string region = uriMatch.Groups["region"].ToString(); - regionInfo = m_gridService.RequestClosestRegion(region); + regionInfo = RequestClosestRegion(region); if (regionInfo == null) { m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); @@ -238,7 +246,7 @@ namespace OpenSim.Region.Communications.Local } m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); - regionInfo = m_gridService.RequestNeighbourInfo(defaultHandle); + regionInfo = GetRegionInfo(defaultHandle); // Customise the response //response.Home = @@ -254,6 +262,21 @@ namespace OpenSim.Region.Communications.Local return PrepareLoginToRegion(regionInfo, theUser, response); } + protected RegionInfo RequestClosestRegion(string region) + { + return m_gridService.RequestClosestRegion(region); + } + + protected RegionInfo GetRegionInfo(ulong homeRegionHandle) + { + return m_gridService.RequestNeighbourInfo(homeRegionHandle); + } + + protected RegionInfo GetRegionInfo(UUID homeRegionId) + { + return m_gridService.RequestNeighbourInfo(homeRegionId); + } + /// /// Add active gestures of the user to the login response. ///