Added initial support for reading hypergrid links from a xml config file. Although its currently still activated by using console command: link-region <URI of xml file> , the uri should be able to be a local file path or a http uri. I'm adding details of the format of the xml file to the wiki's hypergrid page.

TODO: Add a initial startup option for setting the uri and making it autoload it. 
Add support for scanning the xml file to check that its own region(s) aren't in the list, and if they are, ignoring them. This would allow setting up "virtual link/grid lists" on webservers, that people can add their own regions to and also point those regions to those same lists, so they load the other region's data.
Add support for automapping of those region/link lists.
0.6.2-post-fixes
MW 2009-01-15 14:37:04 +00:00
parent 9822f8fc8f
commit 940728dad7
1 changed files with 84 additions and 31 deletions

View File

@ -31,6 +31,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using System.Xml;
using log4net; using log4net;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
@ -144,18 +145,38 @@ namespace OpenSim
// link-region <Xloc> <Yloc> <HostName> <HttpPort> <LocalName> // link-region <Xloc> <Yloc> <HostName> <HttpPort> <LocalName>
if (cmdparams.Length < 4) if (cmdparams.Length < 4)
{ {
LinkRegionCmdUsage(); if (cmdparams.Length == 1)
{
try
{
XmlReader r = XmlReader.Create(cmdparams[0]);
XmlConfigSource cs = new XmlConfigSource(r);
for (int i = 0; i < cs.Configs.Count; i++)
{
ReadLinkFromConfig(cs.Configs[i]);
}
}
catch (Exception)
{
}
}
else
{
LinkRegionCmdUsage();
}
return; return;
} }
RegionInfo regInfo = new RegionInfo(); RegionInfo regInfo;
uint xloc, yloc; uint xloc, yloc;
uint externalPort; uint externalPort;
string externalHostName;
try try
{ {
xloc = Convert.ToUInt32(cmdparams[0]); xloc = Convert.ToUInt32(cmdparams[0]);
yloc = Convert.ToUInt32(cmdparams[1]); yloc = Convert.ToUInt32(cmdparams[1]);
externalPort = Convert.ToUInt32(cmdparams[3]); externalPort = Convert.ToUInt32(cmdparams[3]);
externalHostName = cmdparams[2];
//internalPort = Convert.ToUInt32(cmdparams[4]); //internalPort = Convert.ToUInt32(cmdparams[4]);
//remotingPort = Convert.ToUInt32(cmdparams[5]); //remotingPort = Convert.ToUInt32(cmdparams[5]);
} }
@ -165,44 +186,76 @@ namespace OpenSim
LinkRegionCmdUsage(); LinkRegionCmdUsage();
return; return;
} }
regInfo.RegionLocX = xloc;
regInfo.RegionLocY = yloc;
regInfo.ExternalHostName = cmdparams[2];
regInfo.HttpPort = externalPort;
//regInfo.RemotingPort = remotingPort;
try
{
regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
}
catch (Exception e)
{
m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
LinkRegionCmdUsage();
return;
}
regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString();
// Finally, link it if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo))
try
{ {
m_sceneManager.CurrentOrFirstScene.CommsManager.GridService.RegisterRegion(regInfo); if (cmdparams.Length >= 5)
} {
catch (Exception e) regInfo.RegionName = "";
{ for (int i = 4; i < cmdparams.Length; i++)
m_log.Warn("[HGrid] Unable to link region: " + e.StackTrace); regInfo.RegionName += cmdparams[i] + " ";
} }
if (cmdparams.Length >= 5)
{
regInfo.RegionName = "";
for (int i = 4; i < cmdparams.Length; i++)
regInfo.RegionName += cmdparams[i] + " ";
} }
return;
} }
base.RunCmd(command, cmdparams); base.RunCmd(command, cmdparams);
} }
private void ReadLinkFromConfig(IConfig config)
{
RegionInfo regInfo;
uint xloc, yloc;
uint externalPort;
string externalHostName;
xloc = Convert.ToUInt32(config.GetString("xloc", "0"));
yloc = Convert.ToUInt32(config.GetString("yloc", "0"));
externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
externalHostName = config.GetString("externalHostName", "");
if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo))
{
regInfo.RegionName = config.GetString("localName", "");
}
}
private bool TryCreateLink(uint xloc, uint yloc, uint externalPort, string externalHostName, out RegionInfo regInfo)
{
regInfo = new RegionInfo();
regInfo.RegionLocX = xloc;
regInfo.RegionLocY = yloc;
regInfo.ExternalHostName = externalHostName;
regInfo.HttpPort = externalPort;
//regInfo.RemotingPort = remotingPort;
try
{
regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
}
catch (Exception e)
{
m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
LinkRegionCmdUsage();
return false;
}
regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString();
// Finally, link it
try
{
m_sceneManager.CurrentOrFirstScene.CommsManager.GridService.RegisterRegion(regInfo);
}
catch (Exception e)
{
m_log.Warn("[HGrid] Unable to link region: " + e.StackTrace);
return false;
}
return true;
}
private void LinkRegionCmdUsage() private void LinkRegionCmdUsage()
{ {
Console.WriteLine("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]"); Console.WriteLine("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]");