Add the missing bits for the new region-search:
- Added lookup in the data-layer - MySQL works - SQLite doesn't have a grid-db, so it won't work there - I added MSSQL-code to the best of my knowledge; but I don't know MSSQL :-) - Added the plumbing up to OGS1GridServices. This speaks with the grid-server via XMLRPC. - Modified MapSearchModule to use the new data. It's backward compatible; if used with an old grid-server, it just returns one found region instead of a list. - Refactored a bit. Note: This updates data, grid-server and region code. No new files.0.6.0-stable
parent
ab260b5d23
commit
16d68749a4
|
@ -25,6 +25,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
|
||||||
namespace OpenSim.Data
|
namespace OpenSim.Data
|
||||||
|
@ -35,6 +36,7 @@ namespace OpenSim.Data
|
||||||
public abstract RegionProfileData GetProfileByUUID(UUID UUID);
|
public abstract RegionProfileData GetProfileByUUID(UUID UUID);
|
||||||
public abstract RegionProfileData GetProfileByString(string regionName);
|
public abstract RegionProfileData GetProfileByString(string regionName);
|
||||||
public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
|
public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
|
||||||
|
public abstract List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum);
|
||||||
public abstract bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey);
|
public abstract bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey);
|
||||||
public abstract DataResponse AddProfile(RegionProfileData profile);
|
public abstract DataResponse AddProfile(RegionProfileData profile);
|
||||||
public abstract ReservationData GetReservationAtPoint(uint x, uint y);
|
public abstract ReservationData GetReservationAtPoint(uint x, uint y);
|
||||||
|
@ -44,6 +46,7 @@ namespace OpenSim.Data
|
||||||
public abstract void Initialise();
|
public abstract void Initialise();
|
||||||
public abstract void Initialise(string connect);
|
public abstract void Initialise(string connect);
|
||||||
public abstract void Dispose();
|
public abstract void Dispose();
|
||||||
|
|
||||||
public abstract string Name { get; }
|
public abstract string Name { get; }
|
||||||
public abstract string Version { get; }
|
public abstract string Version { get; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
|
||||||
|
@ -79,6 +80,14 @@ namespace OpenSim.Data
|
||||||
/// <returns>An array containing all the sim profiles in the specified range</returns>
|
/// <returns>An array containing all the sim profiles in the specified range</returns>
|
||||||
RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
|
RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns up to maxNum profiles of regions that have a name starting with namePrefix
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name to match against</param>
|
||||||
|
/// <param name="maxNum">Maximum number of profiles to return</param>
|
||||||
|
/// <returns>A list of sim profiles</returns>
|
||||||
|
List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Authenticates a sim by use of its recv key.
|
/// Authenticates a sim by use of its recv key.
|
||||||
/// WARNING: Insecure
|
/// WARNING: Insecure
|
||||||
|
|
|
@ -216,6 +216,33 @@ namespace OpenSim.Data.MSSQL
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns up to maxNum profiles of regions that have a name starting with namePrefix
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name to match against</param>
|
||||||
|
/// <param name="maxNum">Maximum number of profiles to return</param>
|
||||||
|
/// <returns>A list of sim profiles</returns>
|
||||||
|
override public List<RegionProfileData> GetRegionsByName (string namePrefix, uint maxNum)
|
||||||
|
{
|
||||||
|
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM regions WHERE regionName LIKE @name"))
|
||||||
|
{
|
||||||
|
command.Parameters.Add(database.CreateParameter("name", namePrefix + "%"));
|
||||||
|
|
||||||
|
List<RegionProfileData> rows = new List<RegionProfileData>();
|
||||||
|
|
||||||
|
using (SqlDataReader reader = command.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (rows.Count < maxNum && reader.Read())
|
||||||
|
{
|
||||||
|
rows.Add(ReadSimRow(reader));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a sim profile from its location
|
/// Returns a sim profile from its location
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -282,6 +282,52 @@ namespace OpenSim.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns up to maxNum profiles of regions that have a name starting with namePrefix
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name to match against</param>
|
||||||
|
/// <param name="maxNum">Maximum number of profiles to return</param>
|
||||||
|
/// <returns>A list of sim profiles</returns>
|
||||||
|
override public List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum)
|
||||||
|
{
|
||||||
|
MySQLSuperManager dbm = GetLockedConnection();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
param["?name"] = namePrefix + "%";
|
||||||
|
|
||||||
|
IDbCommand result =
|
||||||
|
dbm.Manager.Query(
|
||||||
|
"SELECT * FROM regions WHERE regionName LIKE ?name",
|
||||||
|
param);
|
||||||
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
RegionProfileData row;
|
||||||
|
|
||||||
|
List<RegionProfileData> rows = new List<RegionProfileData>();
|
||||||
|
|
||||||
|
while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null)
|
||||||
|
{
|
||||||
|
rows.Add(row);
|
||||||
|
}
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
dbm.Manager.Reconnect();
|
||||||
|
m_log.Error(e.ToString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
dbm.Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a sim profile from it's location
|
/// Returns a sim profile from it's location
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -108,6 +108,18 @@ namespace OpenSim.Data.SQLite
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns up to maxNum profiles of regions that have a name starting with namePrefix
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name to match against</param>
|
||||||
|
/// <param name="maxNum">Maximum number of profiles to return</param>
|
||||||
|
/// <returns>A list of sim profiles</returns>
|
||||||
|
override public List<RegionProfileData> GetRegionsByName (string namePrefix, uint maxNum)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a sim profile from it's handle
|
/// Returns a sim profile from it's handle
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -70,5 +70,20 @@ namespace OpenSim.Framework.Communications
|
||||||
List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY);
|
List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY);
|
||||||
// not complete yet, only contains the fields needed for ParcelInfoReqeust
|
// not complete yet, only contains the fields needed for ParcelInfoReqeust
|
||||||
LandData RequestLandData(ulong regionHandle, uint x, uint y);
|
LandData RequestLandData(ulong regionHandle, uint x, uint y);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get information about regions starting with the provided name.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">
|
||||||
|
/// The name to match against.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="maxNumber">
|
||||||
|
/// The maximum number of results to return.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// A list of <see cref="RegionInfo"/>s of regions with matching name. If the
|
||||||
|
/// grid-server couldn't be contacted or returned an error, return null.
|
||||||
|
/// </returns>
|
||||||
|
List<RegionInfo> RequestNamedRegions(string name, int maxNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,6 +188,26 @@ namespace OpenSim.Grid.GridServer
|
||||||
return regions;
|
return regions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<RegionProfileData> GetRegions(string name, int maxNum)
|
||||||
|
{
|
||||||
|
List<RegionProfileData> regions = new List<RegionProfileData>();
|
||||||
|
foreach (IGridDataPlugin plugin in _plugins)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int num = maxNum - regions.Count;
|
||||||
|
List <RegionProfileData> profiles = plugin.GetRegionsByName(name, (uint)num);
|
||||||
|
if (profiles != null) regions.AddRange(profiles);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
m_log.Warn("[storage]: Unable to query regionblock via " + plugin.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return regions;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a XML String containing a list of the neighbouring regions
|
/// Returns a XML String containing a list of the neighbouring regions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -876,6 +896,56 @@ namespace OpenSim.Grid.GridServer
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns up to <code>maxNumber</code> profiles of regions that have a name starting with <code>name</code>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public XmlRpcResponse XmlRpcSearchForRegionMethod(XmlRpcRequest request)
|
||||||
|
{
|
||||||
|
Hashtable requestData = (Hashtable)request.Params[0];
|
||||||
|
|
||||||
|
if (!requestData.ContainsKey("name") || !requestData.Contains("maxNumber"))
|
||||||
|
{
|
||||||
|
m_log.Warn("[DATA] Invalid region-search request; missing name or maxNumber");
|
||||||
|
return new XmlRpcResponse(500, "Missing name or maxNumber in region search request");
|
||||||
|
}
|
||||||
|
|
||||||
|
Hashtable responseData = new Hashtable();
|
||||||
|
|
||||||
|
string name = (string)requestData["name"];
|
||||||
|
int maxNumber = Convert.ToInt32((string)requestData["maxNumber"]);
|
||||||
|
if (maxNumber == 0 || name.Length < 3)
|
||||||
|
{
|
||||||
|
// either we didn't want any, or we were too unspecific
|
||||||
|
responseData["numFound"] = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
List<RegionProfileData> sims = GetRegions(name, maxNumber);
|
||||||
|
|
||||||
|
responseData["numFound"] = sims.Count;
|
||||||
|
for (int i = 0; i < sims.Count; ++i)
|
||||||
|
{
|
||||||
|
RegionProfileData sim = sims[i];
|
||||||
|
string prefix = "region" + i + ".";
|
||||||
|
responseData[prefix + "region_name"] = sim.regionName;
|
||||||
|
responseData[prefix + "region_UUID"] = sim.UUID.ToString();
|
||||||
|
responseData[prefix + "region_locx"] = sim.regionLocX.ToString();
|
||||||
|
responseData[prefix + "region_locy"] = sim.regionLocY.ToString();
|
||||||
|
responseData[prefix + "sim_ip"] = sim.serverIP.ToString();
|
||||||
|
responseData[prefix + "sim_port"] = sim.serverPort.ToString();
|
||||||
|
responseData[prefix + "remoting_port"] = sim.remotingPort.ToString();
|
||||||
|
responseData[prefix + "http_port"] = sim.httpPort.ToString();
|
||||||
|
responseData[prefix + "map_UUID"] = sim.regionMapTextureID.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XmlRpcResponse response = new XmlRpcResponse();
|
||||||
|
response.Value = responseData;
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performs a REST Get Operation
|
/// Performs a REST Get Operation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -101,6 +101,7 @@ namespace OpenSim.Grid.GridServer
|
||||||
m_httpServer.AddXmlRPCHandler("simulator_data_request", m_gridManager.XmlRpcSimulatorDataRequestMethod);
|
m_httpServer.AddXmlRPCHandler("simulator_data_request", m_gridManager.XmlRpcSimulatorDataRequestMethod);
|
||||||
m_httpServer.AddXmlRPCHandler("simulator_after_region_moved", m_gridManager.XmlRpcDeleteRegionMethod);
|
m_httpServer.AddXmlRPCHandler("simulator_after_region_moved", m_gridManager.XmlRpcDeleteRegionMethod);
|
||||||
m_httpServer.AddXmlRPCHandler("map_block", m_gridManager.XmlRpcMapBlockMethod);
|
m_httpServer.AddXmlRPCHandler("map_block", m_gridManager.XmlRpcMapBlockMethod);
|
||||||
|
m_httpServer.AddXmlRPCHandler("search_for_region_by_name", m_gridManager.XmlRpcSearchForRegionMethod);
|
||||||
|
|
||||||
// Message Server ---> Grid Server
|
// Message Server ---> Grid Server
|
||||||
m_httpServer.AddXmlRPCHandler("register_messageserver", m_gridManager.XmlRPCRegisterMessageServer);
|
m_httpServer.AddXmlRPCHandler("register_messageserver", m_gridManager.XmlRPCRegisterMessageServer);
|
||||||
|
|
|
@ -514,5 +514,20 @@ namespace OpenSim.Region.Communications.Local
|
||||||
m_log.Debug("[INTERREGION STANDALONE] didn't find land data locally.");
|
m_log.Debug("[INTERREGION STANDALONE] didn't find land data locally.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<RegionInfo> RequestNamedRegions (string name, int maxNumber)
|
||||||
|
{
|
||||||
|
List<RegionInfo> regions = new List<RegionInfo>();
|
||||||
|
foreach (RegionInfo info in m_regions.Values)
|
||||||
|
{
|
||||||
|
if (info.RegionName.StartsWith(name))
|
||||||
|
{
|
||||||
|
regions.Add(info);
|
||||||
|
if (regions.Count >= maxNumber) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return regions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,27 +352,7 @@ namespace OpenSim.Region.Communications.OGS1
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint regX = Convert.ToUInt32((string) responseData["region_locx"]);
|
regionInfo = buildRegionInfo(responseData, String.Empty);
|
||||||
uint regY = Convert.ToUInt32((string) responseData["region_locy"]);
|
|
||||||
string internalIpStr = (string) responseData["sim_ip"];
|
|
||||||
uint port = Convert.ToUInt32(responseData["sim_port"]);
|
|
||||||
// string externalUri = (string) responseData["sim_uri"];
|
|
||||||
|
|
||||||
IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port);
|
|
||||||
// string neighbourExternalUri = externalUri;
|
|
||||||
regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr);
|
|
||||||
|
|
||||||
regionInfo.RemotingPort = Convert.ToUInt32((string) responseData["remoting_port"]);
|
|
||||||
regionInfo.RemotingAddress = internalIpStr;
|
|
||||||
|
|
||||||
if (responseData.ContainsKey("http_port"))
|
|
||||||
{
|
|
||||||
regionInfo.HttpPort = Convert.ToUInt32((string) responseData["http_port"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
regionInfo.RegionID = new UUID((string) responseData["region_UUID"]);
|
|
||||||
regionInfo.RegionName = (string) responseData["region_name"];
|
|
||||||
|
|
||||||
if (requestData.ContainsKey("regionHandle"))
|
if (requestData.ContainsKey("regionHandle"))
|
||||||
{
|
{
|
||||||
m_remoteRegionInfoCache.Add(Convert.ToUInt64((string) requestData["regionHandle"]), regionInfo);
|
m_remoteRegionInfoCache.Add(Convert.ToUInt64((string) requestData["regionHandle"]), regionInfo);
|
||||||
|
@ -479,30 +459,11 @@ namespace OpenSim.Region.Communications.OGS1
|
||||||
|
|
||||||
if (responseData.ContainsKey("error"))
|
if (responseData.ContainsKey("error"))
|
||||||
{
|
{
|
||||||
m_log.Error("[OGS1 GRID SERVICES]: Error received from grid server" + responseData["error"]);
|
m_log.ErrorFormat("[OGS1 GRID SERVICES]: Error received from grid server: ", responseData["error"]);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint regX = Convert.ToUInt32((string) responseData["region_locx"]);
|
regionInfo = buildRegionInfo(responseData, "");
|
||||||
uint regY = Convert.ToUInt32((string) responseData["region_locy"]);
|
|
||||||
string internalIpStr = (string) responseData["sim_ip"];
|
|
||||||
uint port = Convert.ToUInt32(responseData["sim_port"]);
|
|
||||||
// string externalUri = (string) responseData["sim_uri"];
|
|
||||||
|
|
||||||
IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port);
|
|
||||||
// string neighbourExternalUri = externalUri;
|
|
||||||
regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr);
|
|
||||||
|
|
||||||
regionInfo.RemotingPort = Convert.ToUInt32((string) responseData["remoting_port"]);
|
|
||||||
regionInfo.RemotingAddress = internalIpStr;
|
|
||||||
|
|
||||||
if (responseData.ContainsKey("http_port"))
|
|
||||||
{
|
|
||||||
regionInfo.HttpPort = Convert.ToUInt32((string) responseData["http_port"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
regionInfo.RegionID = new UUID((string) responseData["region_UUID"]);
|
|
||||||
regionInfo.RegionName = (string) responseData["region_name"];
|
|
||||||
|
|
||||||
if (!m_remoteRegionInfoCache.ContainsKey(regionInfo.RegionHandle))
|
if (!m_remoteRegionInfoCache.ContainsKey(regionInfo.RegionHandle))
|
||||||
m_remoteRegionInfoCache.Add(regionInfo.RegionHandle, regionInfo);
|
m_remoteRegionInfoCache.Add(regionInfo.RegionHandle, regionInfo);
|
||||||
|
@ -1676,7 +1637,8 @@ namespace OpenSim.Region.Communications.OGS1
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hash = (Hashtable)response.Value;
|
hash = (Hashtable)response.Value;
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
landData = new LandData();
|
landData = new LandData();
|
||||||
landData.AABBMax = Vector3.Parse((string)hash["AABBMax"]);
|
landData.AABBMax = Vector3.Parse((string)hash["AABBMax"]);
|
||||||
landData.AABBMin = Vector3.Parse((string)hash["AABBMin"]);
|
landData.AABBMin = Vector3.Parse((string)hash["AABBMin"]);
|
||||||
|
@ -1745,5 +1707,76 @@ namespace OpenSim.Region.Communications.OGS1
|
||||||
response.Value = hash;
|
response.Value = hash;
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<RegionInfo> RequestNamedRegions (string name, int maxNumber)
|
||||||
|
{
|
||||||
|
// no asking of the local backend first, here, as we have to ask the gridserver anyway.
|
||||||
|
Hashtable hash = new Hashtable();
|
||||||
|
hash["name"] = name;
|
||||||
|
hash["maxNumber"] = maxNumber.ToString();
|
||||||
|
|
||||||
|
IList paramList = new ArrayList();
|
||||||
|
paramList.Add(hash);
|
||||||
|
|
||||||
|
Hashtable result = XmlRpcSearchForRegionByName(paramList);
|
||||||
|
if (result == null) return null;
|
||||||
|
|
||||||
|
uint numberFound = Convert.ToUInt32(result["numFound"]);
|
||||||
|
List<RegionInfo> infos = new List<RegionInfo>();
|
||||||
|
for (int i = 0; i < numberFound; ++i)
|
||||||
|
{
|
||||||
|
string prefix = "region" + i + ".";
|
||||||
|
RegionInfo info = buildRegionInfo(result, prefix);
|
||||||
|
infos.Add(info);
|
||||||
|
}
|
||||||
|
return infos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private RegionInfo buildRegionInfo(Hashtable responseData, string prefix)
|
||||||
|
{
|
||||||
|
uint regX = Convert.ToUInt32((string) responseData[prefix + "region_locx"]);
|
||||||
|
uint regY = Convert.ToUInt32((string) responseData[prefix + "region_locy"]);
|
||||||
|
string internalIpStr = (string) responseData[prefix + "sim_ip"];
|
||||||
|
uint port = Convert.ToUInt32(responseData[prefix + "sim_port"]);
|
||||||
|
|
||||||
|
IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(internalIpStr), (int) port);
|
||||||
|
|
||||||
|
RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr);
|
||||||
|
regionInfo.RemotingPort = Convert.ToUInt32((string) responseData[prefix + "remoting_port"]);
|
||||||
|
regionInfo.RemotingAddress = internalIpStr;
|
||||||
|
|
||||||
|
if (responseData.ContainsKey(prefix + "http_port"))
|
||||||
|
{
|
||||||
|
regionInfo.HttpPort = Convert.ToUInt32((string) responseData[prefix + "http_port"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
regionInfo.RegionID = new UUID((string) responseData[prefix + "region_UUID"]);
|
||||||
|
regionInfo.RegionName = (string) responseData[prefix + "region_name"];
|
||||||
|
|
||||||
|
regionInfo.RegionSettings.TerrainImageID = new UUID((string) responseData[prefix + "map_UUID"]);
|
||||||
|
return regionInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Hashtable XmlRpcSearchForRegionByName(IList parameters)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
XmlRpcRequest request = new XmlRpcRequest("search_for_region_by_name", parameters);
|
||||||
|
XmlRpcResponse resp = request.Send(serversInfo.GridURL, 10000);
|
||||||
|
Hashtable respData = (Hashtable) resp.Value;
|
||||||
|
if (respData != null && respData.Contains("faultCode"))
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[OGS1 GRID SERVICES]: Got an error while contacting GridServer: {0}", respData["faultString"]);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return respData;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.Error("[OGS1 GRID SERVICES]: MapBlockQuery XMLRPC failure: ", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -78,35 +78,44 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
|
||||||
|
|
||||||
private void OnMapNameRequest(IClientAPI remoteClient, string mapName)
|
private void OnMapNameRequest(IClientAPI remoteClient, string mapName)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[MAPSEARCH]: looking for region {0}", mapName);
|
if (mapName.Length < 3)
|
||||||
|
{
|
||||||
// TODO currently, this only returns one region per name. LL servers will return all starting with the provided name.
|
remoteClient.SendAlertMessage("Use a search string with at least 3 characters");
|
||||||
RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName);
|
return;
|
||||||
// fetch the mapblock of the named sim. We need this anyway (we have the map open, and just jumped to the sim),
|
}
|
||||||
// so there shouldn't be any penalty for that.
|
|
||||||
if (info == null)
|
// try to fetch from GridServer
|
||||||
{
|
List<RegionInfo> regionInfos = m_scene.SceneGridService.RequestNamedRegions(mapName, 20);
|
||||||
m_log.Warn("[MAPSEARCHMODULE]: Got Null Region Question!");
|
if (regionInfos == null)
|
||||||
return;
|
{
|
||||||
|
m_log.Warn("[MAPSEARCHMODULE]: RequestNamedRegions returned null. Old gridserver?");
|
||||||
|
// service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region
|
||||||
|
regionInfos = new List<RegionInfo>();
|
||||||
|
RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName);
|
||||||
|
if (info != null) regionInfos.Add(info);
|
||||||
}
|
}
|
||||||
List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks((int)info.RegionLocX,
|
|
||||||
(int)info.RegionLocY,
|
|
||||||
(int)info.RegionLocX,
|
|
||||||
(int)info.RegionLocY);
|
|
||||||
|
|
||||||
List<MapBlockData> blocks = new List<MapBlockData>();
|
List<MapBlockData> blocks = new List<MapBlockData>();
|
||||||
|
|
||||||
MapBlockData data = new MapBlockData();
|
MapBlockData data;
|
||||||
data.Agents = 3; // TODO set to number of agents in region
|
if (regionInfos.Count > 0)
|
||||||
data.Access = 21; // TODO what's this?
|
{
|
||||||
data.MapImageId = mapBlocks.Count == 0 ? UUID.Zero : mapBlocks[0].MapImageId;
|
foreach (RegionInfo info in regionInfos)
|
||||||
data.Name = info.RegionName;
|
{
|
||||||
data.RegionFlags = 0; // TODO fix this
|
data = new MapBlockData();
|
||||||
data.WaterHeight = 0; // not used
|
data.Agents = 0;
|
||||||
data.X = (ushort)info.RegionLocX;
|
data.Access = 21; // TODO what's this?
|
||||||
data.Y = (ushort)info.RegionLocY;
|
data.MapImageId = info.RegionSettings.TerrainImageID;
|
||||||
blocks.Add(data);
|
data.Name = info.RegionName;
|
||||||
|
data.RegionFlags = 0; // TODO not used?
|
||||||
|
data.WaterHeight = 0; // not used
|
||||||
|
data.X = (ushort)info.RegionLocX;
|
||||||
|
data.Y = (ushort)info.RegionLocY;
|
||||||
|
blocks.Add(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// final block, closing the search result
|
||||||
data = new MapBlockData();
|
data = new MapBlockData();
|
||||||
data.Agents = 0;
|
data.Agents = 0;
|
||||||
data.Access = 255;
|
data.Access = 255;
|
||||||
|
|
|
@ -806,6 +806,10 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
|
return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<RegionInfo> RequestNamedRegions(string name, int maxNumber)
|
||||||
|
{
|
||||||
|
return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue