mirror of
https://github.com/opensim/opensim.git
synced 2026-08-10 19:36:07 +08:00
add gridservice GetOnlineRegions()
This commit is contained in:
@@ -640,6 +640,58 @@ namespace OpenSim.Services.Connectors
|
||||
return rinfos;
|
||||
}
|
||||
|
||||
public List<GridRegion> GetOnlineRegions(UUID scopeID, int x, int y, int maxCount)
|
||||
{
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
|
||||
sendData["SCOPEID"] = scopeID.ToString();
|
||||
sendData["X"] = x.ToString();
|
||||
sendData["Y"] = y.ToString();
|
||||
sendData["MC"] = maxCount.ToString();
|
||||
|
||||
sendData["METHOD"] = "get_online_regions";
|
||||
|
||||
List<GridRegion> rinfos = new List<GridRegion>();
|
||||
string reply = string.Empty;
|
||||
try
|
||||
{
|
||||
reply = SynchronousRestFormsRequester.MakePostRequest(m_ServerURI + "/grid",
|
||||
ServerUtils.BuildQueryString(sendData), m_Auth);
|
||||
|
||||
//m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", m_ServerURI + "/grid", e.Message);
|
||||
return rinfos;
|
||||
}
|
||||
|
||||
if (reply != string.Empty)
|
||||
{
|
||||
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
|
||||
|
||||
if (replyData != null)
|
||||
{
|
||||
Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
|
||||
foreach (object r in rinfosList)
|
||||
{
|
||||
if (r is Dictionary<string, object>)
|
||||
{
|
||||
GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
|
||||
rinfos.Add(rinfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
m_log.DebugFormat("[GRID CONNECTOR]: GetOnlineRegions {0}, {1}-{2} received null response",
|
||||
scopeID, x, y);
|
||||
}
|
||||
else
|
||||
m_log.DebugFormat("[GRID CONNECTOR]: GetOnlineRegions received null reply");
|
||||
|
||||
return rinfos;
|
||||
}
|
||||
|
||||
public List<GridRegion> GetHyperlinks(UUID scopeID)
|
||||
{
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
|
||||
@@ -790,8 +790,8 @@ namespace OpenSim.Services.GridService
|
||||
List<GridRegion> ret = new List<GridRegion>();
|
||||
|
||||
List<RegionData> regions = m_Database.GetFallbackRegions(scopeID);
|
||||
if(regions.Count > 0)
|
||||
{
|
||||
if (regions.Count > 0)
|
||||
{
|
||||
if (regions.Count > 1)
|
||||
{
|
||||
regions.Sort(new RegionDataDistanceCompare(x, y));
|
||||
@@ -800,7 +800,7 @@ namespace OpenSim.Services.GridService
|
||||
foreach (RegionData r in regions)
|
||||
{
|
||||
int rflags = Convert.ToInt32(r.Data["flags"]);
|
||||
if((rflags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0)
|
||||
if ((rflags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0)
|
||||
continue;
|
||||
if ((rflags & (int)OpenSim.Framework.RegionFlags.RegionOnline) != 0)
|
||||
ret.Add(RegionData2RegionInfo(r));
|
||||
@@ -811,6 +811,33 @@ namespace OpenSim.Services.GridService
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<GridRegion> GetOnlineRegions(UUID scopeID, int x, int y, int maxCount)
|
||||
{
|
||||
List<GridRegion> ret = new List<GridRegion>();
|
||||
|
||||
List<RegionData> regions = m_Database.GetOnlineRegions(scopeID);
|
||||
if (regions.Count > 0)
|
||||
{
|
||||
if (regions.Count > 1)
|
||||
{
|
||||
regions.Sort(new RegionDataDistanceCompare(x, y));
|
||||
}
|
||||
|
||||
foreach (RegionData r in regions)
|
||||
{
|
||||
int rflags = Convert.ToInt32(r.Data["flags"]);
|
||||
if ((rflags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0)
|
||||
continue;
|
||||
ret.Add(RegionData2RegionInfo(r));
|
||||
if(ret.Count >= maxCount)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_log.DebugFormat("[GRID SERVICE]: online returned {0} regions", ret.Count);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<GridRegion> GetHyperlinks(UUID scopeID)
|
||||
{
|
||||
List<GridRegion> ret = new List<GridRegion>();
|
||||
|
||||
@@ -107,6 +107,7 @@ namespace OpenSim.Services.Interfaces
|
||||
List<GridRegion> GetDefaultHypergridRegions(UUID scopeID);
|
||||
List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y);
|
||||
List<GridRegion> GetHyperlinks(UUID scopeID);
|
||||
List<GridRegion> GetOnlineRegions(UUID scopeID, int x, int y, int maxCount);
|
||||
|
||||
/// <summary>
|
||||
/// Get internal OpenSimulator region flags.
|
||||
|
||||
Reference in New Issue
Block a user