Merge branch 'grid-service-redux'

0.6.8-post-fixes
Melanie 2009-09-28 23:03:47 +01:00
commit 0709149313
79 changed files with 1405 additions and 4192 deletions

View File

@ -69,7 +69,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
protected CommunicationsManager m_commsManager; protected CommunicationsManager m_commsManager;
protected GridInfoService m_gridInfoService; protected GridInfoService m_gridInfoService;
protected IHyperlink HGServices = null;
protected IRegionCreator m_regionCreator; protected IRegionCreator m_regionCreator;
@ -144,7 +143,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
// We are in grid mode // We are in grid mode
InitialiseHGGridServices(libraryRootFolder); InitialiseHGGridServices(libraryRootFolder);
} }
HGCommands.HGServices = HGServices;
} }
protected void InitialiseStandardServices(LibraryRootFolder libraryRootFolder) protected void InitialiseStandardServices(LibraryRootFolder libraryRootFolder)
@ -188,18 +186,11 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
protected virtual void InitialiseHGStandaloneServices(LibraryRootFolder libraryRootFolder) protected virtual void InitialiseHGStandaloneServices(LibraryRootFolder libraryRootFolder)
{ {
HGGridServicesStandalone gridService
= new HGGridServicesStandalone(
m_openSim.NetServersInfo, m_httpServer, m_openSim.SceneManager);
m_commsManager m_commsManager
= new HGCommunicationsStandalone( = new HGCommunicationsStandalone(
m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer, m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer,
gridService,
libraryRootFolder, false); libraryRootFolder, false);
HGServices = gridService;
CreateGridInfoService(); CreateGridInfoService();
} }
@ -210,8 +201,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
m_openSim.NetServersInfo, m_openSim.NetServersInfo,
m_openSim.SceneManager, libraryRootFolder); m_openSim.SceneManager, libraryRootFolder);
HGServices = ((HGCommunicationsGridMode) m_commsManager).HGServices;
m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler()); m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler());
m_httpServer.AddStreamHandler(new OpenSim.XSimStatusHandler(m_openSim)); m_httpServer.AddStreamHandler(new OpenSim.XSimStatusHandler(m_openSim));
if (m_openSim.userStatsURI != String.Empty) if (m_openSim.userStatsURI != String.Empty)

View File

@ -35,6 +35,8 @@ using System.Text;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using log4net; using log4net;
namespace OpenSim.Framework.Communications.Clients namespace OpenSim.Framework.Communications.Clients
@ -43,7 +45,7 @@ namespace OpenSim.Framework.Communications.Clients
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit, string authKey, out string reason) public bool DoCreateChildAgentCall(GridRegion region, AgentCircuitData aCircuit, string authKey, out string reason)
{ {
reason = String.Empty; reason = String.Empty;
@ -166,7 +168,7 @@ namespace OpenSim.Framework.Communications.Clients
} }
public bool DoChildAgentUpdateCall(RegionInfo region, IAgentData cAgentData) public bool DoChildAgentUpdateCall(GridRegion region, IAgentData cAgentData)
{ {
// Eventually, we want to use a caps url instead of the agentID // Eventually, we want to use a caps url instead of the agentID
string uri = string.Empty; string uri = string.Empty;
@ -260,7 +262,7 @@ namespace OpenSim.Framework.Communications.Clients
return true; return true;
} }
public bool DoRetrieveRootAgentCall(RegionInfo region, UUID id, out IAgentData agent) public bool DoRetrieveRootAgentCall(GridRegion region, UUID id, out IAgentData agent)
{ {
agent = null; agent = null;
// Eventually, we want to use a caps url instead of the agentID // Eventually, we want to use a caps url instead of the agentID
@ -348,7 +350,7 @@ namespace OpenSim.Framework.Communications.Clients
} }
public bool DoCloseAgentCall(RegionInfo region, UUID id) public bool DoCloseAgentCall(GridRegion region, UUID id)
{ {
string uri = string.Empty; string uri = string.Empty;
try try
@ -391,7 +393,7 @@ namespace OpenSim.Framework.Communications.Clients
return true; return true;
} }
public bool DoCreateObjectCall(RegionInfo region, ISceneObject sog, string sogXml2, bool allowScriptCrossing) public bool DoCreateObjectCall(GridRegion region, ISceneObject sog, string sogXml2, bool allowScriptCrossing)
{ {
ulong regionHandle = GetRegionHandle(region.RegionHandle); ulong regionHandle = GetRegionHandle(region.RegionHandle);
string uri string uri
@ -474,7 +476,7 @@ namespace OpenSim.Framework.Communications.Clients
} }
public bool DoCreateObjectCall(RegionInfo region, UUID userID, UUID itemID) public bool DoCreateObjectCall(GridRegion region, UUID userID, UUID itemID)
{ {
ulong regionHandle = GetRegionHandle(region.RegionHandle); ulong regionHandle = GetRegionHandle(region.RegionHandle);
string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/"; string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/";
@ -646,7 +648,7 @@ namespace OpenSim.Framework.Communications.Clients
return false; return false;
} }
public virtual void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit) public virtual void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit)
{ {
} }

View File

@ -59,11 +59,6 @@ namespace OpenSim.Framework.Communications
} }
protected IMessagingService m_messageService; protected IMessagingService m_messageService;
public IGridServices GridService
{
get { return m_gridService; }
}
protected IGridServices m_gridService;
public UserProfileCacheService UserProfileCacheService public UserProfileCacheService UserProfileCacheService
{ {

View File

@ -1,92 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
using OpenMetaverse;
namespace OpenSim.Framework.Communications
{
public interface IGridServices
{
string gdebugRegionName { get; set; }
/// <summary>
/// If true, then regions will accept logins from the user service. If false, then they will not.
/// </summary>
bool RegionLoginsEnabled { get; set; }
/// <summary>
/// Register a region with the grid service.
/// </summary>
/// <param name="regionInfos"> </param>
/// <returns></returns>
/// <exception cref="System.Exception">Thrown if region registration failed</exception>
RegionCommsListener RegisterRegion(RegionInfo regionInfos);
/// <summary>
/// Deregister a region with the grid service.
/// </summary>
/// <param name="regionInfo"></param>
/// <returns></returns>
/// <exception cref="System.Exception">Thrown if region deregistration failed</exception>
bool DeregisterRegion(RegionInfo regionInfo);
/// <summary>
/// Get information about the regions neighbouring the given co-ordinates.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
List<SimpleRegionInfo> RequestNeighbours(uint x, uint y);
RegionInfo RequestNeighbourInfo(ulong regionHandle);
RegionInfo RequestNeighbourInfo(UUID regionID);
RegionInfo RequestNeighbourInfo(string name);
RegionInfo RequestNeighbourInfo(string host, uint port);
RegionInfo RequestClosestRegion(string regionName);
Dictionary<string, string> GetGridSettings();
List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY);
// not complete yet, only contains the fields needed for ParcelInfoReqeust
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);
}
}

View File

@ -46,8 +46,6 @@ namespace OpenSim.Framework
public delegate bool CloseAgentConnection(UUID agentID); public delegate bool CloseAgentConnection(UUID agentID);
public delegate bool RegionUp(RegionInfo region);
public delegate bool ChildAgentUpdate(ChildAgentDataUpdate cAgentData); public delegate bool ChildAgentUpdate(ChildAgentDataUpdate cAgentData);
public delegate void LogOffUser(UUID agentID, UUID regionSecret, string message); public delegate void LogOffUser(UUID agentID, UUID regionSecret, string message);
@ -65,7 +63,6 @@ namespace OpenSim.Framework
event AcknowledgePrimCross OnAcknowledgePrimCrossed; event AcknowledgePrimCross OnAcknowledgePrimCrossed;
event UpdateNeighbours OnNeighboursUpdate; event UpdateNeighbours OnNeighboursUpdate;
event CloseAgentConnection OnCloseAgentConnection; event CloseAgentConnection OnCloseAgentConnection;
event RegionUp OnRegionUp;
event ChildAgentUpdate OnChildAgentUpdate; event ChildAgentUpdate OnChildAgentUpdate;
event LogOffUser OnLogOffUser; event LogOffUser OnLogOffUser;
event GetLandData OnGetLandData; event GetLandData OnGetLandData;

View File

@ -74,7 +74,7 @@ namespace OpenSim.Framework
void CloseAllAgents(uint circuitcode); void CloseAllAgents(uint circuitcode);
void Restart(int seconds); void Restart(int seconds);
bool OtherRegionUp(RegionInfo thisRegion); //RegionInfo OtherRegionUp(RegionInfo thisRegion);
string GetSimulatorVersion(); string GetSimulatorVersion();

View File

@ -102,8 +102,7 @@ namespace OpenSim.Framework
ConfigSettings.DefaultInventoryServerHttpPort.ToString()); ConfigSettings.DefaultInventoryServerHttpPort.ToString());
secureInventoryServer = config.Configs["Network"].GetBoolean("secure_inventory_server", true); secureInventoryServer = config.Configs["Network"].GetBoolean("secure_inventory_server", true);
MessagingURL = config.Configs["Network"].GetString("messaging_server_url", MessagingURL = config.Configs["Network"].GetString("messaging_server_url", string.Empty);
"http://127.0.0.1:" + ConfigSettings.DefaultMessageServerHttpPort);
} }
} }
} }

View File

@ -47,7 +47,6 @@ namespace OpenSim.Framework
private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser
private UpdateNeighbours handlerNeighboursUpdate = null; // OnNeighboursUpdate; private UpdateNeighbours handlerNeighboursUpdate = null; // OnNeighboursUpdate;
private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
private RegionUp handlerRegionUp = null; // OnRegionUp;
private LogOffUser handlerLogOffUser = null; private LogOffUser handlerLogOffUser = null;
private GetLandData handlerGetLandData = null; private GetLandData handlerGetLandData = null;
@ -62,7 +61,6 @@ namespace OpenSim.Framework
public event AcknowledgeAgentCross OnAcknowledgeAgentCrossed; public event AcknowledgeAgentCross OnAcknowledgeAgentCrossed;
public event AcknowledgePrimCross OnAcknowledgePrimCrossed; public event AcknowledgePrimCross OnAcknowledgePrimCrossed;
public event CloseAgentConnection OnCloseAgentConnection; public event CloseAgentConnection OnCloseAgentConnection;
public event RegionUp OnRegionUp;
public event ChildAgentUpdate OnChildAgentUpdate; public event ChildAgentUpdate OnChildAgentUpdate;
public event LogOffUser OnLogOffUser; public event LogOffUser OnLogOffUser;
public event GetLandData OnGetLandData; public event GetLandData OnGetLandData;
@ -108,17 +106,6 @@ namespace OpenSim.Framework
return false; return false;
} }
public virtual bool TriggerRegionUp(RegionInfo region)
{
handlerRegionUp = OnRegionUp;
if (handlerRegionUp != null)
{
handlerRegionUp(region);
return true;
}
return false;
}
public virtual bool TriggerChildAgentUpdate(ChildAgentDataUpdate cAgentData) public virtual bool TriggerChildAgentUpdate(ChildAgentDataUpdate cAgentData)
{ {
handlerChildAgentUpdate = OnChildAgentUpdate; handlerChildAgentUpdate = OnChildAgentUpdate;

View File

@ -59,11 +59,11 @@ namespace OpenSim.Framework.Servers.HttpServer
int length = 0; int length = 0;
using (StreamWriter writer = new StreamWriter(buffer)) using (StreamWriter writer = new StreamWriter(buffer))
{ {
writer.WriteLine(obj); writer.Write(obj);
writer.Flush(); writer.Flush();
length = (int)buffer.Length;
} }
length = (int)obj.Length;
request.ContentLength = length; request.ContentLength = length;
Stream requestStream = request.GetRequestStream(); Stream requestStream = request.GetRequestStream();

View File

@ -1203,6 +1203,32 @@ namespace OpenSim.Framework
return found.ToArray(); return found.ToArray();
} }
public static string ServerURI(string uri)
{
if (uri == string.Empty)
return string.Empty;
// Get rid of eventual slashes at the end
uri = uri.TrimEnd('/');
IPAddress ipaddr1 = null;
string port1 = "";
try
{
ipaddr1 = Util.GetHostFromURL(uri);
}
catch { }
try
{
port1 = uri.Split(new char[] { ':' })[2];
}
catch { }
// We tried our best to convert the domain names to IP addresses
return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri;
}
#region FireAndForget Threading Pattern #region FireAndForget Threading Pattern
public static void FireAndForget(System.Threading.WaitCallback callback) public static void FireAndForget(System.Threading.WaitCallback callback)

View File

@ -34,6 +34,7 @@ using System.Text.RegularExpressions;
using log4net; using log4net;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenMetaverse; using OpenMetaverse;
using Nini.Config;
using OpenSim.Data; using OpenSim.Data;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
@ -42,6 +43,9 @@ using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Capabilities; using OpenSim.Framework.Capabilities;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using OpenSim.Services.Connectors;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Grid.UserServer.Modules namespace OpenSim.Grid.UserServer.Modules
{ {
@ -63,6 +67,8 @@ namespace OpenSim.Grid.UserServer.Modules
public UserConfig m_config; public UserConfig m_config;
private readonly IRegionProfileRouter m_regionProfileService; private readonly IRegionProfileRouter m_regionProfileService;
private IGridService m_GridService;
protected BaseHttpServer m_httpServer; protected BaseHttpServer m_httpServer;
public UserLoginService( public UserLoginService(
@ -76,6 +82,8 @@ namespace OpenSim.Grid.UserServer.Modules
m_defaultHomeY = m_config.DefaultY; m_defaultHomeY = m_config.DefaultY;
m_interInventoryService = inventoryService; m_interInventoryService = inventoryService;
m_regionProfileService = regionProfileService; m_regionProfileService = regionProfileService;
m_GridService = new GridServicesConnector(config.GridServerURL.ToString());
} }
public void RegisterHandlers(BaseHttpServer httpServer, bool registerLLSDHandler, bool registerOpenIDHandlers) public void RegisterHandlers(BaseHttpServer httpServer, bool registerLLSDHandler, bool registerOpenIDHandlers)
@ -203,47 +211,38 @@ namespace OpenSim.Grid.UserServer.Modules
protected override RegionInfo RequestClosestRegion(string region) protected override RegionInfo RequestClosestRegion(string region)
{ {
RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(region, return GridRegionToRegionInfo(m_GridService.GetRegionByName(UUID.Zero, region));
m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey);
if (profileData != null)
{
return profileData.ToRegionInfo();
}
else
{
return null;
}
} }
protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) protected override RegionInfo GetRegionInfo(ulong homeRegionHandle)
{ {
RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionHandle, uint x = 0, y = 0;
m_config.GridServerURL, m_config.GridSendKey, Utils.LongToUInts(homeRegionHandle, out x, out y);
m_config.GridRecvKey); return GridRegionToRegionInfo(m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y));
if (profileData != null)
{
return profileData.ToRegionInfo();
}
else
{
return null;
}
} }
protected override RegionInfo GetRegionInfo(UUID homeRegionId) protected override RegionInfo GetRegionInfo(UUID homeRegionId)
{ {
RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionId, return GridRegionToRegionInfo(m_GridService.GetRegionByUUID(UUID.Zero, homeRegionId));
m_config.GridServerURL, m_config.GridSendKey,
m_config.GridRecvKey);
if (profileData != null)
{
return profileData.ToRegionInfo();
} }
else
private RegionInfo GridRegionToRegionInfo(GridRegion gregion)
{ {
if (gregion == null)
return null; return null;
}
RegionInfo rinfo = new RegionInfo();
rinfo.ExternalHostName = gregion.ExternalHostName;
rinfo.HttpPort = gregion.HttpPort;
rinfo.InternalEndPoint = gregion.InternalEndPoint;
rinfo.RegionID = gregion.RegionID;
rinfo.RegionLocX = (uint)(gregion.RegionLocX / Constants.RegionSize);
rinfo.RegionLocY = (uint)(gregion.RegionLocY / Constants.RegionSize);
rinfo.RegionName = gregion.RegionName;
rinfo.ScopeID = gregion.ScopeID;
rinfo.ServerURI = gregion.ServerURI;
return rinfo;
} }
protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient) protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient)

View File

@ -43,16 +43,11 @@ namespace OpenSim
public class HGCommands public class HGCommands
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static IHyperlink HGServices = null;
private static uint m_autoMappingX = 0;
private static uint m_autoMappingY = 0;
private static bool m_enableAutoMapping = false;
public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager, public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager,
StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version) StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version)
{ {
HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices); HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager);
return return
new HGScene( new HGScene(
@ -61,213 +56,5 @@ namespace OpenSim
m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
} }
public static void RunHGCommand(string command, string[] cmdparams, Scene scene)
{
if (command.Equals("link-mapping"))
{
if (cmdparams.Length == 2)
{
try
{
m_autoMappingX = Convert.ToUInt32(cmdparams[0]);
m_autoMappingY = Convert.ToUInt32(cmdparams[1]);
m_enableAutoMapping = true;
}
catch (Exception)
{
m_autoMappingX = 0;
m_autoMappingY = 0;
m_enableAutoMapping = false;
}
}
}
else if (command.Equals("link-region"))
{
if (cmdparams.Length < 3)
{
if ((cmdparams.Length == 1) || (cmdparams.Length == 2))
{
LoadXmlLinkFile(cmdparams, scene);
}
else
{
LinkRegionCmdUsage();
}
return;
}
if (cmdparams[2].Contains(":"))
{
// New format
uint xloc, yloc;
string mapName;
try
{
xloc = Convert.ToUInt32(cmdparams[0]);
yloc = Convert.ToUInt32(cmdparams[1]);
mapName = cmdparams[2];
if (cmdparams.Length > 3)
for (int i = 3; i < cmdparams.Length; i++)
mapName += " " + cmdparams[i];
m_log.Info(">> MapName: " + mapName);
//internalPort = Convert.ToUInt32(cmdparams[4]);
//remotingPort = Convert.ToUInt32(cmdparams[5]);
}
catch (Exception e)
{
m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
LinkRegionCmdUsage();
return;
}
HGHyperlink.TryLinkRegionToCoords(scene, null, mapName, xloc, yloc);
}
else
{
// old format
RegionInfo regInfo;
uint xloc, yloc;
uint externalPort;
string externalHostName;
try
{
xloc = Convert.ToUInt32(cmdparams[0]);
yloc = Convert.ToUInt32(cmdparams[1]);
externalPort = Convert.ToUInt32(cmdparams[3]);
externalHostName = cmdparams[2];
//internalPort = Convert.ToUInt32(cmdparams[4]);
//remotingPort = Convert.ToUInt32(cmdparams[5]);
}
catch (Exception e)
{
m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
LinkRegionCmdUsage();
return;
}
//if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo))
if (HGHyperlink.TryCreateLink(scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo))
{
if (cmdparams.Length >= 5)
{
regInfo.RegionName = "";
for (int i = 4; i < cmdparams.Length; i++)
regInfo.RegionName += cmdparams[i] + " ";
}
}
}
return;
}
else if (command.Equals("unlink-region"))
{
if (cmdparams.Length < 1)
{
UnlinkRegionCmdUsage();
return;
}
if (HGHyperlink.TryUnlinkRegion(scene, cmdparams[0]))
m_log.InfoFormat("[HGrid]: Successfully unlinked {0}", cmdparams[0]);
else
m_log.InfoFormat("[HGrid]: Unable to unlink {0}, region not found", cmdparams[0]);
}
}
private static void LoadXmlLinkFile(string[] cmdparams, Scene scene)
{
//use http://www.hgurl.com/hypergrid.xml for test
try
{
XmlReader r = XmlReader.Create(cmdparams[0]);
XmlConfigSource cs = new XmlConfigSource(r);
string[] excludeSections = null;
if (cmdparams.Length == 2)
{
if (cmdparams[1].ToLower().StartsWith("excludelist:"))
{
string excludeString = cmdparams[1].ToLower();
excludeString = excludeString.Remove(0, 12);
char[] splitter = {';'};
excludeSections = excludeString.Split(splitter);
}
}
for (int i = 0; i < cs.Configs.Count; i++)
{
bool skip = false;
if ((excludeSections != null) && (excludeSections.Length > 0))
{
for (int n = 0; n < excludeSections.Length; n++)
{
if (excludeSections[n] == cs.Configs[i].Name.ToLower())
{
skip = true;
break;
}
}
}
if (!skip)
{
ReadLinkFromConfig(cs.Configs[i], scene);
}
}
}
catch (Exception e)
{
m_log.Error(e.ToString());
}
}
private static void ReadLinkFromConfig(IConfig config, Scene scene)
{
RegionInfo regInfo;
uint xloc, yloc;
uint externalPort;
string externalHostName;
uint realXLoc, realYLoc;
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", "");
realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0"));
realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0"));
if (m_enableAutoMapping)
{
xloc = (uint) ((xloc%100) + m_autoMappingX);
yloc = (uint) ((yloc%100) + m_autoMappingY);
}
if (((realXLoc == 0) && (realYLoc == 0)) ||
(((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) &&
((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896))))
{
if (
HGHyperlink.TryCreateLink(scene, null, xloc, yloc, "", externalPort,
externalHostName, out regInfo))
{
regInfo.RegionName = config.GetString("localName", "");
}
}
}
private static void LinkRegionCmdUsage()
{
m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]");
m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]");
m_log.Info("Usage: link-region <URI_of_xml> [<exclude>]");
}
private static void UnlinkRegionCmdUsage()
{
m_log.Info("Usage: unlink-region <HostName>:<HttpPort>");
m_log.Info("Usage: unlink-region <LocalName>");
}
} }
} }

View File

@ -755,11 +755,6 @@ namespace OpenSim
} }
break; break;
case "link-region":
case "unlink-region":
case "link-mapping":
HGCommands.RunHGCommand(command, cmdparams, m_sceneManager.CurrentOrFirstScene);
break;
} }
} }

View File

@ -399,7 +399,7 @@ namespace OpenSim
} }
catch (Exception e) catch (Exception e)
{ {
m_log.ErrorFormat("[STARTUP]: Registration of region with grid failed, aborting startup - {0}", e); m_log.ErrorFormat("[STARTUP]: Registration of region with grid failed, aborting startup - {0}", e.StackTrace);
// Carrying on now causes a lot of confusion down the // Carrying on now causes a lot of confusion down the
// line - we need to get the user's attention // line - we need to get the user's attention

View File

@ -28,6 +28,7 @@
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.ClientStack.LindenUDP.Tests namespace OpenSim.Region.ClientStack.LindenUDP.Tests
{ {
@ -58,7 +59,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
public override void RemoveClient(UUID agentID) {} public override void RemoveClient(UUID agentID) {}
public override void CloseAllAgents(uint circuitcode) {} public override void CloseAllAgents(uint circuitcode) {}
public override bool OtherRegionUp(RegionInfo thisRegion) { return false; } public override void OtherRegionUp(GridRegion otherRegion) { }
/// <summary> /// <summary>
/// Doesn't really matter what the call is - we're using this to test that a packet has actually been received /// Doesn't really matter what the call is - we're using this to test that a packet has actually been received

View File

@ -40,21 +40,12 @@ namespace OpenSim.Region.Communications.Hypergrid
{ {
public class HGCommunicationsGridMode : CommunicationsManager // CommunicationsOGS1 public class HGCommunicationsGridMode : CommunicationsManager // CommunicationsOGS1
{ {
IHyperlink m_osw = null;
public IHyperlink HGServices
{
get { return m_osw; }
}
public HGCommunicationsGridMode( public HGCommunicationsGridMode(
NetworkServersInfo serversInfo, NetworkServersInfo serversInfo,
SceneManager sman, LibraryRootFolder libraryRootFolder) SceneManager sman, LibraryRootFolder libraryRootFolder)
: base(serversInfo, libraryRootFolder) : base(serversInfo, libraryRootFolder)
{ {
// From constructor at CommunicationsOGS1
HGGridServices gridInterComms = new HGGridServicesGridMode(serversInfo, sman, m_userProfileCacheService);
m_gridService = gridInterComms;
m_osw = gridInterComms;
HGUserServices userServices = new HGUserServices(this); HGUserServices userServices = new HGUserServices(this);
// This plugin arrangement could eventually be configurable rather than hardcoded here. // This plugin arrangement could eventually be configurable rather than hardcoded here.

View File

@ -44,7 +44,6 @@ namespace OpenSim.Region.Communications.Hypergrid
ConfigSettings configSettings, ConfigSettings configSettings,
NetworkServersInfo serversInfo, NetworkServersInfo serversInfo,
BaseHttpServer httpServer, BaseHttpServer httpServer,
HGGridServices gridService,
LibraryRootFolder libraryRootFolder, LibraryRootFolder libraryRootFolder,
bool dumpAssetsToFile) bool dumpAssetsToFile)
: base(serversInfo, libraryRootFolder) : base(serversInfo, libraryRootFolder)
@ -64,8 +63,6 @@ namespace OpenSim.Region.Communications.Hypergrid
m_avatarService = hgUserService; m_avatarService = hgUserService;
m_messageService = hgUserService; m_messageService = hgUserService;
gridService.UserProfileCache = m_userProfileCacheService;
m_gridService = gridService;
} }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,159 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Communications.OGS1;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.Communications.Hypergrid
{
public class HGGridServicesGridMode : HGGridServices
{
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Encapsulate remote backend services for manipulation of grid regions
/// </summary>
private OGS1GridServices m_remoteBackend = null;
public OGS1GridServices RemoteBackend
{
get { return m_remoteBackend; }
}
public override string gdebugRegionName
{
get { return m_remoteBackend.gdebugRegionName; }
set { m_remoteBackend.gdebugRegionName = value; }
}
public override bool RegionLoginsEnabled
{
get { return m_remoteBackend.RegionLoginsEnabled; }
set { m_remoteBackend.RegionLoginsEnabled = value; }
}
public HGGridServicesGridMode(NetworkServersInfo servers_info,
SceneManager sman, UserProfileCacheService userv)
: base(servers_info, sman)
{
m_remoteBackend = new OGS1GridServices(servers_info);
m_userProfileCache = userv;
}
#region IGridServices interface
public override RegionCommsListener RegisterRegion(RegionInfo regionInfo)
{
if (!regionInfo.RegionID.Equals(UUID.Zero))
{
m_regionsOnInstance.Add(regionInfo);
return m_remoteBackend.RegisterRegion(regionInfo);
}
else
return base.RegisterRegion(regionInfo);
}
public override bool DeregisterRegion(RegionInfo regionInfo)
{
bool success = base.DeregisterRegion(regionInfo);
if (!success)
success = m_remoteBackend.DeregisterRegion(regionInfo);
return success;
}
public override List<SimpleRegionInfo> RequestNeighbours(uint x, uint y)
{
List<SimpleRegionInfo> neighbours = m_remoteBackend.RequestNeighbours(x, y);
//List<SimpleRegionInfo> remotes = base.RequestNeighbours(x, y);
//neighbours.AddRange(remotes);
return neighbours;
}
public override RegionInfo RequestNeighbourInfo(UUID Region_UUID)
{
RegionInfo info = m_remoteBackend.RequestNeighbourInfo(Region_UUID);
if (info == null)
info = base.RequestNeighbourInfo(Region_UUID);
return info;
}
public override RegionInfo RequestNeighbourInfo(ulong regionHandle)
{
RegionInfo info = base.RequestNeighbourInfo(regionHandle);
if (info == null)
info = m_remoteBackend.RequestNeighbourInfo(regionHandle);
return info;
}
public override RegionInfo RequestClosestRegion(string regionName)
{
RegionInfo info = m_remoteBackend.RequestClosestRegion(regionName);
if (info == null)
info = base.RequestClosestRegion(regionName);
return info;
}
public override List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
{
List<MapBlockData> neighbours = m_remoteBackend.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
List<MapBlockData> remotes = base.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
neighbours.AddRange(remotes);
return neighbours;
}
public override LandData RequestLandData(ulong regionHandle, uint x, uint y)
{
LandData land = m_remoteBackend.RequestLandData(regionHandle, x, y);
if (land == null)
land = base.RequestLandData(regionHandle, x, y);
return land;
}
public override List<RegionInfo> RequestNamedRegions(string name, int maxNumber)
{
List<RegionInfo> infos = m_remoteBackend.RequestNamedRegions(name, maxNumber);
List<RegionInfo> remotes = base.RequestNamedRegions(name, maxNumber);
infos.AddRange(remotes);
return infos;
}
#endregion
}
}

View File

@ -1,259 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Security.Authentication;
using log4net;
using Nwc.XmlRpc;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Communications.Local;
using OpenSim.Region.Communications.OGS1;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.Communications.Hypergrid
{
public class HGGridServicesStandalone : HGGridServices
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Encapsulate local backend services for manipulation of local regions
/// </summary>
protected LocalBackEndServices m_localBackend = new LocalBackEndServices();
//private Dictionary<ulong, int> m_deadRegionCache = new Dictionary<ulong, int>();
public LocalBackEndServices LocalBackend
{
get { return m_localBackend; }
}
public override string gdebugRegionName
{
get { return m_localBackend.gdebugRegionName; }
set { m_localBackend.gdebugRegionName = value; }
}
public override bool RegionLoginsEnabled
{
get { return m_localBackend.RegionLoginsEnabled; }
set { m_localBackend.RegionLoginsEnabled = value; }
}
public HGGridServicesStandalone(NetworkServersInfo servers_info, BaseHttpServer httpServe, SceneManager sman)
: base(servers_info, sman)
{
//Respond to Grid Services requests
MainServer.Instance.AddXmlRPCHandler("logoff_user", LogOffUser);
MainServer.Instance.AddXmlRPCHandler("check", PingCheckReply);
MainServer.Instance.AddXmlRPCHandler("land_data", LandData);
}
#region IGridServices interface
public override RegionCommsListener RegisterRegion(RegionInfo regionInfo)
{
if (!regionInfo.RegionID.Equals(UUID.Zero))
{
m_regionsOnInstance.Add(regionInfo);
return m_localBackend.RegisterRegion(regionInfo);
}
else
return base.RegisterRegion(regionInfo);
}
public override bool DeregisterRegion(RegionInfo regionInfo)
{
bool success = m_localBackend.DeregisterRegion(regionInfo);
if (!success)
success = base.DeregisterRegion(regionInfo);
return success;
}
public override List<SimpleRegionInfo> RequestNeighbours(uint x, uint y)
{
List<SimpleRegionInfo> neighbours = m_localBackend.RequestNeighbours(x, y);
//List<SimpleRegionInfo> remotes = base.RequestNeighbours(x, y);
//neighbours.AddRange(remotes);
return neighbours;
}
public override RegionInfo RequestNeighbourInfo(UUID Region_UUID)
{
RegionInfo info = m_localBackend.RequestNeighbourInfo(Region_UUID);
if (info == null)
info = base.RequestNeighbourInfo(Region_UUID);
return info;
}
public override RegionInfo RequestNeighbourInfo(ulong regionHandle)
{
RegionInfo info = m_localBackend.RequestNeighbourInfo(regionHandle);
//m_log.Info("[HGrid] Request neighbor info, local backend returned " + info);
if (info == null)
info = base.RequestNeighbourInfo(regionHandle);
return info;
}
public override RegionInfo RequestClosestRegion(string regionName)
{
RegionInfo info = m_localBackend.RequestClosestRegion(regionName);
if (info == null)
info = base.RequestClosestRegion(regionName);
return info;
}
public override List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
{
//m_log.Info("[HGrid] Request map blocks " + minX + "-" + minY + "-" + maxX + "-" + maxY);
List<MapBlockData> neighbours = m_localBackend.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
List<MapBlockData> remotes = base.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
neighbours.AddRange(remotes);
return neighbours;
}
public override LandData RequestLandData(ulong regionHandle, uint x, uint y)
{
LandData land = m_localBackend.RequestLandData(regionHandle, x, y);
if (land == null)
land = base.RequestLandData(regionHandle, x, y);
return land;
}
public override List<RegionInfo> RequestNamedRegions(string name, int maxNumber)
{
List<RegionInfo> infos = m_localBackend.RequestNamedRegions(name, maxNumber);
List<RegionInfo> remotes = base.RequestNamedRegions(name, maxNumber);
infos.AddRange(remotes);
return infos;
}
#endregion
#region XML Request Handlers
/// <summary>
/// A ping / version check
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual XmlRpcResponse PingCheckReply(XmlRpcRequest request, IPEndPoint remoteClient)
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable respData = new Hashtable();
respData["online"] = "true";
m_localBackend.PingCheckReply(respData);
response.Value = respData;
return response;
}
// Grid Request Processing
/// <summary>
/// Ooops, our Agent must be dead if we're getting this request!
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse LogOffUser(XmlRpcRequest request, IPEndPoint remoteClient)
{
m_log.Debug("[HGrid]: LogOff User Called");
Hashtable requestData = (Hashtable)request.Params[0];
string message = (string)requestData["message"];
UUID agentID = UUID.Zero;
UUID RegionSecret = UUID.Zero;
UUID.TryParse((string)requestData["agent_id"], out agentID);
UUID.TryParse((string)requestData["region_secret"], out RegionSecret);
ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
m_localBackend.TriggerLogOffUser(regionHandle, agentID, RegionSecret, message);
return new XmlRpcResponse();
}
/// <summary>
/// Someone asked us about parcel-information
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse LandData(XmlRpcRequest request, IPEndPoint remoteClient)
{
Hashtable requestData = (Hashtable)request.Params[0];
ulong regionHandle = Convert.ToUInt64(requestData["region_handle"]);
uint x = Convert.ToUInt32(requestData["x"]);
uint y = Convert.ToUInt32(requestData["y"]);
m_log.DebugFormat("[HGrid]: Got XML reqeuest for land data at {0}, {1} in region {2}", x, y, regionHandle);
LandData landData = m_localBackend.RequestLandData(regionHandle, x, y);
Hashtable hash = new Hashtable();
if (landData != null)
{
// for now, only push out the data we need for answering a ParcelInfoReqeust
hash["AABBMax"] = landData.AABBMax.ToString();
hash["AABBMin"] = landData.AABBMin.ToString();
hash["Area"] = landData.Area.ToString();
hash["AuctionID"] = landData.AuctionID.ToString();
hash["Description"] = landData.Description;
hash["Flags"] = landData.Flags.ToString();
hash["GlobalID"] = landData.GlobalID.ToString();
hash["Name"] = landData.Name;
hash["OwnerID"] = landData.OwnerID.ToString();
hash["SalePrice"] = landData.SalePrice.ToString();
hash["SnapshotID"] = landData.SnapshotID.ToString();
hash["UserLocation"] = landData.UserLocation.ToString();
}
XmlRpcResponse response = new XmlRpcResponse();
response.Value = hash;
return response;
}
#endregion
}
}

View File

@ -53,8 +53,6 @@ namespace OpenSim.Region.Communications.Local
m_avatarService = lus; m_avatarService = lus;
m_messageService = lus; m_messageService = lus;
m_gridService = new LocalBackEndServices();
//LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, backendService); //LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, backendService);
} }
} }

View File

@ -1,410 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
namespace OpenSim.Region.Communications.Local
{
public class LocalBackEndServices : IGridServices
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected Dictionary<ulong, RegionInfo> m_regions = new Dictionary<ulong, RegionInfo>();
protected Dictionary<ulong, RegionCommsListener> m_regionListeners =
new Dictionary<ulong, RegionCommsListener>();
// private Dictionary<ulong, RegionInfo> m_remoteRegionInfoCache = new Dictionary<ulong, RegionInfo>();
private Dictionary<string, string> m_queuedGridSettings = new Dictionary<string, string>();
public string _gdebugRegionName = String.Empty;
public bool RegionLoginsEnabled
{
get { return m_regionLoginsEnabled; }
set { m_regionLoginsEnabled = value; }
}
private bool m_regionLoginsEnabled;
public bool CheckRegion(string address, uint port)
{
return true;
}
public string gdebugRegionName
{
get { return _gdebugRegionName; }
set { _gdebugRegionName = value; }
}
public string _rdebugRegionName = String.Empty;
public string rdebugRegionName
{
get { return _rdebugRegionName; }
set { _rdebugRegionName = value; }
}
/// <summary>
/// Register a region method with the BackEnd Services.
/// </summary>
/// <param name="regionInfo"></param>
/// <returns></returns>
public RegionCommsListener RegisterRegion(RegionInfo regionInfo)
{
//m_log.Debug("CommsManager - Region " + regionInfo.RegionHandle + " , " + regionInfo.RegionLocX + " , "+ regionInfo.RegionLocY +" is registering");
if (!m_regions.ContainsKey(regionInfo.RegionHandle))
{
//m_log.Debug("CommsManager - Adding Region " + regionInfo.RegionHandle);
m_regions.Add(regionInfo.RegionHandle, regionInfo);
RegionCommsListener regionHost = new RegionCommsListener();
if (m_regionListeners.ContainsKey(regionInfo.RegionHandle))
{
m_log.Error("[INTERREGION STANDALONE]: " +
"Error:Region registered twice as an Events listener for Interregion Communications but not as a listed region. " +
"In Standalone mode this will cause BIG issues. In grid mode, it means a region went down and came back up.");
m_regionListeners.Remove(regionInfo.RegionHandle);
}
m_regionListeners.Add(regionInfo.RegionHandle, regionHost);
return regionHost;
}
else
{
// Already in our list, so the region went dead and restarted.
// don't replace the old regioninfo.. this might be a locking issue.. however we need to
// remove it and let it add normally below or we get extremely strange and intermittant
// connectivity errors.
// Don't change this line below to 'm_regions[regionInfo.RegionHandle] = regionInfo' unless you
// *REALLY* know what you are doing here.
m_regions[regionInfo.RegionHandle] = regionInfo;
m_log.Warn("[INTERREGION STANDALONE]: Region registered twice. Region went down and came back up.");
RegionCommsListener regionHost = new RegionCommsListener();
if (m_regionListeners.ContainsKey(regionInfo.RegionHandle))
{
m_regionListeners.Remove(regionInfo.RegionHandle);
}
m_regionListeners.Add(regionInfo.RegionHandle, regionHost);
return regionHost;
}
}
public bool DeregisterRegion(RegionInfo regionInfo)
{
if (m_regions.ContainsKey(regionInfo.RegionHandle))
{
m_regions.Remove(regionInfo.RegionHandle);
if (m_regionListeners.ContainsKey(regionInfo.RegionHandle))
{
m_regionListeners.Remove(regionInfo.RegionHandle);
}
return true;
}
return false;
}
/// <summary>
/// </summary>
/// <param name="regionInfo"></param>
/// <returns></returns>
public List<SimpleRegionInfo> RequestNeighbours(uint x, uint y)
{
// m_log.Debug("Finding Neighbours to " + regionInfo.RegionHandle);
List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
foreach (RegionInfo reg in m_regions.Values)
{
// m_log.Debug("CommsManager- RequestNeighbours() checking region " + reg.RegionLocX + " , "+ reg.RegionLocY);
if (reg.RegionLocX != x || reg.RegionLocY != y)
{
//m_log.Debug("CommsManager- RequestNeighbours() - found a different region in list, checking location");
if ((reg.RegionLocX > (x - 2)) && (reg.RegionLocX < (x + 2)))
{
if ((reg.RegionLocY > (y - 2)) && (reg.RegionLocY < (y + 2)))
{
neighbours.Add(reg);
}
}
}
}
return neighbours;
}
/// <summary>
/// Get information about a neighbouring region
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbourInfo(ulong regionHandle)
{
if (m_regions.ContainsKey(regionHandle))
{
return m_regions[regionHandle];
}
return null;
}
/// <summary>
/// Get information about a neighbouring region
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbourInfo(UUID regionID)
{
// TODO add a dictionary for faster lookup
foreach (RegionInfo info in m_regions.Values)
{
if (info.RegionID == regionID)
return info;
}
return null;
}
/// <summary>
/// Get information about a neighbouring region
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbourInfo(string name)
{
foreach (RegionInfo info in m_regions.Values)
{
if (info.RegionName == name)
return info;
}
return null;
}
/// <summary>
/// Get information about a neighbouring region
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbourInfo(string host, uint port)
{
foreach (RegionInfo info in m_regions.Values)
{
if ((info.ExternalHostName == host) && (info.HttpPort == port))
return info;
}
return null;
}
/// <summary>
/// Get information about the closet region given a region name.
/// </summary>
/// <param name="regionName"></param>
/// <returns></returns>
public RegionInfo RequestClosestRegion(string regionName)
{
foreach (RegionInfo regInfo in m_regions.Values)
{
if (regInfo.RegionName == regionName)
return regInfo;
}
return null;
}
/// <summary>
///
/// </summary>
/// <param name="minX"></param>
/// <param name="minY"></param>
/// <param name="maxX"></param>
/// <param name="maxY"></param>
/// <returns></returns>
public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
{
List<MapBlockData> mapBlocks = new List<MapBlockData>();
foreach (RegionInfo regInfo in m_regions.Values)
{
if (((regInfo.RegionLocX >= minX) && (regInfo.RegionLocX <= maxX)) &&
((regInfo.RegionLocY >= minY) && (regInfo.RegionLocY <= maxY)))
{
MapBlockData map = new MapBlockData();
map.Name = regInfo.RegionName;
map.X = (ushort) regInfo.RegionLocX;
map.Y = (ushort) regInfo.RegionLocY;
map.WaterHeight = (byte) regInfo.RegionSettings.WaterHeight;
map.MapImageId = regInfo.RegionSettings.TerrainImageID;
map.Agents = 1;
map.RegionFlags = 72458694;
map.Access = regInfo.AccessLevel;
mapBlocks.Add(map);
}
}
return mapBlocks;
}
// This function is only here to keep this class in line with the Grid Interface.
// It never gets called.
public virtual Dictionary<string, string> GetGridSettings()
{
Dictionary<string, string> returnGridSettings = new Dictionary<string, string>();
lock (m_queuedGridSettings)
{
returnGridSettings = m_queuedGridSettings;
m_queuedGridSettings.Clear();
}
return returnGridSettings;
}
public virtual void SetForcefulBanlistsDisallowed()
{
m_queuedGridSettings.Add("allow_forceful_banlines", "FALSE");
}
/// <summary>
/// Is a Sandbox mode method, used by the local Login server to inform a region of a connection user/session
/// </summary>
/// <param name="regionHandle"></param>
/// <param name="loginData"></param>
/// <returns></returns>
public void AddNewSession(ulong regionHandle, Login loginData)
{
AgentCircuitData agent = new AgentCircuitData();
agent.AgentID = loginData.Agent;
agent.firstname = loginData.First;
agent.lastname = loginData.Last;
agent.SessionID = loginData.Session;
agent.SecureSessionID = loginData.SecureSession;
agent.circuitcode = loginData.CircuitCode;
agent.BaseFolder = loginData.BaseFolder;
agent.InventoryFolder = loginData.InventoryFolder;
agent.startpos = loginData.StartPos;
agent.CapsPath = loginData.CapsPath;
if (loginData.Appearance != null)
agent.Appearance = loginData.Appearance;
else
{
m_log.WarnFormat("[INTER]: Appearance not found for {0} {1}. Creating default.", agent.firstname, agent.lastname);
agent.Appearance = new AvatarAppearance(agent.AgentID);
}
TriggerExpectUser(regionHandle, agent);
}
public void TriggerExpectUser(ulong regionHandle, AgentCircuitData agent)
{
//m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: Other region is sending child agent our way: " + agent.firstname + " " + agent.lastname);
if (m_regionListeners.ContainsKey(regionHandle))
{
//m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: FoundLocalRegion To send it to: " + agent.firstname + " " + agent.lastname);
m_regionListeners[regionHandle].TriggerExpectUser(agent);
}
}
public void TriggerLogOffUser(ulong regionHandle, UUID agentID, UUID RegionSecret, string message)
{
if (m_regionListeners.ContainsKey(regionHandle))
{
//m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: FoundLocalRegion To send it to: " + agent.firstname + " " + agent.lastname);
m_regionListeners[regionHandle].TriggerLogOffUser(agentID, RegionSecret, message);
}
}
public void PingCheckReply(Hashtable respData)
{
foreach (ulong region in m_regions.Keys)
{
Hashtable regData = new Hashtable();
RegionInfo reg = m_regions[region];
regData["status"] = "active";
regData["handle"] = region.ToString();
respData[reg.RegionID.ToString()] = regData;
}
}
public LandData RequestLandData (ulong regionHandle, uint x, uint y)
{
m_log.DebugFormat("[INTERREGION STANDALONE] requests land data in {0}, at {1}, {2}",
regionHandle, x, y);
if (m_regionListeners.ContainsKey(regionHandle))
{
LandData land = m_regionListeners[regionHandle].TriggerGetLandData(x, y);
return land;
}
m_log.Debug("[INTERREGION STANDALONE] didn't find land data locally.");
return null;
}
public List<RegionInfo> RequestNamedRegions (string name, int maxNumber)
{
List<RegionInfo> lowercase_regions = new List<RegionInfo>();
List<RegionInfo> regions = new List<RegionInfo>();
foreach (RegionInfo info in m_regions.Values)
{
// Prioritizes exact match
if (info.RegionName.StartsWith(name))
{
regions.Add(info);
if (regions.Count >= maxNumber) break;
}
// But still saves lower case matches
else if (info.RegionName.ToLower().StartsWith(name))
{
if (lowercase_regions.Count < maxNumber)
{
lowercase_regions.Add(info);
}
}
}
// If no exact matches found, return lowercase matches (libOMV compatiblity)
if (regions.Count == 0 && lowercase_regions.Count != 0)
{
return lowercase_regions;
}
return regions;
}
}
}

View File

@ -39,8 +39,6 @@ namespace OpenSim.Region.Communications.OGS1
LibraryRootFolder libraryRootFolder) LibraryRootFolder libraryRootFolder)
: base(serversInfo, libraryRootFolder) : base(serversInfo, libraryRootFolder)
{ {
OGS1GridServices gridInterComms = new OGS1GridServices(serversInfo);
m_gridService = gridInterComms;
// This plugin arrangement could eventually be configurable rather than hardcoded here. // This plugin arrangement could eventually be configurable rather than hardcoded here.
OGS1UserServices userServices = new OGS1UserServices(this); OGS1UserServices userServices = new OGS1UserServices(this);

View File

@ -1,937 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using log4net;
using Nwc.XmlRpc;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Communications.Local;
namespace OpenSim.Region.Communications.OGS1
{
public class OGS1GridServices : IGridServices
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private bool m_useRemoteRegionCache = true;
/// <summary>
/// Encapsulate local backend services for manipulation of local regions
/// </summary>
private LocalBackEndServices m_localBackend = new LocalBackEndServices();
private Dictionary<ulong, RegionInfo> m_remoteRegionInfoCache = new Dictionary<ulong, RegionInfo>();
// private List<SimpleRegionInfo> m_knownRegions = new List<SimpleRegionInfo>();
private Dictionary<ulong, int> m_deadRegionCache = new Dictionary<ulong, int>();
private Dictionary<string, string> m_queuedGridSettings = new Dictionary<string, string>();
private List<RegionInfo> m_regionsOnInstance = new List<RegionInfo>();
public BaseHttpServer httpListener;
public NetworkServersInfo serversInfo;
public string gdebugRegionName
{
get { return m_localBackend.gdebugRegionName; }
set { m_localBackend.gdebugRegionName = value; }
}
public string rdebugRegionName
{
get { return _rdebugRegionName; }
set { _rdebugRegionName = value; }
}
private string _rdebugRegionName = String.Empty;
public bool RegionLoginsEnabled
{
get { return m_localBackend.RegionLoginsEnabled; }
set { m_localBackend.RegionLoginsEnabled = value; }
}
/// <summary>
/// Contructor. Adds "expect_user" and "check" xmlrpc method handlers
/// </summary>
/// <param name="servers_info"></param>
/// <param name="httpServe"></param>
public OGS1GridServices(NetworkServersInfo servers_info)
{
serversInfo = servers_info;
//Respond to Grid Services requests
MainServer.Instance.AddXmlRPCHandler("check", PingCheckReply);
}
// see IGridServices
public RegionCommsListener RegisterRegion(RegionInfo regionInfo)
{
if (m_regionsOnInstance.Contains(regionInfo))
{
m_log.Error("[OGS1 GRID SERVICES]: Foobar! Caller is confused, region already registered " + regionInfo.RegionName);
Exception e = new Exception(String.Format("Unable to register region"));
throw e;
}
m_log.InfoFormat(
"[OGS1 GRID SERVICES]: Registering region {0} with grid at {1}",
regionInfo.RegionName, serversInfo.GridURL);
m_regionsOnInstance.Add(regionInfo);
Hashtable GridParams = new Hashtable();
// Login / Authentication
GridParams["authkey"] = serversInfo.GridSendKey;
GridParams["recvkey"] = serversInfo.GridRecvKey;
GridParams["UUID"] = regionInfo.RegionID.ToString();
GridParams["sim_ip"] = regionInfo.ExternalHostName;
GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString();
GridParams["region_locx"] = regionInfo.RegionLocX.ToString();
GridParams["region_locy"] = regionInfo.RegionLocY.ToString();
GridParams["sim_name"] = regionInfo.RegionName;
GridParams["http_port"] = serversInfo.HttpListenerPort.ToString();
GridParams["remoting_port"] = ConfigSettings.DefaultRegionRemotingPort.ToString();
GridParams["map-image-id"] = regionInfo.RegionSettings.TerrainImageID.ToString();
GridParams["originUUID"] = regionInfo.originRegionID.ToString();
GridParams["server_uri"] = regionInfo.ServerURI;
GridParams["region_secret"] = regionInfo.regionSecret;
GridParams["major_interface_version"] = VersionInfo.MajorInterfaceVersion.ToString();
if (regionInfo.MasterAvatarAssignedUUID != UUID.Zero)
GridParams["master_avatar_uuid"] = regionInfo.MasterAvatarAssignedUUID.ToString();
else
GridParams["master_avatar_uuid"] = regionInfo.EstateSettings.EstateOwner.ToString();
GridParams["maturity"] = regionInfo.RegionSettings.Maturity.ToString();
// Package into an XMLRPC Request
ArrayList SendParams = new ArrayList();
SendParams.Add(GridParams);
// Send Request
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
XmlRpcResponse GridResp;
try
{
// The timeout should always be significantly larger than the timeout for the grid server to request
// the initial status of the region before confirming registration.
GridResp = GridReq.Send(serversInfo.GridURL, 9999999);
}
catch (Exception e)
{
Exception e2
= new Exception(
String.Format(
"Unable to register region with grid at {0}. Grid service not running?",
serversInfo.GridURL),
e);
throw e2;
}
Hashtable GridRespData = (Hashtable)GridResp.Value;
// Hashtable griddatahash = GridRespData;
// Process Response
if (GridRespData.ContainsKey("error"))
{
string errorstring = (string) GridRespData["error"];
Exception e = new Exception(
String.Format("Unable to connect to grid at {0}: {1}", serversInfo.GridURL, errorstring));
throw e;
}
else
{
// m_knownRegions = RequestNeighbours(regionInfo.RegionLocX, regionInfo.RegionLocY);
if (GridRespData.ContainsKey("allow_forceful_banlines"))
{
if ((string) GridRespData["allow_forceful_banlines"] != "TRUE")
{
//m_localBackend.SetForcefulBanlistsDisallowed(regionInfo.RegionHandle);
if (!m_queuedGridSettings.ContainsKey("allow_forceful_banlines"))
m_queuedGridSettings.Add("allow_forceful_banlines", "FALSE");
}
}
m_log.InfoFormat(
"[OGS1 GRID SERVICES]: Region {0} successfully registered with grid at {1}",
regionInfo.RegionName, serversInfo.GridURL);
}
return m_localBackend.RegisterRegion(regionInfo);
}
// see IGridServices
public bool DeregisterRegion(RegionInfo regionInfo)
{
Hashtable GridParams = new Hashtable();
GridParams["UUID"] = regionInfo.RegionID.ToString();
// Package into an XMLRPC Request
ArrayList SendParams = new ArrayList();
SendParams.Add(GridParams);
// Send Request
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_after_region_moved", SendParams);
XmlRpcResponse GridResp = null;
try
{
GridResp = GridReq.Send(serversInfo.GridURL, 10000);
}
catch (Exception e)
{
Exception e2
= new Exception(
String.Format(
"Unable to deregister region with grid at {0}. Grid service not running?",
serversInfo.GridURL),
e);
throw e2;
}
Hashtable GridRespData = (Hashtable) GridResp.Value;
// Hashtable griddatahash = GridRespData;
// Process Response
if (GridRespData != null && GridRespData.ContainsKey("error"))
{
string errorstring = (string)GridRespData["error"];
m_log.Error("Unable to connect to grid: " + errorstring);
return false;
}
return m_localBackend.DeregisterRegion(regionInfo);
}
public virtual Dictionary<string, string> GetGridSettings()
{
Dictionary<string, string> returnGridSettings = new Dictionary<string, string>();
lock (m_queuedGridSettings)
{
foreach (string Dictkey in m_queuedGridSettings.Keys)
{
returnGridSettings.Add(Dictkey, m_queuedGridSettings[Dictkey]);
}
m_queuedGridSettings.Clear();
}
return returnGridSettings;
}
// see IGridServices
public List<SimpleRegionInfo> RequestNeighbours(uint x, uint y)
{
Hashtable respData = MapBlockQuery((int) x - 1, (int) y - 1, (int) x + 1, (int) y + 1);
List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
foreach (ArrayList neighboursList in respData.Values)
{
foreach (Hashtable neighbourData in neighboursList)
{
uint regX = Convert.ToUInt32(neighbourData["x"]);
uint regY = Convert.ToUInt32(neighbourData["y"]);
if ((x != regX) || (y != regY))
{
string simIp = (string) neighbourData["sim_ip"];
uint port = Convert.ToUInt32(neighbourData["sim_port"]);
// string externalUri = (string) neighbourData["sim_uri"];
// string externalIpStr = String.Empty;
try
{
// externalIpStr = Util.GetHostFromDNS(simIp).ToString();
Util.GetHostFromDNS(simIp).ToString();
}
catch (SocketException e)
{
m_log.WarnFormat(
"[OGS1 GRID SERVICES]: RequestNeighbours(): Lookup of neighbour {0} failed! Not including in neighbours list. {1}",
simIp, e);
continue;
}
SimpleRegionInfo sri = new SimpleRegionInfo(regX, regY, simIp, port);
sri.RemotingPort = Convert.ToUInt32(neighbourData["remoting_port"]);
if (neighbourData.ContainsKey("http_port"))
{
sri.HttpPort = Convert.ToUInt32(neighbourData["http_port"]);
}
else
{
m_log.Error("[OGS1 GRID SERVICES]: Couldn't find httpPort, using default 9000; please upgrade your grid-server to r7621 or later");
sri.HttpPort = 9000; // that's the default and will probably be wrong
}
sri.RegionID = new UUID((string) neighbourData["uuid"]);
neighbours.Add(sri);
}
}
}
return neighbours;
}
/// <summary>
/// Request information about a region.
/// </summary>
/// <param name="regionHandle"></param>
/// <returns>
/// null on a failure to contact or get a response from the grid server
/// FIXME: Might be nicer to return a proper exception here since we could inform the client more about the
/// nature of the faiulre.
/// </returns>
public RegionInfo RequestNeighbourInfo(UUID Region_UUID)
{
// don't ask the gridserver about regions on this instance...
foreach (RegionInfo info in m_regionsOnInstance)
{
if (info.RegionID == Region_UUID) return info;
}
// didn't find it so far, we have to go the long way
RegionInfo regionInfo;
Hashtable requestData = new Hashtable();
requestData["region_UUID"] = Region_UUID.ToString();
requestData["authkey"] = serversInfo.GridSendKey;
ArrayList SendParams = new ArrayList();
SendParams.Add(requestData);
XmlRpcRequest gridReq = new XmlRpcRequest("simulator_data_request", SendParams);
XmlRpcResponse gridResp = null;
try
{
gridResp = gridReq.Send(serversInfo.GridURL, 3000);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[OGS1 GRID SERVICES]: Communication with the grid server at {0} failed, {1}",
serversInfo.GridURL, e);
return null;
}
Hashtable responseData = (Hashtable)gridResp.Value;
if (responseData.ContainsKey("error"))
{
m_log.WarnFormat("[OGS1 GRID SERVICES]: Error received from grid server: {0}", responseData["error"]);
return null;
}
regionInfo = buildRegionInfo(responseData, String.Empty);
if ((m_useRemoteRegionCache) && (requestData.ContainsKey("regionHandle")))
{
m_remoteRegionInfoCache.Add(Convert.ToUInt64((string) requestData["regionHandle"]), regionInfo);
}
return regionInfo;
}
/// <summary>
/// Request information about a region.
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbourInfo(ulong regionHandle)
{
RegionInfo regionInfo = m_localBackend.RequestNeighbourInfo(regionHandle);
if (regionInfo != null)
{
return regionInfo;
}
if ((!m_useRemoteRegionCache) || (!m_remoteRegionInfoCache.TryGetValue(regionHandle, out regionInfo)))
{
try
{
Hashtable requestData = new Hashtable();
requestData["region_handle"] = regionHandle.ToString();
requestData["authkey"] = serversInfo.GridSendKey;
ArrayList SendParams = new ArrayList();
SendParams.Add(requestData);
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000);
Hashtable responseData = (Hashtable) GridResp.Value;
if (responseData.ContainsKey("error"))
{
m_log.Error("[OGS1 GRID SERVICES]: Error received from grid server: " + responseData["error"]);
return null;
}
uint regX = Convert.ToUInt32((string) responseData["region_locx"]);
uint regY = Convert.ToUInt32((string) responseData["region_locy"]);
string externalHostName = (string) responseData["sim_ip"];
uint simPort = Convert.ToUInt32(responseData["sim_port"]);
string regionName = (string)responseData["region_name"];
UUID regionID = new UUID((string)responseData["region_UUID"]);
uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
uint httpPort = 9000;
if (responseData.ContainsKey("http_port"))
{
httpPort = Convert.ToUInt32((string)responseData["http_port"]);
}
// Ok, so this is definitively the wrong place to do this, way too hard coded, but it doesn't seem we GET this info?
string simURI = "http://" + externalHostName + ":" + simPort;
// string externalUri = (string) responseData["sim_uri"];
//IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port);
regionInfo = RegionInfo.Create(regionID, regionName, regX, regY, externalHostName, httpPort, simPort, remotingPort, simURI);
if (m_useRemoteRegionCache)
{
lock (m_remoteRegionInfoCache)
{
if (!m_remoteRegionInfoCache.ContainsKey(regionHandle))
{
m_remoteRegionInfoCache.Add(regionHandle, regionInfo);
}
}
}
}
catch (Exception e)
{
m_log.Error("[OGS1 GRID SERVICES]: " +
"Region lookup failed for: " + regionHandle.ToString() +
" - Is the GridServer down?" + e.ToString());
return null;
}
}
return regionInfo;
}
/// <summary>
/// Get information about a neighbouring region
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbourInfo(string name)
{
// Not implemented yet
return null;
}
/// <summary>
/// Get information about a neighbouring region
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbourInfo(string host, uint port)
{
// Not implemented yet
return null;
}
public RegionInfo RequestClosestRegion(string regionName)
{
if (m_useRemoteRegionCache)
{
foreach (RegionInfo ri in m_remoteRegionInfoCache.Values)
{
if (ri.RegionName == regionName)
return ri;
}
}
RegionInfo regionInfo = null;
try
{
Hashtable requestData = new Hashtable();
requestData["region_name_search"] = regionName;
requestData["authkey"] = serversInfo.GridSendKey;
ArrayList SendParams = new ArrayList();
SendParams.Add(requestData);
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000);
Hashtable responseData = (Hashtable) GridResp.Value;
if (responseData.ContainsKey("error"))
{
m_log.ErrorFormat("[OGS1 GRID SERVICES]: Error received from grid server: ", responseData["error"]);
return null;
}
regionInfo = buildRegionInfo(responseData, "");
if ((m_useRemoteRegionCache) && (!m_remoteRegionInfoCache.ContainsKey(regionInfo.RegionHandle)))
m_remoteRegionInfoCache.Add(regionInfo.RegionHandle, regionInfo);
}
catch
{
m_log.Error("[OGS1 GRID SERVICES]: " +
"Region lookup failed for: " + regionName +
" - Is the GridServer down?");
}
return regionInfo;
}
/// <summary>
///
/// </summary>
/// <param name="minX"></param>
/// <param name="minY"></param>
/// <param name="maxX"></param>
/// <param name="maxY"></param>
/// <returns></returns>
public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
{
int temp = 0;
if (minX > maxX)
{
temp = minX;
minX = maxX;
maxX = temp;
}
if (minY > maxY)
{
temp = minY;
minY = maxY;
maxY = temp;
}
Hashtable respData = MapBlockQuery(minX, minY, maxX, maxY);
List<MapBlockData> neighbours = new List<MapBlockData>();
foreach (ArrayList a in respData.Values)
{
foreach (Hashtable n in a)
{
MapBlockData neighbour = new MapBlockData();
neighbour.X = Convert.ToUInt16(n["x"]);
neighbour.Y = Convert.ToUInt16(n["y"]);
neighbour.Name = (string) n["name"];
neighbour.Access = Convert.ToByte(n["access"]);
neighbour.RegionFlags = Convert.ToUInt32(n["region-flags"]);
neighbour.WaterHeight = Convert.ToByte(n["water-height"]);
neighbour.MapImageId = new UUID((string) n["map-image-id"]);
neighbours.Add(neighbour);
}
}
return neighbours;
}
/// <summary>
/// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates
/// </summary>
/// <remarks>REDUNDANT - OGS1 is to be phased out in favour of OGS2</remarks>
/// <param name="minX">Minimum X value</param>
/// <param name="minY">Minimum Y value</param>
/// <param name="maxX">Maximum X value</param>
/// <param name="maxY">Maximum Y value</param>
/// <returns>Hashtable of hashtables containing map data elements</returns>
private Hashtable MapBlockQuery(int minX, int minY, int maxX, int maxY)
{
Hashtable param = new Hashtable();
param["xmin"] = minX;
param["ymin"] = minY;
param["xmax"] = maxX;
param["ymax"] = maxY;
IList parameters = new ArrayList();
parameters.Add(param);
try
{
XmlRpcRequest req = new XmlRpcRequest("map_block", parameters);
XmlRpcResponse resp = req.Send(serversInfo.GridURL, 10000);
Hashtable respData = (Hashtable) resp.Value;
return respData;
}
catch (Exception e)
{
m_log.Error("MapBlockQuery XMLRPC failure: " + e);
return new Hashtable();
}
}
/// <summary>
/// A ping / version check
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse PingCheckReply(XmlRpcRequest request, IPEndPoint remoteClient)
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable respData = new Hashtable();
respData["online"] = "true";
m_localBackend.PingCheckReply(respData);
response.Value = respData;
return response;
}
/// <summary>
/// Received from the user server when a user starts logging in. This call allows
/// the region to prepare for direct communication from the client. Sends back an empty
/// xmlrpc response on completion.
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse ExpectUser(XmlRpcRequest request)
{
Hashtable requestData = (Hashtable) request.Params[0];
AgentCircuitData agentData = new AgentCircuitData();
agentData.SessionID = new UUID((string) requestData["session_id"]);
agentData.SecureSessionID = new UUID((string) requestData["secure_session_id"]);
agentData.firstname = (string) requestData["firstname"];
agentData.lastname = (string) requestData["lastname"];
agentData.AgentID = new UUID((string) requestData["agent_id"]);
agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
agentData.CapsPath = (string)requestData["caps_path"];
ulong regionHandle = Convert.ToUInt64((string) requestData["regionhandle"]);
// Appearance
if (requestData["appearance"] != null)
agentData.Appearance = new AvatarAppearance((Hashtable)requestData["appearance"]);
m_log.DebugFormat(
"[CLIENT]: Told by user service to prepare for a connection from {0} {1} {2}, circuit {3}",
agentData.firstname, agentData.lastname, agentData.AgentID, agentData.circuitcode);
if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
{
//m_log.Debug("[CLIENT]: Child agent detected");
agentData.child = true;
}
else
{
//m_log.Debug("[CLIENT]: Main agent detected");
agentData.startpos =
new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]),
(float)Convert.ToDecimal((string)requestData["startpos_y"]),
(float)Convert.ToDecimal((string)requestData["startpos_z"]));
agentData.child = false;
}
XmlRpcResponse resp = new XmlRpcResponse();
if (!RegionLoginsEnabled)
{
m_log.InfoFormat(
"[CLIENT]: Denying access for user {0} {1} because region login is currently disabled",
agentData.firstname, agentData.lastname);
Hashtable respdata = new Hashtable();
respdata["success"] = "FALSE";
respdata["reason"] = "region login currently disabled";
resp.Value = respdata;
}
else
{
RegionInfo[] regions = m_regionsOnInstance.ToArray();
bool banned = false;
for (int i = 0; i < regions.Length; i++)
{
if (regions[i] != null)
{
if (regions[i].RegionHandle == regionHandle)
{
if (regions[i].EstateSettings.IsBanned(agentData.AgentID))
{
banned = true;
break;
}
}
}
}
if (banned)
{
m_log.InfoFormat(
"[CLIENT]: Denying access for user {0} {1} because user is banned",
agentData.firstname, agentData.lastname);
Hashtable respdata = new Hashtable();
respdata["success"] = "FALSE";
respdata["reason"] = "banned";
resp.Value = respdata;
}
else
{
m_localBackend.TriggerExpectUser(regionHandle, agentData);
Hashtable respdata = new Hashtable();
respdata["success"] = "TRUE";
resp.Value = respdata;
}
}
return resp;
}
// Grid Request Processing
/// <summary>
/// Ooops, our Agent must be dead if we're getting this request!
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse LogOffUser(XmlRpcRequest request)
{
m_log.Debug("[CONNECTION DEBUGGING]: LogOff User Called");
Hashtable requestData = (Hashtable)request.Params[0];
string message = (string)requestData["message"];
UUID agentID = UUID.Zero;
UUID RegionSecret = UUID.Zero;
UUID.TryParse((string)requestData["agent_id"], out agentID);
UUID.TryParse((string)requestData["region_secret"], out RegionSecret);
ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
m_localBackend.TriggerLogOffUser(regionHandle, agentID, RegionSecret,message);
return new XmlRpcResponse();
}
public void NoteDeadRegion(ulong regionhandle)
{
lock (m_deadRegionCache)
{
if (m_deadRegionCache.ContainsKey(regionhandle))
{
m_deadRegionCache[regionhandle] = m_deadRegionCache[regionhandle] + 1;
}
else
{
m_deadRegionCache.Add(regionhandle, 1);
}
}
}
public LandData RequestLandData (ulong regionHandle, uint x, uint y)
{
m_log.DebugFormat("[OGS1 GRID SERVICES] requests land data in {0}, at {1}, {2}",
regionHandle, x, y);
LandData landData = m_localBackend.RequestLandData(regionHandle, x, y);
if (landData == null)
{
Hashtable hash = new Hashtable();
hash["region_handle"] = regionHandle.ToString();
hash["x"] = x.ToString();
hash["y"] = y.ToString();
IList paramList = new ArrayList();
paramList.Add(hash);
try
{
// this might be cached, as we probably requested it just a moment ago...
RegionInfo info = RequestNeighbourInfo(regionHandle);
if (info != null) // just to be sure
{
XmlRpcRequest request = new XmlRpcRequest("land_data", paramList);
string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
XmlRpcResponse response = request.Send(uri, 10000);
if (response.IsFault)
{
m_log.ErrorFormat("[OGS1 GRID SERVICES] remote call returned an error: {0}", response.FaultString);
}
else
{
hash = (Hashtable)response.Value;
try
{
landData = new LandData();
landData.AABBMax = Vector3.Parse((string)hash["AABBMax"]);
landData.AABBMin = Vector3.Parse((string)hash["AABBMin"]);
landData.Area = Convert.ToInt32(hash["Area"]);
landData.AuctionID = Convert.ToUInt32(hash["AuctionID"]);
landData.Description = (string)hash["Description"];
landData.Flags = Convert.ToUInt32(hash["Flags"]);
landData.GlobalID = new UUID((string)hash["GlobalID"]);
landData.Name = (string)hash["Name"];
landData.OwnerID = new UUID((string)hash["OwnerID"]);
landData.SalePrice = Convert.ToInt32(hash["SalePrice"]);
landData.SnapshotID = new UUID((string)hash["SnapshotID"]);
landData.UserLocation = Vector3.Parse((string)hash["UserLocation"]);
m_log.DebugFormat("[OGS1 GRID SERVICES] Got land data for parcel {0}", landData.Name);
}
catch (Exception e)
{
m_log.Error("[OGS1 GRID SERVICES] Got exception while parsing land-data:", e);
}
}
}
else m_log.WarnFormat("[OGS1 GRID SERVICES] Couldn't find region with handle {0}", regionHandle);
}
catch (Exception e)
{
m_log.ErrorFormat("[OGS1 GRID SERVICES] Couldn't contact region {0}: {1}", regionHandle, e);
}
}
return landData;
}
// Grid Request Processing
/// <summary>
/// Someone asked us about parcel-information
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse LandData(XmlRpcRequest request, IPEndPoint remoteClient)
{
Hashtable requestData = (Hashtable)request.Params[0];
ulong regionHandle = Convert.ToUInt64(requestData["region_handle"]);
uint x = Convert.ToUInt32(requestData["x"]);
uint y = Convert.ToUInt32(requestData["y"]);
m_log.DebugFormat("[OGS1 GRID SERVICES]: Got XML reqeuest for land data at {0}, {1} in region {2}", x, y, regionHandle);
LandData landData = m_localBackend.RequestLandData(regionHandle, x, y);
Hashtable hash = new Hashtable();
if (landData != null)
{
// for now, only push out the data we need for answering a ParcelInfoReqeust
hash["AABBMax"] = landData.AABBMax.ToString();
hash["AABBMin"] = landData.AABBMin.ToString();
hash["Area"] = landData.Area.ToString();
hash["AuctionID"] = landData.AuctionID.ToString();
hash["Description"] = landData.Description;
hash["Flags"] = landData.Flags.ToString();
hash["GlobalID"] = landData.GlobalID.ToString();
hash["Name"] = landData.Name;
hash["OwnerID"] = landData.OwnerID.ToString();
hash["SalePrice"] = landData.SalePrice.ToString();
hash["SnapshotID"] = landData.SnapshotID.ToString();
hash["UserLocation"] = landData.UserLocation.ToString();
}
XmlRpcResponse response = new XmlRpcResponse();
response.Value = hash;
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;
}
}
}
}

View File

@ -40,6 +40,7 @@ using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.Avatar.Friends namespace OpenSim.Region.CoreModules.Avatar.Friends
{ {
@ -108,7 +109,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>(); private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>();
private IMessageTransferModule m_TransferModule = null; private IMessageTransferModule m_TransferModule = null;
private IGridServices m_gridServices = null; private IGridService m_gridServices = null;
#region IRegionModule Members #region IRegionModule Members
@ -142,7 +143,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (m_scenes.Count > 0) if (m_scenes.Count > 0)
{ {
m_TransferModule = m_initialScene.RequestModuleInterface<IMessageTransferModule>(); m_TransferModule = m_initialScene.RequestModuleInterface<IMessageTransferModule>();
m_gridServices = m_initialScene.CommsManager.GridService; m_gridServices = m_initialScene.GridService;
} }
if (m_TransferModule == null) if (m_TransferModule == null)
m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work"); m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work");
@ -171,7 +172,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
List<UUID> tpdAway = new List<UUID>(); List<UUID> tpdAway = new List<UUID>();
// destRegionHandle is a region on another server // destRegionHandle is a region on another server
RegionInfo info = m_gridServices.RequestNeighbourInfo(destRegionHandle); uint x = 0, y = 0;
Utils.LongToUInts(destRegionHandle, out x, out y);
GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y);
if (info != null) if (info != null)
{ {
string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk";
@ -223,7 +226,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
public bool TriggerTerminateFriend(ulong destRegionHandle, UUID agentID, UUID exFriendID) public bool TriggerTerminateFriend(ulong destRegionHandle, UUID agentID, UUID exFriendID)
{ {
// destRegionHandle is a region on another server // destRegionHandle is a region on another server
RegionInfo info = m_gridServices.RequestNeighbourInfo(destRegionHandle); uint x = 0, y = 0;
Utils.LongToUInts(destRegionHandle, out x, out y);
GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y);
if (info == null) if (info == null)
{ {
m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}", destRegionHandle); m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}", destRegionHandle);

View File

@ -36,6 +36,7 @@ using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.Avatar.InstantMessage namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{ {
@ -497,7 +498,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{ {
if (upd.AgentOnline) if (upd.AgentOnline)
{ {
RegionInfo reginfo = m_Scenes[0].SceneGridService.RequestNeighbouringRegionInfo(upd.Handle); uint x = 0, y = 0;
Utils.LongToUInts(upd.Handle, out x, out y);
GridRegion reginfo = m_Scenes[0].GridService.GetRegionByPosition(m_Scenes[0].RegionInfo.ScopeID,
(int)x, (int)y);
if (reginfo != null) if (reginfo != null)
{ {
Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im);
@ -559,7 +563,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
/// <param name="reginfo">RegionInfo we pull the data out of to send the request to</param> /// <param name="reginfo">RegionInfo we pull the data out of to send the request to</param>
/// <param name="xmlrpcdata">The Instant Message data Hashtable</param> /// <param name="xmlrpcdata">The Instant Message data Hashtable</param>
/// <returns>Bool if the message was successfully delivered at the other side.</returns> /// <returns>Bool if the message was successfully delivered at the other side.</returns>
protected virtual bool doIMSending(RegionInfo reginfo, Hashtable xmlrpcdata) protected virtual bool doIMSending(GridRegion reginfo, Hashtable xmlrpcdata)
{ {
ArrayList SendParams = new ArrayList(); ArrayList SendParams = new ArrayList();

View File

@ -35,6 +35,7 @@ using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.Avatar.InstantMessage namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{ {
@ -171,7 +172,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{ {
// TODO this is the old messaging-server protocol; only the regionHandle is available. // TODO this is the old messaging-server protocol; only the regionHandle is available.
// Fetch region-info to get the id // Fetch region-info to get the id
RegionInfo regionInfo = m_initialScene.RequestNeighbouringRegionInfo(info.regionHandle); uint x = 0, y = 0;
Utils.LongToUInts(info.regionHandle, out x, out y);
GridRegion regionInfo = m_initialScene.GridService.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID,
(int)x, (int)y);
regionID = regionInfo.RegionID; regionID = regionInfo.RegionID;
} }
result[indices[i]] = new PresenceInfo(uuids[i], regionID); result[indices[i]] = new PresenceInfo(uuids[i], regionID);
@ -349,6 +353,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
private void NotifyMessageServerOfShutdown(Scene scene) private void NotifyMessageServerOfShutdown(Scene scene)
{ {
if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
return;
Hashtable xmlrpcdata = new Hashtable(); Hashtable xmlrpcdata = new Hashtable();
xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString();
ArrayList SendParams = new ArrayList(); ArrayList SendParams = new ArrayList();
@ -372,6 +379,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
private void NotifyMessageServerOfAgentLocation(UUID agentID, UUID region, ulong regionHandle) private void NotifyMessageServerOfAgentLocation(UUID agentID, UUID region, ulong regionHandle)
{ {
if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
return;
Hashtable xmlrpcdata = new Hashtable(); Hashtable xmlrpcdata = new Hashtable();
xmlrpcdata["AgentID"] = agentID.ToString(); xmlrpcdata["AgentID"] = agentID.ToString();
xmlrpcdata["RegionUUID"] = region.ToString(); xmlrpcdata["RegionUUID"] = region.ToString();
@ -397,6 +407,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
private void NotifyMessageServerOfAgentLeaving(UUID agentID, UUID region, ulong regionHandle) private void NotifyMessageServerOfAgentLeaving(UUID agentID, UUID region, ulong regionHandle)
{ {
if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
return;
Hashtable xmlrpcdata = new Hashtable(); Hashtable xmlrpcdata = new Hashtable();
xmlrpcdata["AgentID"] = agentID.ToString(); xmlrpcdata["AgentID"] = agentID.ToString();
xmlrpcdata["RegionUUID"] = region.ToString(); xmlrpcdata["RegionUUID"] = region.ToString();

View File

@ -1,208 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.Reflection;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Data;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using Nwc.XmlRpc;
namespace OpenSim.Region.CoreModules.Framework.Services
{
public class RegionMapService : IRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static bool initialized = false;
private static bool enabled = false;
Scene m_scene;
//AssetService m_assetService;
#region IRegionModule interface
public void Initialise(Scene scene, IConfigSource config)
{
if (!initialized)
{
initialized = true;
m_scene = scene;
// This module is only on for hypergrid mode
enabled = config.Configs["Startup"].GetBoolean("hypergrid", false);
}
}
public void PostInitialise()
{
if (enabled)
{
m_log.Info("[RegionMapService]: Starting...");
//m_assetService = new AssetService(m_scene);
new GridService(m_scene);
}
}
public void Close()
{
}
public string Name
{
get { return "RegionMapService"; }
}
public bool IsSharedModule
{
get { return true; }
}
#endregion
}
public class GridService
{
// private IUserService m_userService;
private IGridServices m_gridService;
private bool m_doLookup = false;
public bool DoLookup
{
get { return m_doLookup; }
set { m_doLookup = value; }
}
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public GridService(Scene m_scene)
{
AddHandlers(m_scene);
// m_userService = m_scene.CommsManager.UserService;
m_gridService = m_scene.CommsManager.GridService;
}
protected void AddHandlers(Scene m_scene)
{
// IAssetDataPlugin m_assetProvider
// = ((AssetServerBase)m_scene.CommsManager.AssetCache.AssetServer).AssetProviderPlugin;
IHttpServer httpServer = MainServer.Instance;
httpServer.AddXmlRPCHandler("simulator_data_request", XmlRpcSimulatorDataRequestMethod);
//m_httpServer.AddXmlRPCHandler("map_block", XmlRpcMapBlockMethod);
//m_httpServer.AddXmlRPCHandler("search_for_region_by_name", XmlRpcSearchForRegionMethod);
}
/// <summary>
/// Returns an XML RPC response to a simulator profile request
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request, IPEndPoint remoteClient)
{
Hashtable requestData = (Hashtable)request.Params[0];
Hashtable responseData = new Hashtable();
RegionInfo simData = null;
if (requestData.ContainsKey("region_UUID"))
{
UUID regionID = new UUID((string)requestData["region_UUID"]);
simData = m_gridService.RequestNeighbourInfo(regionID); //.GetRegion(regionID);
if (simData == null)
{
m_log.WarnFormat("[HGGridService] didn't find region for regionID {0} from {1}",
regionID, request.Params.Count > 1 ? request.Params[1] : "unknwon source");
}
}
else if (requestData.ContainsKey("region_handle"))
{
//CFK: The if/else below this makes this message redundant.
//CFK: m_log.Info("requesting data for region " + (string) requestData["region_handle"]);
ulong regionHandle = Convert.ToUInt64((string)requestData["region_handle"]);
simData = m_gridService.RequestNeighbourInfo(regionHandle); //m_gridDBService.GetRegion(regionHandle);
if (simData == null)
{
m_log.WarnFormat("[HGGridService] didn't find region for regionHandle {0} from {1}",
regionHandle, request.Params.Count > 1 ? request.Params[1] : "unknwon source");
}
}
else if (requestData.ContainsKey("region_name_search"))
{
string regionName = (string)requestData["region_name_search"];
List<RegionInfo> regInfos = m_gridService.RequestNamedRegions(regionName, 1);//m_gridDBService.GetRegion(regionName);
if (regInfos != null)
simData = regInfos[0];
if (simData == null)
{
m_log.WarnFormat("[HGGridService] didn't find region for regionName {0} from {1}",
regionName, request.Params.Count > 1 ? request.Params[1] : "unknwon source");
}
}
else m_log.Warn("[HGGridService] regionlookup without regionID, regionHandle or regionHame");
if (simData == null)
{
//Sim does not exist
responseData["error"] = "Sim does not exist";
}
else
{
m_log.Debug("[HGGridService]: found " + (string)simData.RegionName + " regionHandle = " +
(string)requestData["region_handle"]);
responseData["sim_ip"] = simData.ExternalEndPoint.Address.ToString();
responseData["sim_port"] = simData.ExternalEndPoint.Port.ToString();
//responseData["server_uri"] = simData.serverURI;
responseData["http_port"] = simData.HttpPort.ToString();
//responseData["remoting_port"] = simData.remotingPort.ToString();
responseData["region_locx"] = simData.RegionLocX.ToString();
responseData["region_locy"] = simData.RegionLocY.ToString();
responseData["region_UUID"] = simData.RegionID.ToString();
responseData["region_name"] = simData.RegionName;
responseData["region_secret"] = simData.regionSecret;
}
XmlRpcResponse response = new XmlRpcResponse();
response.Value = responseData;
return response;
}
}
}

View File

@ -34,6 +34,7 @@ using OpenSim.Framework;
using OpenSim.Region.CoreModules.World.WorldMap; using OpenSim.Region.CoreModules.World.WorldMap;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.Hypergrid namespace OpenSim.Region.CoreModules.Hypergrid
{ {
@ -59,7 +60,17 @@ namespace OpenSim.Region.CoreModules.Hypergrid
protected override void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) protected override void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
{ {
List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4); List<MapBlockData> mapBlocks = new List<MapBlockData>();
List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
(minX - 4) * (int)Constants.RegionSize, (maxX + 4) * (int)Constants.RegionSize,
(minY - 4) * (int)Constants.RegionSize, (maxY + 4) * (int)Constants.RegionSize);
foreach (GridRegion r in regions)
{
MapBlockData block = new MapBlockData();
MapBlockFromGridRegion(block, r);
mapBlocks.Add(block);
}
// Different from super // Different from super
FillInMap(mapBlocks, minX, minY, maxX, maxY); FillInMap(mapBlocks, minX, minY, maxX, maxY);

View File

@ -37,6 +37,8 @@ using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base; using OpenSim.Server.Base;
using OpenSim.Server.Handlers.Base; using OpenSim.Server.Handlers.Base;
using OpenSim.Server.Handlers.Grid; using OpenSim.Server.Handlers.Grid;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
{ {
@ -94,6 +96,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
if (!m_Enabled) if (!m_Enabled)
return; return;
}
public void RemoveRegion(Scene scene)
{
if (!m_Enabled)
return;
GridRegion rinfo = new GridRegion(scene.RegionInfo);
m_HypergridHandler.RemoveRegion(rinfo);
}
public void RegionLoaded(Scene scene)
{
if (!m_Registered) if (!m_Registered)
{ {
m_Registered = true; m_Registered = true;
@ -102,27 +117,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
Object[] args = new Object[] { m_Config, MainServer.Instance }; Object[] args = new Object[] { m_Config, MainServer.Instance };
m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance); m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance, scene.RequestModuleInterface<IHyperlinkService>());
//ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args); //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
} }
SimpleRegionInfo rinfo = new SimpleRegionInfo(scene.RegionInfo); GridRegion rinfo = new GridRegion(scene.RegionInfo);
m_HypergridHandler.AddRegion(rinfo); m_HypergridHandler.AddRegion(rinfo);
} }
public void RemoveRegion(Scene scene)
{
if (!m_Enabled)
return;
SimpleRegionInfo rinfo = new SimpleRegionInfo(scene.RegionInfo);
m_HypergridHandler.RemoveRegion(rinfo);
}
public void RegionLoaded(Scene scene)
{
}
#endregion #endregion
} }

View File

@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour
#region INeighbourService #region INeighbourService
public bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) public GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
{ {
m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}", m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}",
thisRegion.RegionName, regionHandle, m_Scenes.Count); thisRegion.RegionName, regionHandle, m_Scenes.Count);
@ -134,7 +134,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour
} }
} }
m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: region handle {0} not found", regionHandle); m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: region handle {0} not found", regionHandle);
return false; return null;
} }
#endregion INeighbourService #endregion INeighbourService

View File

@ -86,7 +86,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
private void RunHGCommand(string command, string[] cmdparams) private void RunHGCommand(string command, string[] cmdparams)
{ {
if (command.Equals("linkk-mapping")) if (command.Equals("link-mapping"))
{ {
if (cmdparams.Length == 2) if (cmdparams.Length == 2)
{ {
@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
} }
} }
} }
else if (command.Equals("linkk-region")) else if (command.Equals("link-region"))
{ {
if (cmdparams.Length < 3) if (cmdparams.Length < 3)
{ {
@ -187,7 +187,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
} }
return; return;
} }
else if (command.Equals("unlinkk-region")) else if (command.Equals("unlink-region"))
{ {
if (cmdparams.Length < 1) if (cmdparams.Length < 1)
{ {

View File

@ -31,6 +31,7 @@ using System.Net;
using System.Reflection; using System.Reflection;
using System.Xml; using System.Xml;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
@ -47,15 +48,19 @@ using Nini.Config;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
{ {
public class HGGridConnector : ISharedRegionModule, IGridService public class HGGridConnector : ISharedRegionModule, IGridService, IHyperlinkService
{ {
private static readonly ILog m_log = private static readonly ILog m_log =
LogManager.GetLogger( LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType); MethodBase.GetCurrentMethod().DeclaringType);
private static string LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI;
private bool m_Enabled = false; private bool m_Enabled = false;
private bool m_Initialized = false; private bool m_Initialized = false;
private Scene m_aScene;
private Dictionary<ulong, Scene> m_LocalScenes = new Dictionary<ulong, Scene>();
private IGridService m_GridServiceConnector; private IGridService m_GridServiceConnector;
private HypergridServiceConnector m_HypergridServiceConnector; private HypergridServiceConnector m_HypergridServiceConnector;
@ -130,6 +135,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public void PostInitialise() public void PostInitialise()
{ {
if (m_Enabled)
((ISharedRegionModule)m_GridServiceConnector).PostInitialise();
} }
public void Close() public void Close()
@ -141,12 +148,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if (!m_Enabled) if (!m_Enabled)
return; return;
m_LocalScenes[scene.RegionInfo.RegionHandle] = scene;
scene.RegisterModuleInterface<IGridService>(this); scene.RegisterModuleInterface<IGridService>(this);
scene.RegisterModuleInterface<IHyperlinkService>(this);
((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene);
} }
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
{ {
if (m_Enabled)
{
m_LocalScenes.Remove(scene.RegionInfo.RegionHandle);
((ISharedRegionModule)m_GridServiceConnector).RemoveRegion(scene);
}
} }
public void RegionLoaded(Scene scene) public void RegionLoaded(Scene scene)
@ -156,29 +172,28 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if (!m_Initialized) if (!m_Initialized)
{ {
m_aScene = scene;
LocalAssetServerURI = m_aScene.CommsManager.NetworkServersInfo.UserURL;
LocalInventoryServerURI = m_aScene.CommsManager.NetworkServersInfo.InventoryURL;
LocalUserServerURI = m_aScene.CommsManager.NetworkServersInfo.UserURL;
m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService); m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService);
HGCommands hgCommands = new HGCommands(this, scene); HGCommands hgCommands = new HGCommands(this, scene);
MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-region", MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-region",
"link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>", "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
"Link a hypergrid region", hgCommands.RunCommand); "Link a hypergrid region", hgCommands.RunCommand);
MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlinkk-region", MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlink-region",
"unlink-region <local name> or <HostName>:<HttpPort> <cr>", "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
"Unlink a hypergrid region", hgCommands.RunCommand); "Unlink a hypergrid region", hgCommands.RunCommand);
MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-mapping", "link-mapping [<x> <y>] <cr>", MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
"Set local coordinate to map HG regions to", hgCommands.RunCommand); "Set local coordinate to map HG regions to", hgCommands.RunCommand);
// Yikes!! Remove this as soon as user services get refactored
HGNetworkServersInfo.Init(LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI);
m_Initialized = true; m_Initialized = true;
} }
//scene.AddCommand("HGGridServicesConnector", "linkk-region",
// "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
// "Link a hypergrid region", hgCommands.RunCommand);
//scene.AddCommand("HGGridServicesConnector", "unlinkk-region",
// "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
// "Unlink a hypergrid region", hgCommands.RunCommand);
//scene.AddCommand("HGGridServicesConnector", "linkk-mapping", "link-mapping [<x> <y>] <cr>",
// "Set local coordinate to map HG regions to", hgCommands.RunCommand);
} }
#endregion #endregion
@ -250,7 +265,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
// Try the foreign users home collection // Try the foreign users home collection
foreach (GridRegion r in m_knownRegions.Values) foreach (GridRegion r in m_knownRegions.Values)
if (r.RegionID == regionID) if (r.RegionID == regionID)
return m_knownRegions[regionID]; return r;
// Finally, try the normal route // Finally, try the normal route
return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID);
@ -271,8 +286,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
foreach (GridRegion r in m_knownRegions.Values) foreach (GridRegion r in m_knownRegions.Values)
{ {
if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
{
return r; return r;
} }
}
// Finally, try the normal route // Finally, try the normal route
return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y); return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y);
@ -338,8 +355,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle)
{ {
m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); m_HyperlinkRegions[regionInfo.RegionID] = regionInfo;
m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); m_HyperlinkHandles[regionInfo.RegionID] = regionHandle;
} }
private void RemoveHyperlinkRegion(UUID regionID) private void RemoveHyperlinkRegion(UUID regionID)
@ -350,8 +367,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle) private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle)
{ {
m_knownRegions.Add(userID, regionInfo); m_knownRegions[userID] = regionInfo;
m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); m_HyperlinkHandles[regionInfo.RegionID] = regionHandle;
} }
private void RemoveHyperlinkHomeRegion(UUID regionID) private void RemoveHyperlinkHomeRegion(UUID regionID)
@ -367,10 +384,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
} }
#endregion #endregion
#region Hyperlinks #region IHyperlinkService
private static Random random = new Random(); private static Random random = new Random();
public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc) public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc)
{ {
string host = "127.0.0.1"; string host = "127.0.0.1";
@ -417,10 +435,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return null; return null;
} }
// From the map search and secondlife://blah // From the map search and secondlife://blah
public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
{ {
int xloc = random.Next(0, Int16.MaxValue); int xloc = random.Next(0, Int16.MaxValue) * (int) Constants.RegionSize;
return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
} }
@ -447,13 +466,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
} }
// Finally, link it // Finally, link it
try if (!RegisterRegion(UUID.Zero, regInfo))
{ {
RegisterRegion(UUID.Zero, regInfo); m_log.Warn("[HGrid]: Unable to link region");
}
catch (Exception e)
{
m_log.Warn("[HGrid]: Unable to link region: " + e.Message);
return false; return false;
} }
@ -554,7 +569,227 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return true; return true;
} }
public GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor)
{
return TryLinkRegion((Scene)client.Scene, client, regionDescriptor);
}
public GridRegion GetHyperlinkRegion(ulong handle)
{
foreach (GridRegion r in m_HyperlinkRegions.Values)
if (r.RegionHandle == handle)
return r;
foreach (GridRegion r in m_knownRegions.Values)
if (r.RegionHandle == handle)
return r;
return null;
}
public ulong FindRegionHandle(ulong handle)
{
foreach (GridRegion r in m_HyperlinkRegions.Values)
if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID)))
return m_HyperlinkHandles[r.RegionID];
foreach (GridRegion r in m_knownRegions.Values)
if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID)))
return m_HyperlinkHandles[r.RegionID];
return handle;
}
public bool SendUserInformation(GridRegion regInfo, AgentCircuitData agentData)
{
CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID);
if ((IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) ||
(!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo)))
{
m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere");
// Set the position of the region on the remote grid
ulong realHandle = FindRegionHandle(regInfo.RegionHandle);
uint x = 0, y = 0;
Utils.LongToUInts(regInfo.RegionHandle, out x, out y);
GridRegion clonedRegion = new GridRegion(regInfo);
clonedRegion.RegionLocX = (int)x;
clonedRegion.RegionLocY = (int)y;
// Get the user's home region information
GridRegion home = m_aScene.GridService.GetRegionByUUID(m_aScene.RegionInfo.ScopeID, uinfo.UserProfile.HomeRegionID);
// Get the user's service URLs
string serverURI = "";
if (uinfo.UserProfile is ForeignUserProfileData)
serverURI = Util.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
string userServer = (serverURI == "") || (serverURI == null) ? LocalUserServerURI : serverURI;
string assetServer = Util.ServerURI(uinfo.UserProfile.UserAssetURI);
if ((assetServer == null) || (assetServer == ""))
assetServer = LocalAssetServerURI;
string inventoryServer = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
if ((inventoryServer == null) || (inventoryServer == ""))
inventoryServer = LocalInventoryServerURI;
if (!m_HypergridServiceConnector.InformRegionOfUser(clonedRegion, agentData, home, userServer, assetServer, inventoryServer))
{
m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
return false;
}
}
//if ((uinfo == null) || !IsGoingHome(uinfo, regInfo))
//{
// m_log.Info("[HGrid]: User seems to be going to foreign region.");
// if (!InformRegionOfUser(regInfo, agentData))
// {
// m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
// return false;
// }
//}
//else
// m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
// May need to change agent's name
if (IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null))
{
agentData.firstname = agentData.firstname + "." + agentData.lastname;
agentData.lastname = "@" + LocalUserServerURI.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI;
}
return true;
}
public void AdjustUserInformation(AgentCircuitData agentData)
{
CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID);
if ((uinfo != null) && (uinfo.UserProfile != null) &&
(IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData)))
{
//m_log.Debug("---------------> Local User!");
string[] parts = agentData.firstname.Split(new char[] { '.' });
if (parts.Length == 2)
{
agentData.firstname = parts[0];
agentData.lastname = parts[1];
}
}
//else
// m_log.Debug("---------------> Foreign User!");
}
// Check if a local user exists with the same UUID as the incoming foreign user
public bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome)
{
comingHome = false;
if (!m_aScene.SceneGridService.RegionLoginsEnabled)
return false;
CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
if (uinfo != null)
{
// uh-oh we have a potential intruder
if (uinfo.SessionID != sessionID)
// can't have a foreigner with a local UUID
return false;
else
// oh, so it's you! welcome back
comingHome = true;
}
// OK, user can come in
return true;
}
public void AcceptUser(ForeignUserProfileData user, GridRegion home)
{
m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user);
ulong realHandle = home.RegionHandle;
// Change the local coordinates
// X=0 on the map
home.RegionLocX = 0;
home.RegionLocY = random.Next(0, 10000) * (int)Constants.RegionSize;
AddHyperlinkHomeRegion(user.ID, home, realHandle);
DumpUserData(user);
DumpRegionData(home);
}
public bool IsLocalUser(UUID userID)
{
CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
return IsLocalUser(uinfo);
}
#endregion #endregion
#region IHyperlink Misc
protected bool IsComingHome(ForeignUserProfileData userData)
{
return (userData.UserServerURI == LocalUserServerURI);
}
// Is the user going back to the home region or the home grid?
protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo)
{
if (uinfo.UserProfile == null)
return false;
if (!(uinfo.UserProfile is ForeignUserProfileData))
// it's a home user, can't be outside to return home
return false;
// OK, it's a foreign user with a ForeignUserProfileData
// and is going back to exactly the home region.
// We can't check if it's going back to a non-home region
// of the home grid. That will be dealt with in the
// receiving end
return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID);
}
protected bool IsLocalUser(CachedUserInfo uinfo)
{
if (uinfo == null)
return false;
return !(uinfo.UserProfile is ForeignUserProfileData);
}
protected bool IsLocalRegion(ulong handle)
{
return m_LocalScenes.ContainsKey(handle);
}
private void DumpUserData(ForeignUserProfileData userData)
{
m_log.Info(" ------------ User Data Dump ----------");
m_log.Info(" >> Name: " + userData.FirstName + " " + userData.SurName);
m_log.Info(" >> HomeID: " + userData.HomeRegionID);
m_log.Info(" >> UserServer: " + userData.UserServerURI);
m_log.Info(" >> InvServer: " + userData.UserInventoryURI);
m_log.Info(" >> AssetServer: " + userData.UserAssetURI);
m_log.Info(" ------------ -------------- ----------");
}
private void DumpRegionData(GridRegion rinfo)
{
m_log.Info(" ------------ Region Data Dump ----------");
m_log.Info(" >> handle: " + rinfo.RegionHandle);
m_log.Info(" >> coords: " + rinfo.RegionLocX + ", " + rinfo.RegionLocY);
m_log.Info(" >> external host name: " + rinfo.ExternalHostName);
m_log.Info(" >> http port: " + rinfo.HttpPort);
m_log.Info(" >> external EP address: " + rinfo.ExternalEndPoint.Address);
m_log.Info(" >> external EP port: " + rinfo.ExternalEndPoint.Port);
m_log.Info(" ------------ -------------- ----------");
}
#endregion
} }
} }

View File

@ -31,6 +31,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Server.Base; using OpenSim.Server.Base;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
@ -47,7 +48,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
LogManager.GetLogger( LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType); MethodBase.GetCurrentMethod().DeclaringType);
private static LocalGridServicesConnector m_MainInstance;
private IGridService m_GridService; private IGridService m_GridService;
private Dictionary<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>();
private bool m_Enabled = false; private bool m_Enabled = false;
@ -58,6 +62,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public LocalGridServicesConnector(IConfigSource source) public LocalGridServicesConnector(IConfigSource source)
{ {
m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated"); m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated");
m_MainInstance = this;
InitialiseService(source); InitialiseService(source);
} }
@ -82,6 +87,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if (name == Name) if (name == Name)
{ {
InitialiseService(source); InitialiseService(source);
m_MainInstance = this;
m_Enabled = true; m_Enabled = true;
m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled"); m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled");
} }
@ -120,6 +126,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public void PostInitialise() public void PostInitialise()
{ {
if (m_MainInstance == this)
{
MainConsole.Instance.Commands.AddCommand("LocalGridConnector", false, "show neighbours",
"show neighbours",
"Shows the local regions' neighbours", NeighboursCommand);
}
} }
public void Close() public void Close()
@ -128,14 +140,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public void AddRegion(Scene scene) public void AddRegion(Scene scene)
{ {
if (!m_Enabled) if (m_Enabled)
return;
scene.RegisterModuleInterface<IGridService>(this); scene.RegisterModuleInterface<IGridService>(this);
if (m_MainInstance == this)
{
if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID))
m_log.ErrorFormat("[LOCAL GRID CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!");
else
m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene));
}
} }
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
{ {
if (m_MainInstance == this)
{
m_LocalCache[scene.RegionInfo.RegionID].Clear();
m_LocalCache.Remove(scene.RegionInfo.RegionID);
}
} }
public void RegionLoaded(Scene scene) public void RegionLoaded(Scene scene)
@ -158,7 +182,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
{ {
return m_GridService.GetNeighbours(scopeID, regionID); if (m_LocalCache.ContainsKey(regionID))
{
return m_LocalCache[regionID].GetNeighbours();
}
else
{
m_log.WarnFormat("[LOCAL GRID CONNECTOR]: GetNeighbours: Requested region {0} is not on this sim", regionID);
return new List<GridRegion>();
}
// Don't go to the DB
//return m_GridService.GetNeighbours(scopeID, regionID);
} }
public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
@ -187,5 +222,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
} }
#endregion #endregion
public void NeighboursCommand(string module, string[] cmdparams)
{
foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache)
{
m_log.InfoFormat("*** Neighbours of {0} {1} ***", kvp.Key, kvp.Value.RegionName);
List<GridRegion> regions = kvp.Value.GetNeighbours();
foreach (GridRegion r in regions)
m_log.InfoFormat(" {0} @ {1}={2}", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize);
}
}
} }
} }

View File

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using log4net;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
{
public class RegionCache
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private Dictionary<ulong, GridRegion> m_neighbours = new Dictionary<ulong, GridRegion>();
public string RegionName
{
get { return m_scene.RegionInfo.RegionName; }
}
public RegionCache(Scene s)
{
m_scene = s;
m_scene.EventManager.OnRegionUp += OnRegionUp;
}
private void OnRegionUp(GridRegion otherRegion)
{
m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}",
m_scene.RegionInfo.RegionName, otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY);
m_neighbours[otherRegion.RegionHandle] = otherRegion;
}
public void Clear()
{
m_scene.EventManager.OnRegionUp -= OnRegionUp;
m_neighbours.Clear();
}
public List<GridRegion> GetNeighbours()
{
return new List<GridRegion>(m_neighbours.Values);
}
}
}

View File

@ -104,6 +104,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public void PostInitialise() public void PostInitialise()
{ {
if (m_LocalGridService != null)
((ISharedRegionModule)m_LocalGridService).PostInitialise();
} }
public void Close() public void Close()
@ -112,14 +114,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public void AddRegion(Scene scene) public void AddRegion(Scene scene)
{ {
if (!m_Enabled) if (m_Enabled)
return;
scene.RegisterModuleInterface<IGridService>(this); scene.RegisterModuleInterface<IGridService>(this);
if (m_LocalGridService != null)
((ISharedRegionModule)m_LocalGridService).AddRegion(scene);
} }
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
{ {
if (m_LocalGridService != null)
((ISharedRegionModule)m_LocalGridService).RemoveRegion(scene);
} }
public void RegionLoaded(Scene scene) public void RegionLoaded(Scene scene)
@ -146,7 +151,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return false; return false;
} }
// Let's not override GetNeighbours -- let's get them all from the grid server // Let's override GetNeighbours completely -- never go to the grid server
// Neighbours are/should be cached locally
// For retrieval from the DB, caller should call GetRegionByPosition
public override List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
{
return m_LocalGridService.GetNeighbours(scopeID, regionID);
}
public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
{ {

View File

@ -42,6 +42,8 @@ using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Region.Framework.Scenes.Hypergrid;
using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
{ {
@ -59,6 +61,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
protected RegionToRegionClient m_regionClient; protected RegionToRegionClient m_regionClient;
protected IHyperlinkService m_hyperlinkService;
protected bool m_safemode; protected bool m_safemode;
protected IPAddress m_thisIP; protected IPAddress m_thisIP;
@ -134,7 +138,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
m_localBackend = new LocalInterregionComms(); m_localBackend = new LocalInterregionComms();
m_commsManager = scene.CommsManager; m_commsManager = scene.CommsManager;
m_aScene = scene; m_aScene = scene;
m_regionClient = new RegionToRegionClient(m_aScene); m_hyperlinkService = m_aScene.RequestModuleInterface<IHyperlinkService>();
m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService);
m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName); m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName);
} }
@ -161,7 +166,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing // else do the remote thing
if (!m_localBackend.IsLocalRegion(regionHandle)) if (!m_localBackend.IsLocalRegion(regionHandle))
{ {
RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if (regInfo != null) if (regInfo != null)
{ {
m_regionClient.SendUserInformation(regInfo, aCircuit); m_regionClient.SendUserInformation(regInfo, aCircuit);
@ -183,7 +190,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing // else do the remote thing
if (!m_localBackend.IsLocalRegion(regionHandle)) if (!m_localBackend.IsLocalRegion(regionHandle))
{ {
RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if (regInfo != null) if (regInfo != null)
{ {
return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData);
@ -204,7 +213,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing // else do the remote thing
if (!m_localBackend.IsLocalRegion(regionHandle)) if (!m_localBackend.IsLocalRegion(regionHandle))
{ {
RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if (regInfo != null) if (regInfo != null)
{ {
return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData);
@ -225,7 +236,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing // else do the remote thing
if (!m_localBackend.IsLocalRegion(regionHandle)) if (!m_localBackend.IsLocalRegion(regionHandle))
{ {
RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if (regInfo != null) if (regInfo != null)
{ {
return m_regionClient.DoRetrieveRootAgentCall(regInfo, id, out agent); return m_regionClient.DoRetrieveRootAgentCall(regInfo, id, out agent);
@ -257,7 +270,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing // else do the remote thing
if (!m_localBackend.IsLocalRegion(regionHandle)) if (!m_localBackend.IsLocalRegion(regionHandle))
{ {
RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if (regInfo != null) if (regInfo != null)
{ {
return m_regionClient.DoCloseAgentCall(regInfo, id); return m_regionClient.DoCloseAgentCall(regInfo, id);
@ -284,7 +299,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing // else do the remote thing
if (!m_localBackend.IsLocalRegion(regionHandle)) if (!m_localBackend.IsLocalRegion(regionHandle))
{ {
RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if (regInfo != null) if (regInfo != null)
{ {
return m_regionClient.DoCreateObjectCall( return m_regionClient.DoCreateObjectCall(
@ -776,16 +793,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
protected class RegionToRegionClient : RegionClient protected class RegionToRegionClient : RegionClient
{ {
Scene m_aScene = null; Scene m_aScene = null;
IHyperlinkService m_hyperlinkService;
public RegionToRegionClient(Scene s) public RegionToRegionClient(Scene s, IHyperlinkService hyperService)
{ {
m_aScene = s; m_aScene = s;
m_hyperlinkService = hyperService;
} }
public override ulong GetRegionHandle(ulong handle) public override ulong GetRegionHandle(ulong handle)
{ {
if (m_aScene.SceneGridService is HGSceneCommunicationService) if (m_aScene.SceneGridService is HGSceneCommunicationService)
return ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.FindRegionHandle(handle); {
if (m_hyperlinkService != null)
return m_hyperlinkService.FindRegionHandle(handle);
}
return handle; return handle;
} }
@ -793,29 +815,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
public override bool IsHyperlink(ulong handle) public override bool IsHyperlink(ulong handle)
{ {
if (m_aScene.SceneGridService is HGSceneCommunicationService) if (m_aScene.SceneGridService is HGSceneCommunicationService)
return ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.IsHyperlinkRegion(handle); {
if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null))
return true;
}
return false; return false;
} }
public override void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit) public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit)
{ {
try if (m_hyperlinkService != null)
{ m_hyperlinkService.SendUserInformation(regInfo, aCircuit);
if (m_aScene.SceneGridService is HGSceneCommunicationService)
{
((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.SendUserInformation(regInfo, aCircuit);
}
}
catch // Bad cast
{ }
} }
public override void AdjustUserInformation(AgentCircuitData aCircuit) public override void AdjustUserInformation(AgentCircuitData aCircuit)
{ {
if (m_aScene.SceneGridService is HGSceneCommunicationService) if (m_hyperlinkService != null)
((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.AdjustUserInformation(aCircuit); m_hyperlinkService.AdjustUserInformation(aCircuit);
} }
} }

View File

@ -525,7 +525,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
return true; return true;
} }
string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); if ((uinfo.UserProfile.UserInventoryURI == null) || (uinfo.UserProfile.UserInventoryURI == ""))
// this happens in standalone profiles, apparently
return true;
string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
string uri = m_LocalGridInventoryURI.TrimEnd('/'); string uri = m_LocalGridInventoryURI.TrimEnd('/');
if ((userInventoryServerURI == uri) || (userInventoryServerURI == "")) if ((userInventoryServerURI == uri) || (userInventoryServerURI == ""))
@ -544,7 +549,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
if ((uinfo == null) || (uinfo.UserProfile == null)) if ((uinfo == null) || (uinfo.UserProfile == null))
return invURI; return invURI;
string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
if ((userInventoryServerURI != null) && if ((userInventoryServerURI != null) &&
(userInventoryServerURI != "")) (userInventoryServerURI != ""))

View File

@ -37,6 +37,7 @@ using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using OpenSim.Server.Base; using OpenSim.Server.Base;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land
{ {
public class RemoteLandServicesConnector : public class RemoteLandServicesConnector :
@ -89,7 +90,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land
if (!m_Enabled) if (!m_Enabled)
return; return;
m_MapService = scene.CommsManager.GridService; m_GridService = scene.GridService;
m_LocalService.AddRegion(scene); m_LocalService.AddRegion(scene);
scene.RegisterModuleInterface<ILandService>(this); scene.RegisterModuleInterface<ILandService>(this);
} }

View File

@ -119,7 +119,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
#region INeighbourService #region INeighbourService
public bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) public GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
{ {
m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}", m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}",
thisRegion.RegionName, regionHandle, m_Scenes.Count); thisRegion.RegionName, regionHandle, m_Scenes.Count);
@ -132,7 +132,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
} }
} }
m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: region handle {0} not found", regionHandle); m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: region handle {0} not found", regionHandle);
return false; return null;
} }
#endregion INeighbourService #endregion INeighbourService

View File

@ -118,7 +118,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
if (!m_Enabled) if (!m_Enabled)
return; return;
m_MapService = scene.CommsManager.GridService;
m_LocalService.AddRegion(scene); m_LocalService.AddRegion(scene);
scene.RegisterModuleInterface<INeighbourService>(this); scene.RegisterModuleInterface<INeighbourService>(this);
} }
@ -134,16 +133,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
if (!m_Enabled) if (!m_Enabled)
return; return;
m_GridService = scene.GridService;
m_log.InfoFormat("[NEIGHBOUR CONNECTOR]: Enabled remote neighbours for region {0}", scene.RegionInfo.RegionName); m_log.InfoFormat("[NEIGHBOUR CONNECTOR]: Enabled remote neighbours for region {0}", scene.RegionInfo.RegionName);
} }
#region INeighbourService #region INeighbourService
public override bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) public override GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
{ {
if (m_LocalService.HelloNeighbour(regionHandle, thisRegion)) GridRegion region = m_LocalService.HelloNeighbour(regionHandle, thisRegion);
return true; if (region != null)
return region;
return base.HelloNeighbour(regionHandle, thisRegion); return base.HelloNeighbour(regionHandle, thisRegion);
} }

View File

@ -36,10 +36,12 @@ using OpenSim.Framework;
using OpenSim.Framework.Capabilities; using OpenSim.Framework.Capabilities;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using Caps=OpenSim.Framework.Capabilities.Caps; using Caps=OpenSim.Framework.Capabilities.Caps;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.World.Land namespace OpenSim.Region.CoreModules.World.Land
{ {
@ -1301,7 +1303,7 @@ namespace OpenSim.Region.CoreModules.World.Land
else else
{ {
// a parcel request for a parcel in another region. Ask the grid about the region // a parcel request for a parcel in another region. Ask the grid about the region
RegionInfo info = m_scene.CommsManager.GridService.RequestNeighbourInfo(regionID); GridRegion info = m_scene.GridService.GetRegionByUUID(UUID.Zero, regionID);
if (info != null) if (info != null)
parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y); parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y);
} }
@ -1359,7 +1361,8 @@ namespace OpenSim.Region.CoreModules.World.Land
} }
else else
{ {
extLandData.landData = m_scene.CommsManager.GridService.RequestLandData(extLandData.regionHandle, ILandService landService = m_scene.RequestModuleInterface<ILandService>();
extLandData.landData = landService.GetLandData(extLandData.regionHandle,
extLandData.x, extLandData.x,
extLandData.y); extLandData.y);
if (extLandData.landData == null) if (extLandData.landData == null)
@ -1373,20 +1376,27 @@ namespace OpenSim.Region.CoreModules.World.Land
if (data != null) // if we found some data, send it if (data != null) // if we found some data, send it
{ {
RegionInfo info; GridRegion info;
if (data.regionHandle == m_scene.RegionInfo.RegionHandle) if (data.regionHandle == m_scene.RegionInfo.RegionHandle)
{ {
info = m_scene.RegionInfo; info = new GridRegion(m_scene.RegionInfo);
} }
else else
{ {
// most likely still cached from building the extLandData entry // most likely still cached from building the extLandData entry
info = m_scene.CommsManager.GridService.RequestNeighbourInfo(data.regionHandle); uint x = 0, y = 0;
Utils.LongToUInts(data.regionHandle, out x, out y);
info = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
} }
// we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark. // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark.
m_log.DebugFormat("[LAND] got parcelinfo for parcel {0} in region {1}; sending...", m_log.DebugFormat("[LAND] got parcelinfo for parcel {0} in region {1}; sending...",
data.landData.Name, data.regionHandle); data.landData.Name, data.regionHandle);
remoteClient.SendParcelInfo(info, data.landData, parcelID, data.x, data.y); // HACK for now
RegionInfo r = new RegionInfo();
r.RegionName = info.RegionName;
r.RegionLocX = (uint)info.RegionLocX;
r.RegionLocY = (uint)info.RegionLocY;
remoteClient.SendParcelInfo(r, data.landData, parcelID, data.x, data.y);
} }
else else
m_log.Debug("[LAND] got no parcelinfo; not sending"); m_log.Debug("[LAND] got no parcelinfo; not sending");

View File

@ -33,6 +33,8 @@ using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Region.Framework.Scenes.Hypergrid;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.World.WorldMap namespace OpenSim.Region.CoreModules.World.WorldMap
{ {
@ -92,13 +94,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
} }
// try to fetch from GridServer // try to fetch from GridServer
List<RegionInfo> regionInfos = m_scene.SceneGridService.RequestNamedRegions(mapName, 20); List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(UUID.Zero, mapName, 20);
if (regionInfos == null) if (regionInfos == null)
{ {
m_log.Warn("[MAPSEARCHMODULE]: RequestNamedRegions returned null. Old gridserver?"); 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 // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region
regionInfos = new List<RegionInfo>(); regionInfos = new List<GridRegion>();
RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName); GridRegion info = m_scene.GridService.GetRegionByName(UUID.Zero, mapName);
if (info != null) regionInfos.Add(info); if (info != null) regionInfos.Add(info);
} }
@ -109,30 +111,34 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
if (mapName.Contains(".") && mapName.Contains(":")) if (mapName.Contains(".") && mapName.Contains(":"))
{ {
// It probably is a domain name. Try to link to it. // It probably is a domain name. Try to link to it.
RegionInfo regInfo; GridRegion regInfo;
Scene cScene = GetClientScene(remoteClient); Scene cScene = GetClientScene(remoteClient);
regInfo = HGHyperlink.TryLinkRegion(cScene, remoteClient, mapName); IHyperlinkService hyperService = cScene.RequestModuleInterface<IHyperlinkService>();
if (hyperService != null)
{
regInfo = hyperService.TryLinkRegion(remoteClient, mapName);
if (regInfo != null) if (regInfo != null)
regionInfos.Add(regInfo); regionInfos.Add(regInfo);
} }
} }
}
List<MapBlockData> blocks = new List<MapBlockData>(); List<MapBlockData> blocks = new List<MapBlockData>();
MapBlockData data; MapBlockData data;
if (regionInfos.Count > 0) if (regionInfos.Count > 0)
{ {
foreach (RegionInfo info in regionInfos) foreach (GridRegion info in regionInfos)
{ {
data = new MapBlockData(); data = new MapBlockData();
data.Agents = 0; data.Agents = 0;
data.Access = info.AccessLevel; data.Access = info.Access;
data.MapImageId = info.RegionSettings.TerrainImageID; data.MapImageId = info.TerrainImage;
data.Name = info.RegionName; data.Name = info.RegionName;
data.RegionFlags = 0; // TODO not used? data.RegionFlags = 0; // TODO not used?
data.WaterHeight = 0; // not used data.WaterHeight = 0; // not used
data.X = (ushort)info.RegionLocX; data.X = (ushort)(info.RegionLocX / Constants.RegionSize);
data.Y = (ushort)info.RegionLocY; data.Y = (ushort)(info.RegionLocY / Constants.RegionSize);
blocks.Add(data); blocks.Add(data);
} }
} }

View File

@ -48,6 +48,7 @@ using OpenSim.Region.Framework.Scenes;
using Caps=OpenSim.Framework.Capabilities.Caps; using Caps=OpenSim.Framework.Capabilities.Caps;
using OSDArray=OpenMetaverse.StructuredData.OSDArray; using OSDArray=OpenMetaverse.StructuredData.OSDArray;
using OSDMap=OpenMetaverse.StructuredData.OSDMap; using OSDMap=OpenMetaverse.StructuredData.OSDMap;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.World.WorldMap namespace OpenSim.Region.CoreModules.World.WorldMap
{ {
@ -232,10 +233,20 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
} }
if (lookup) if (lookup)
{ {
List<MapBlockData> mapBlocks; List<MapBlockData> mapBlocks = new List<MapBlockData>(); ;
mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks((int)m_scene.RegionInfo.RegionLocX - 8, (int)m_scene.RegionInfo.RegionLocY - 8, (int)m_scene.RegionInfo.RegionLocX + 8, (int)m_scene.RegionInfo.RegionLocY + 8); List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
avatarPresence.ControllingClient.SendMapBlock(mapBlocks,0); (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize,
(int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize,
(int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize,
(int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize);
foreach (GridRegion r in regions)
{
MapBlockData block = new MapBlockData();
MapBlockFromGridRegion(block, r);
mapBlocks.Add(block);
}
avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0);
lock (cachedMapBlocks) lock (cachedMapBlocks)
cachedMapBlocks = mapBlocks; cachedMapBlocks = mapBlocks;
@ -579,7 +590,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
} }
if (httpserver.Length == 0) if (httpserver.Length == 0)
{ {
RegionInfo mreg = m_scene.SceneGridService.RequestNeighbouringRegionInfo(regionhandle); uint x = 0, y = 0;
Utils.LongToUInts(regionhandle, out x, out y);
GridRegion mreg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
if (mreg != null) if (mreg != null)
{ {
@ -719,15 +732,25 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
{ {
List<MapBlockData> response = new List<MapBlockData>(); List<MapBlockData> response = new List<MapBlockData>();
// this should return one mapblock at most. But make sure: Look whether the one we requested is in there // this should return one mapblock at most.
List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); // (diva note: why?? in that case we should GetRegionByPosition)
if (mapBlocks != null) // But make sure: Look whether the one we requested is in there
List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
minX * (int)Constants.RegionSize,
maxX * (int)Constants.RegionSize,
minY * (int)Constants.RegionSize,
maxY * (int)Constants.RegionSize);
if (regions != null)
{ {
foreach (MapBlockData block in mapBlocks) foreach (GridRegion r in regions)
{ {
if (block.X == minX && block.Y == minY) if ((r.RegionLocX == minX * (int)Constants.RegionSize) &&
(r.RegionLocY == minY * (int)Constants.RegionSize))
{ {
// found it => add it to response // found it => add it to response
MapBlockData block = new MapBlockData();
MapBlockFromGridRegion(block, r);
response.Add(block); response.Add(block);
break; break;
} }
@ -754,10 +777,30 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
protected virtual void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) protected virtual void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
{ {
List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4); List<MapBlockData> mapBlocks = new List<MapBlockData>();
List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
(minX - 4) * (int)Constants.RegionSize,
(maxX + 4) * (int)Constants.RegionSize,
(minY - 4) * (int)Constants.RegionSize,
(maxY + 4) * (int)Constants.RegionSize);
foreach (GridRegion r in regions)
{
MapBlockData block = new MapBlockData();
MapBlockFromGridRegion(block, r);
mapBlocks.Add(block);
}
remoteClient.SendMapBlock(mapBlocks, flag); remoteClient.SendMapBlock(mapBlocks, flag);
} }
protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r)
{
block.Access = r.Access;
block.MapImageId = r.TerrainImage;
block.Name = r.RegionName;
block.X = (ushort)(r.RegionLocX / Constants.RegionSize);
block.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
}
public Hashtable OnHTTPGetMapImage(Hashtable keysvals) public Hashtable OnHTTPGetMapImage(Hashtable keysvals)
{ {
m_log.Debug("[WORLD MAP]: Sending map image jpeg"); m_log.Debug("[WORLD MAP]: Sending map image jpeg");
@ -874,31 +917,34 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
m_log.InfoFormat( m_log.InfoFormat(
"[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath); "[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath);
List<MapBlockData> mapBlocks = List<MapBlockData> mapBlocks = new List<MapBlockData>();
m_scene.CommsManager.GridService.RequestNeighbourMapBlocks( List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
(int)(m_scene.RegionInfo.RegionLocX - 9), (int)(m_scene.RegionInfo.RegionLocX - 9) * (int)Constants.RegionSize,
(int)(m_scene.RegionInfo.RegionLocY - 9), (int)(m_scene.RegionInfo.RegionLocX + 9) * (int)Constants.RegionSize,
(int)(m_scene.RegionInfo.RegionLocX + 9), (int)(m_scene.RegionInfo.RegionLocY - 9) * (int)Constants.RegionSize,
(int)(m_scene.RegionInfo.RegionLocY + 9)); (int)(m_scene.RegionInfo.RegionLocY + 9) * (int)Constants.RegionSize);
List<AssetBase> textures = new List<AssetBase>(); List<AssetBase> textures = new List<AssetBase>();
List<Image> bitImages = new List<Image>(); List<Image> bitImages = new List<Image>();
foreach (MapBlockData mapBlock in mapBlocks) foreach (GridRegion r in regions)
{ {
MapBlockData mapBlock = new MapBlockData();
MapBlockFromGridRegion(mapBlock, r);
AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
if (texAsset != null) if (texAsset != null)
{ {
textures.Add(texAsset); textures.Add(texAsset);
} }
else //else
{ //{
texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); // // WHAT?!? This doesn't seem right. Commenting (diva)
if (texAsset != null) // texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
{ // if (texAsset != null)
textures.Add(texAsset); // {
} // textures.Add(texAsset);
} // }
//}
} }
foreach (AssetBase asset in textures) foreach (AssetBase asset in textures)

View File

@ -32,6 +32,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Client; using OpenSim.Framework.Client;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using Caps=OpenSim.Framework.Capabilities.Caps; using Caps=OpenSim.Framework.Capabilities.Caps;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes namespace OpenSim.Region.Framework.Scenes
{ {
@ -305,6 +306,9 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void Attach(uint localID, UUID itemID, UUID avatarID); public delegate void Attach(uint localID, UUID itemID, UUID avatarID);
public event Attach OnAttach; public event Attach OnAttach;
public delegate void RegionUp(GridRegion region);
public event RegionUp OnRegionUp;
public class MoneyTransferArgs : EventArgs public class MoneyTransferArgs : EventArgs
{ {
public UUID sender; public UUID sender;
@ -446,6 +450,7 @@ namespace OpenSim.Region.Framework.Scenes
private EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = null; private EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = null;
private Attach handlerOnAttach = null; private Attach handlerOnAttach = null;
private RegionUp handlerOnRegionUp = null;
public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID) public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID)
{ {
@ -1035,5 +1040,13 @@ namespace OpenSim.Region.Framework.Scenes
if (handlerSetRootAgentScene != null) if (handlerSetRootAgentScene != null)
handlerSetRootAgentScene(agentID, scene); handlerSetRootAgentScene(agentID, scene);
} }
public void TriggerOnRegionUp(GridRegion otherRegion)
{
handlerOnRegionUp = OnRegionUp;
if (handlerOnRegionUp != null)
handlerOnRegionUp(otherRegion);
}
} }
} }

View File

@ -35,6 +35,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Communications.Clients; using OpenSim.Framework.Communications.Clients;
using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Services.Interfaces;
//using HyperGrid.Framework; //using HyperGrid.Framework;
//using OpenSim.Region.Communications.Hypergrid; //using OpenSim.Region.Communications.Hypergrid;
@ -50,6 +51,18 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>(); // private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
private Scene m_scene; private Scene m_scene;
private IHyperlinkService m_hyper;
IHyperlinkService HyperlinkService
{
get
{
if (m_hyper == null)
m_hyper = m_scene.RequestModuleInterface<IHyperlinkService>();
return m_hyper;
}
}
#endregion #endregion
#region Constructor #region Constructor
@ -79,22 +92,6 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
// return null; // return null;
// } // }
private bool IsLocalUser(UUID userID)
{
CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
if (uinfo != null)
{
if (HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile))
{
m_log.Debug("[HGScene]: Home user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
return true;
}
}
m_log.Debug("[HGScene]: Foreign user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
return false;
}
public AssetBase FetchAsset(string url, UUID assetID) public AssetBase FetchAsset(string url, UUID assetID)
{ {
@ -170,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
public void Get(UUID assetID, UUID ownerID) public void Get(UUID assetID, UUID ownerID)
{ {
if (!IsLocalUser(ownerID)) if (!HyperlinkService.IsLocalUser(ownerID))
{ {
// Get the item from the remote asset server onto the local AssetCache // Get the item from the remote asset server onto the local AssetCache
// and place an entry in m_assetMap // and place an entry in m_assetMap
@ -228,7 +225,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
public void Post(UUID assetID, UUID ownerID) public void Post(UUID assetID, UUID ownerID)
{ {
if (!IsLocalUser(ownerID)) if (!HyperlinkService.IsLocalUser(ownerID))
{ {
// Post the item from the local AssetCache onto the remote asset server // Post the item from the local AssetCache onto the remote asset server
// and place an entry in m_assetMap // and place an entry in m_assetMap

View File

@ -1,232 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Net;
using System.Reflection;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
namespace OpenSim.Region.Framework.Scenes.Hypergrid
{
public class HGHyperlink
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static Random random = new Random();
public static RegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc)
{
string host = "127.0.0.1";
string portstr;
string regionName = "";
uint port = 9000;
string[] parts = mapName.Split(new char[] { ':' });
if (parts.Length >= 1)
{
host = parts[0];
}
if (parts.Length >= 2)
{
portstr = parts[1];
if (!UInt32.TryParse(portstr, out port))
regionName = parts[1];
}
// always take the last one
if (parts.Length >= 3)
{
regionName = parts[2];
}
// Sanity check. Don't ever link to this sim.
IPAddress ipaddr = null;
try
{
ipaddr = Util.GetHostFromDNS(host);
}
catch { }
if ((ipaddr != null) &&
!((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port)))
{
RegionInfo regInfo;
bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo);
if (success)
{
regInfo.RegionName = mapName;
return regInfo;
}
}
return null;
}
public static RegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
{
uint xloc = (uint)(random.Next(0, Int16.MaxValue));
return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
}
public static bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc,
string externalRegionName, uint externalPort, string externalHostName, out RegionInfo regInfo)
{
m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
regInfo = new RegionInfo();
regInfo.RegionName = externalRegionName;
regInfo.HttpPort = externalPort;
regInfo.ExternalHostName = externalHostName;
regInfo.RegionLocX = xloc;
regInfo.RegionLocY = yloc;
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: " + e.Message);
return false;
}
regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString();
// Finally, link it
try
{
m_scene.CommsManager.GridService.RegisterRegion(regInfo);
}
catch (Exception e)
{
m_log.Warn("[HGrid]: Unable to link region: " + e.Message);
return false;
}
uint x, y;
if (!Check4096(m_scene, regInfo, out x, out y))
{
m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
if (client != null)
client.SendAlertMessage("Region is too far (" + x + ", " + y + ")");
m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")");
return false;
}
if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y))
{
m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
if (client != null)
client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")");
m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")");
return false;
}
m_log.Debug("[HGrid]: link region succeeded");
return true;
}
public static bool TryUnlinkRegion(Scene m_scene, string mapName)
{
RegionInfo regInfo = null;
if (mapName.Contains(":"))
{
string host = "127.0.0.1";
//string portstr;
//string regionName = "";
uint port = 9000;
string[] parts = mapName.Split(new char[] { ':' });
if (parts.Length >= 1)
{
host = parts[0];
}
// if (parts.Length >= 2)
// {
// portstr = parts[1];
// if (!UInt32.TryParse(portstr, out port))
// regionName = parts[1];
// }
// always take the last one
// if (parts.Length >= 3)
// {
// regionName = parts[2];
// }
regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(host, port);
}
else
{
regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(mapName);
}
if (regInfo != null)
{
return m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
}
else
{
m_log.InfoFormat("[HGrid]: Region {0} not found", mapName);
return false;
}
}
/// <summary>
/// Cope with this viewer limitation.
/// </summary>
/// <param name="regInfo"></param>
/// <returns></returns>
public static bool Check4096(Scene m_scene, RegionInfo regInfo, out uint x, out uint y)
{
ulong realHandle;
if (UInt64.TryParse(regInfo.regionSecret, out realHandle))
{
Utils.LongToUInts(realHandle, out x, out y);
x = x / Constants.RegionSize;
y = y / Constants.RegionSize;
if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) ||
(Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096))
{
return false;
}
return true;
}
else
{
m_scene.CommsManager.GridService.RegisterRegion(regInfo);
m_log.Debug("[HGrid]: Gnomes. Region deregistered.");
x = y = 0;
return false;
}
}
public static bool CheckCoords(uint thisx, uint thisy, uint x, uint y)
{
if ((thisx == x) && (thisy == y))
return false;
return true;
}
}
}

View File

@ -29,6 +29,7 @@ using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using TPFlags = OpenSim.Framework.Constants.TeleportFlags; using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes.Hypergrid namespace OpenSim.Region.Framework.Scenes.Hypergrid
{ {
@ -50,7 +51,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
if (UserProfile != null) if (UserProfile != null)
{ {
RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion); GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
//if (regionInfo != null) //if (regionInfo != null)
//{ //{
// UserProfile.HomeRegionID = regionInfo.RegionID; // UserProfile.HomeRegionID = regionInfo.RegionID;

View File

@ -38,6 +38,8 @@ using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Capabilities; using OpenSim.Framework.Capabilities;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes.Hypergrid namespace OpenSim.Region.Framework.Scenes.Hypergrid
{ {
@ -45,11 +47,19 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public readonly IHyperlink m_hg; private IHyperlinkService m_hg;
IHyperlinkService HyperlinkService
public HGSceneCommunicationService(CommunicationsManager commsMan, IHyperlink hg) : base(commsMan) {
get
{
if (m_hg == null)
m_hg = m_scene.RequestModuleInterface<IHyperlinkService>();
return m_hg;
}
}
public HGSceneCommunicationService(CommunicationsManager commsMan) : base(commsMan)
{ {
m_hg = hg;
} }
@ -112,7 +122,10 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
} }
else else
{ {
RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
if (reg != null) if (reg != null)
{ {
@ -125,13 +138,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
/// Hypergrid mod start /// Hypergrid mod start
/// ///
/// ///
bool isHyperLink = m_hg.IsHyperlinkRegion(reg.RegionHandle); bool isHyperLink = (HyperlinkService.GetHyperlinkRegion(reg.RegionHandle) != null);
bool isHomeUser = true; bool isHomeUser = true;
ulong realHandle = regionHandle; ulong realHandle = regionHandle;
CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID); CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID);
if (uinfo != null) if (uinfo != null)
{ {
isHomeUser = HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile); isHomeUser = HyperlinkService.IsLocalUser(uinfo.UserProfile.ID);
realHandle = m_hg.FindRegionHandle(regionHandle); realHandle = m_hg.FindRegionHandle(regionHandle);
m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString()); m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString());
} }

View File

@ -49,6 +49,7 @@ using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using Timer=System.Timers.Timer; using Timer=System.Timers.Timer;
using TPFlags = OpenSim.Framework.Constants.TeleportFlags; using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes namespace OpenSim.Region.Framework.Scenes
{ {
@ -193,6 +194,26 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
protected IGridService m_GridService = null;
public IGridService GridService
{
get
{
if (m_GridService == null)
{
m_GridService = RequestModuleInterface<IGridService>();
if (m_GridService == null)
{
throw new Exception("No IGridService available. This could happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. Please also check that you have the correct version of your inventory service dll. Sometimes old versions of this dll will still exist. Do a clean checkout and re-create the opensim.ini from the opensim.ini.example.");
}
}
return m_GridService;
}
}
protected IXMLRPC m_xmlrpcModule; protected IXMLRPC m_xmlrpcModule;
protected IWorldComm m_worldCommModule; protected IWorldComm m_worldCommModule;
protected IAvatarFactory m_AvatarFactory; protected IAvatarFactory m_AvatarFactory;
@ -566,10 +587,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
/// <summary> /// <summary>
/// Another region is up. Gets called from Grid Comms: /// Another region is up.
/// (OGS1 -> LocalBackEnd -> RegionListened -> SceneCommunicationService)
/// We have to tell all our ScenePresences about it, and add it to the
/// neighbor list.
/// ///
/// We only add it to the neighbor list if it's within 1 region from here. /// We only add it to the neighbor list if it's within 1 region from here.
/// Agents may have draw distance values that cross two regions though, so /// Agents may have draw distance values that cross two regions though, so
@ -578,47 +596,30 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
/// <param name="otherRegion">RegionInfo handle for the new region.</param> /// <param name="otherRegion">RegionInfo handle for the new region.</param>
/// <returns>True after all operations complete, throws exceptions otherwise.</returns> /// <returns>True after all operations complete, throws exceptions otherwise.</returns>
public override bool OtherRegionUp(RegionInfo otherRegion) public override void OtherRegionUp(GridRegion otherRegion)
{ {
m_log.InfoFormat("[SCENE]: Region {0} up in coords {1}-{2}", otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); uint xcell = (uint)((int)otherRegion.RegionLocX / (int)Constants.RegionSize);
uint ycell = (uint)((int)otherRegion.RegionLocY / (int)Constants.RegionSize);
m_log.InfoFormat("[SCENE]: (on region {0}): Region {1} up in coords {2}-{3}",
RegionInfo.RegionName, otherRegion.RegionName, xcell, ycell);
if (RegionInfo.RegionHandle != otherRegion.RegionHandle) if (RegionInfo.RegionHandle != otherRegion.RegionHandle)
{ {
for (int i = 0; i < m_neighbours.Count; i++)
{
// The purpose of this loop is to re-update the known neighbors
// when another region comes up on top of another one.
// The latest region in that location ends up in the
// 'known neighbors list'
// Additionally, the commFailTF property gets reset to false.
if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle)
{
lock (m_neighbours)
{
m_neighbours[i] = otherRegion;
}
}
}
// If the value isn't in the neighbours, add it.
// If the RegionInfo isn't exact but is for the same XY World location,
// then the above loop will fix that.
if (!(CheckNeighborRegion(otherRegion)))
{
lock (m_neighbours)
{
m_neighbours.Add(otherRegion);
//m_log.Info("[UP]: " + otherRegion.RegionHandle.ToString());
}
}
// If these are cast to INT because long + negative values + abs returns invalid data // If these are cast to INT because long + negative values + abs returns invalid data
int resultX = Math.Abs((int)otherRegion.RegionLocX - (int)RegionInfo.RegionLocX); int resultX = Math.Abs((int)xcell - (int)RegionInfo.RegionLocX);
int resultY = Math.Abs((int)otherRegion.RegionLocY - (int)RegionInfo.RegionLocY); int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY);
if (resultX <= 1 && resultY <= 1) if (resultX <= 1 && resultY <= 1)
{ {
// Let the grid service module know, so this can be cached
m_eventManager.TriggerOnRegionUp(otherRegion);
RegionInfo regInfo = new RegionInfo(xcell, ycell, otherRegion.InternalEndPoint, otherRegion.ExternalHostName);
regInfo.RegionID = otherRegion.RegionID;
regInfo.RegionName = otherRegion.RegionName;
regInfo.ScopeID = otherRegion.ScopeID;
regInfo.ExternalHostName = otherRegion.ExternalHostName;
try try
{ {
ForEachScenePresence(delegate(ScenePresence agent) ForEachScenePresence(delegate(ScenePresence agent)
@ -632,7 +633,7 @@ namespace OpenSim.Region.Framework.Scenes
List<ulong> old = new List<ulong>(); List<ulong> old = new List<ulong>();
old.Add(otherRegion.RegionHandle); old.Add(otherRegion.RegionHandle);
agent.DropOldNeighbours(old); agent.DropOldNeighbours(old);
InformClientOfNeighbor(agent, otherRegion); InformClientOfNeighbor(agent, regInfo);
} }
} }
); );
@ -643,6 +644,7 @@ namespace OpenSim.Region.Framework.Scenes
// This shouldn't happen too often anymore. // This shouldn't happen too often anymore.
m_log.Error("[SCENE]: Couldn't inform client of regionup because we got a null reference exception"); m_log.Error("[SCENE]: Couldn't inform client of regionup because we got a null reference exception");
} }
} }
else else
{ {
@ -651,7 +653,6 @@ namespace OpenSim.Region.Framework.Scenes
otherRegion.RegionLocY.ToString() + ")"); otherRegion.RegionLocY.ToString() + ")");
} }
} }
return true;
} }
public void AddNeighborRegion(RegionInfo region) public void AddNeighborRegion(RegionInfo region)
@ -683,9 +684,10 @@ namespace OpenSim.Region.Framework.Scenes
} }
// Alias IncomingHelloNeighbour OtherRegionUp, for now // Alias IncomingHelloNeighbour OtherRegionUp, for now
public bool IncomingHelloNeighbour(RegionInfo neighbour) public GridRegion IncomingHelloNeighbour(RegionInfo neighbour)
{ {
return OtherRegionUp(neighbour); OtherRegionUp(new GridRegion(neighbour));
return new GridRegion(RegionInfo);
} }
/// <summary> /// <summary>
@ -1336,24 +1338,31 @@ namespace OpenSim.Region.Framework.Scenes
RegisterCommsEvents(); RegisterCommsEvents();
// These two 'commands' *must be* next to each other or sim rebooting fails. // These two 'commands' *must be* next to each other or sim rebooting fails.
m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo); //m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo);
GridRegion region = new GridRegion(RegionInfo);
bool success = GridService.RegisterRegion(RegionInfo.ScopeID, region);
if (!success)
throw new Exception("Can't register with grid");
m_sceneGridService.SetScene(this);
m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);
Dictionary<string, string> dGridSettings = m_sceneGridService.GetGridSettings(); //Dictionary<string, string> dGridSettings = m_sceneGridService.GetGridSettings();
if (dGridSettings.ContainsKey("allow_forceful_banlines")) //if (dGridSettings.ContainsKey("allow_forceful_banlines"))
{ //{
if (dGridSettings["allow_forceful_banlines"] != "TRUE") // if (dGridSettings["allow_forceful_banlines"] != "TRUE")
{ // {
m_log.Info("[GRID]: Grid is disabling forceful parcel banlists"); // m_log.Info("[GRID]: Grid is disabling forceful parcel banlists");
EventManager.TriggerSetAllowForcefulBan(false); // EventManager.TriggerSetAllowForcefulBan(false);
} // }
else // else
{ // {
m_log.Info("[GRID]: Grid is allowing forceful parcel banlists"); // m_log.Info("[GRID]: Grid is allowing forceful parcel banlists");
EventManager.TriggerSetAllowForcefulBan(true); // EventManager.TriggerSetAllowForcefulBan(true);
} // }
} //}
} }
/// <summary> /// <summary>
@ -2717,10 +2726,12 @@ namespace OpenSim.Region.Framework.Scenes
UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId);
if (UserProfile != null) if (UserProfile != null)
{ {
RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegionID); GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
if (regionInfo == null) if (regionInfo == null)
{ {
regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion); uint x = 0, y = 0;
Utils.LongToUInts(UserProfile.HomeRegion, out x, out y);
regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if (regionInfo != null) // home region can be away temporarily, too if (regionInfo != null) // home region can be away temporarily, too
{ {
UserProfile.HomeRegionID = regionInfo.RegionID; UserProfile.HomeRegionID = regionInfo.RegionID;
@ -3074,7 +3085,7 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGridService.OnExpectUser += HandleNewUserConnection; m_sceneGridService.OnExpectUser += HandleNewUserConnection;
m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing; m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing;
m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent; m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent;
m_sceneGridService.OnRegionUp += OtherRegionUp; //m_eventManager.OnRegionUp += OtherRegionUp;
//m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup; m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup;
//m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
@ -3102,7 +3113,7 @@ namespace OpenSim.Region.Framework.Scenes
//m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup; m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup;
//m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
m_sceneGridService.OnRegionUp -= OtherRegionUp; //m_eventManager.OnRegionUp -= OtherRegionUp;
m_sceneGridService.OnExpectUser -= HandleNewUserConnection; m_sceneGridService.OnExpectUser -= HandleNewUserConnection;
m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing; m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing;
m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent;
@ -3111,7 +3122,11 @@ namespace OpenSim.Region.Framework.Scenes
if (m_interregionCommsIn != null) if (m_interregionCommsIn != null)
m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
// this does nothing; should be removed
m_sceneGridService.Close(); m_sceneGridService.Close();
if (!GridService.DeregisterRegion(m_regInfo.RegionID))
m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", m_regInfo.RegionName);
} }
/// <summary> /// <summary>
@ -3556,30 +3571,6 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours); m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours);
} }
/// <summary>
/// Requests information about this region from gridcomms
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
{
return m_sceneGridService.RequestNeighbouringRegionInfo(regionHandle);
}
/// <summary>
/// Requests textures for map from minimum region to maximum region in world cordinates
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="minX"></param>
/// <param name="minY"></param>
/// <param name="maxX"></param>
/// <param name="maxY"></param>
public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
{
m_log.DebugFormat("[MAPBLOCK]: {0}-{1}, {2}-{3}", minX, minY, maxX, maxY);
m_sceneGridService.RequestMapBlocks(remoteClient, minX, minY, maxX, maxY);
}
/// <summary> /// <summary>
/// Tries to teleport agent to other region. /// Tries to teleport agent to other region.
/// </summary> /// </summary>
@ -3591,7 +3582,7 @@ namespace OpenSim.Region.Framework.Scenes
public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position, public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position,
Vector3 lookat, uint teleportFlags) Vector3 lookat, uint teleportFlags)
{ {
RegionInfo regionInfo = m_sceneGridService.RequestClosestRegion(regionName); GridRegion regionInfo = GridService.GetRegionByName(UUID.Zero, regionName);
if (regionInfo == null) if (regionInfo == null)
{ {
// can't find the region: Tell viewer and abort // can't find the region: Tell viewer and abort
@ -3680,7 +3671,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="position"></param> /// <param name="position"></param>
public void RequestTeleportLandmark(IClientAPI remoteClient, UUID regionID, Vector3 position) public void RequestTeleportLandmark(IClientAPI remoteClient, UUID regionID, Vector3 position)
{ {
RegionInfo info = CommsManager.GridService.RequestNeighbourInfo(regionID); GridRegion info = GridService.GetRegionByUUID(UUID.Zero, regionID);
if (info == null) if (info == null)
{ {
@ -3864,10 +3855,6 @@ namespace OpenSim.Region.Framework.Scenes
return LandChannel.GetLandObject((int)x, (int)y).landData; return LandChannel.GetLandObject((int)x, (int)y).landData;
} }
public RegionInfo RequestClosestRegion(string name)
{
return m_sceneGridService.RequestClosestRegion(name);
}
#endregion #endregion
@ -4178,14 +4165,18 @@ namespace OpenSim.Region.Framework.Scenes
public void RegionHandleRequest(IClientAPI client, UUID regionID) public void RegionHandleRequest(IClientAPI client, UUID regionID)
{ {
RegionInfo info; ulong handle = 0;
if (regionID == RegionInfo.RegionID) if (regionID == RegionInfo.RegionID)
info = RegionInfo; handle = RegionInfo.RegionHandle;
else else
info = CommsManager.GridService.RequestNeighbourInfo(regionID); {
GridRegion r = GridService.GetRegionByUUID(UUID.Zero, regionID);
if (r != null)
handle = r.RegionHandle;
}
if (info != null) if (handle != 0)
client.SendRegionHandle(regionID, info.RegionHandle); client.SendRegionHandle(regionID, handle);
} }
public void TerrainUnAcked(IClientAPI client, int patchX, int patchY) public void TerrainUnAcked(IClientAPI client, int patchX, int patchY)

View File

@ -36,6 +36,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes namespace OpenSim.Region.Framework.Scenes
{ {
@ -227,7 +228,7 @@ namespace OpenSim.Region.Framework.Scenes
return false; return false;
} }
public abstract bool OtherRegionUp(RegionInfo thisRegion); public abstract void OtherRegionUp(GridRegion otherRegion);
public virtual string GetSimulatorVersion() public virtual string GetSimulatorVersion()
{ {

View File

@ -41,6 +41,7 @@ using OpenSim.Framework.Capabilities;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using OSD = OpenMetaverse.StructuredData.OSD; using OSD = OpenMetaverse.StructuredData.OSD;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes namespace OpenSim.Region.Framework.Scenes
{ {
@ -58,6 +59,7 @@ namespace OpenSim.Region.Framework.Scenes
protected CommunicationsManager m_commsProvider; protected CommunicationsManager m_commsProvider;
protected IInterregionCommsOut m_interregionCommsOut; protected IInterregionCommsOut m_interregionCommsOut;
protected RegionInfo m_regionInfo; protected RegionInfo m_regionInfo;
protected Scene m_scene;
protected RegionCommsListener regionCommsHost; protected RegionCommsListener regionCommsHost;
@ -91,10 +93,10 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
public event PrimCrossing OnPrimCrossingIntoRegion; public event PrimCrossing OnPrimCrossingIntoRegion;
/// <summary> ///// <summary>
/// A New Region is up and available ///// A New Region is up and available
/// </summary> ///// </summary>
public event RegionUp OnRegionUp; //public event RegionUp OnRegionUp;
/// <summary> /// <summary>
/// We have a child agent for this avatar and we're getting a status update about it /// We have a child agent for this avatar and we're getting a status update about it
@ -117,7 +119,7 @@ namespace OpenSim.Region.Framework.Scenes
private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim; private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim;
private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection; private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
private RegionUp handlerRegionUp = null; // OnRegionUp; //private RegionUp handlerRegionUp = null; // OnRegionUp;
private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate; private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate;
//private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar; //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar;
private LogOffUser handlerLogOffUser = null; private LogOffUser handlerLogOffUser = null;
@ -131,6 +133,13 @@ namespace OpenSim.Region.Framework.Scenes
m_agentsInTransit = new List<UUID>(); m_agentsInTransit = new List<UUID>();
} }
public void SetScene(Scene s)
{
m_scene = s;
m_regionInfo = s.RegionInfo;
m_interregionCommsOut = m_scene.RequestModuleInterface<IInterregionCommsOut>();
}
/// <summary> /// <summary>
/// Register a region with the grid /// Register a region with the grid
/// </summary> /// </summary>
@ -138,40 +147,30 @@ namespace OpenSim.Region.Framework.Scenes
/// <exception cref="System.Exception">Thrown if region registration fails.</exception> /// <exception cref="System.Exception">Thrown if region registration fails.</exception>
public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos) public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos)
{ {
m_interregionCommsOut = comms_out; //m_interregionCommsOut = comms_out;
m_regionInfo = regionInfos; //m_regionInfo = regionInfos;
m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName; //m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName;
regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo); //regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo);
if (regionCommsHost != null) //if (regionCommsHost != null)
{ //{
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString()); // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString());
regionCommsHost.debugRegionName = regionInfos.RegionName; // regionCommsHost.debugRegionName = regionInfos.RegionName;
regionCommsHost.OnExpectPrim += IncomingPrimCrossing; // regionCommsHost.OnExpectPrim += IncomingPrimCrossing;
regionCommsHost.OnExpectUser += NewUserConnection; // regionCommsHost.OnExpectUser += NewUserConnection;
regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; // regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
regionCommsHost.OnCloseAgentConnection += CloseConnection; // regionCommsHost.OnCloseAgentConnection += CloseConnection;
regionCommsHost.OnRegionUp += newRegionUp; // regionCommsHost.OnRegionUp += newRegionUp;
regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; // regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
regionCommsHost.OnLogOffUser += GridLogOffUser; // regionCommsHost.OnLogOffUser += GridLogOffUser;
regionCommsHost.OnGetLandData += FetchLandData; // regionCommsHost.OnGetLandData += FetchLandData;
} //}
else //else
{ //{
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null"); // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null");
} //}
}
/// <summary>
/// Returns a region with the name closest to string provided
/// </summary>
/// <param name="name">Partial Region Name for matching</param>
/// <returns>Region Information for the region</returns>
public RegionInfo RequestClosestRegion(string name)
{
return m_commsProvider.GridService.RequestClosestRegion(name);
} }
/// <summary> /// <summary>
@ -180,30 +179,31 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
public void Close() public void Close()
{ {
if (regionCommsHost != null)
{
regionCommsHost.OnLogOffUser -= GridLogOffUser;
regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate;
regionCommsHost.OnRegionUp -= newRegionUp;
regionCommsHost.OnExpectUser -= NewUserConnection;
regionCommsHost.OnExpectPrim -= IncomingPrimCrossing;
regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing;
regionCommsHost.OnCloseAgentConnection -= CloseConnection;
regionCommsHost.OnGetLandData -= FetchLandData;
try //if (regionCommsHost != null)
{ //{
m_commsProvider.GridService.DeregisterRegion(m_regionInfo); // regionCommsHost.OnLogOffUser -= GridLogOffUser;
} // regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate;
catch (Exception e) // regionCommsHost.OnRegionUp -= newRegionUp;
{ // regionCommsHost.OnExpectUser -= NewUserConnection;
m_log.ErrorFormat( // regionCommsHost.OnExpectPrim -= IncomingPrimCrossing;
"[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing", // regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing;
m_regionInfo.RegionName, e); // regionCommsHost.OnCloseAgentConnection -= CloseConnection;
} // regionCommsHost.OnGetLandData -= FetchLandData;
regionCommsHost = null; // try
} // {
// m_commsProvider.GridService.DeregisterRegion(m_regionInfo);
// }
// catch (Exception e)
// {
// m_log.ErrorFormat(
// "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing",
// m_regionInfo.RegionName, e);
// }
// regionCommsHost = null;
//}
} }
#region CommsManager Event handlers #region CommsManager Event handlers
@ -238,22 +238,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
/// <summary>
/// A New Region is now available. Inform the scene that there is a new region available.
/// </summary>
/// <param name="region">Information about the new region that is available</param>
/// <returns>True if the event was handled</returns>
protected bool newRegionUp(RegionInfo region)
{
handlerRegionUp = OnRegionUp;
if (handlerRegionUp != null)
{
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: newRegionUp Fired for User:" + region.RegionName);
handlerRegionUp(region);
}
return true;
}
/// <summary> /// <summary>
/// Inform the scene that we've got an update about a child agent that we have /// Inform the scene that we've got an update about a child agent that we have
/// </summary> /// </summary>
@ -337,7 +321,7 @@ namespace OpenSim.Region.Framework.Scenes
#region Inform Client of Neighbours #region Inform Client of Neighbours
private delegate void InformClientOfNeighbourDelegate( private delegate void InformClientOfNeighbourDelegate(
ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg, IPEndPoint endPoint, bool newAgent); ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
private void InformClientOfNeighbourCompleted(IAsyncResult iar) private void InformClientOfNeighbourCompleted(IAsyncResult iar)
{ {
@ -355,7 +339,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="a"></param> /// <param name="a"></param>
/// <param name="regionHandle"></param> /// <param name="regionHandle"></param>
/// <param name="endPoint"></param> /// <param name="endPoint"></param>
private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg, private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, GridRegion reg,
IPEndPoint endPoint, bool newAgent) IPEndPoint endPoint, bool newAgent)
{ {
// Let's wait just a little to give time to originating regions to catch up with closing child agents // Let's wait just a little to give time to originating regions to catch up with closing child agents
@ -373,7 +357,6 @@ namespace OpenSim.Region.Framework.Scenes
string reason = String.Empty; string reason = String.Empty;
//bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a);
bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason); bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason);
@ -407,17 +390,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
public void RequestNeighbors(RegionInfo region) public List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
{
// List<SimpleRegionInfo> neighbours =
m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
//IPEndPoint blah = new IPEndPoint();
//blah.Address = region.RemotingAddress;
//blah.Port = region.RemotingPort;
}
public List<SimpleRegionInfo> RequestNeighbors(Scene pScene, uint pRegionLocX, uint pRegionLocY)
{ {
Border[] northBorders = pScene.NorthBorders.ToArray(); Border[] northBorders = pScene.NorthBorders.ToArray();
Border[] southBorders = pScene.SouthBorders.ToArray(); Border[] southBorders = pScene.SouthBorders.ToArray();
@ -427,50 +400,34 @@ namespace OpenSim.Region.Framework.Scenes
// Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement. // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement.
if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
{ {
return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY); return m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
} }
else else
{ {
Vector2 extent = Vector2.Zero; Vector2 extent = Vector2.Zero;
for (int i=0;i<eastBorders.Length;i++) for (int i = 0; i < eastBorders.Length; i++)
{ {
extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X; extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
} }
for (int i=0;i<northBorders.Length;i++) for (int i = 0; i < northBorders.Length; i++)
{ {
extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y; extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
} }
List<SimpleRegionInfo> neighbourList = new List<SimpleRegionInfo>();
// Loss of fraction on purpose // Loss of fraction on purpose
extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1; extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1; extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
int startX = (int) pRegionLocX - 1; int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize;
int startY = (int) pRegionLocY - 1; int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize;
int endX = (int) pRegionLocX + (int)extent.X; int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize;
int endY = (int) pRegionLocY + (int)extent.Y; int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize;
for (int i=startX;i<endX;i++) List<GridRegion> neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
{ neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
for (int j=startY;j<endY;j++)
{
// Skip CurrentRegion
if (i == (int)pRegionLocX && j == (int)pRegionLocY)
continue;
ulong regionHandle = Util.UIntsToLong((uint)(i * Constants.RegionSize), return neighbours;
(uint)(j * Constants.RegionSize));
RegionInfo neighborreg = m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
if (neighborreg != null)
{
neighbourList.Add(neighborreg);
}
}
}
return neighbourList;
//SimpleRegionInfo regionData = m_commsProvider.GridService.RequestNeighbourInfo() //SimpleRegionInfo regionData = m_commsProvider.GridService.RequestNeighbourInfo()
//return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY); //return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY);
} }
@ -482,30 +439,29 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours) public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
{ {
List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>(); //List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
List<GridRegion> neighbours = new List<GridRegion>();
//m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); ////m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
for (int i = 0; i < lstneighbours.Count; i++) //for (int i = 0; i < lstneighbours.Count; i++)
{ //{
// We don't want to keep sending to regions that consistently fail on comms. // // We don't want to keep sending to regions that consistently fail on comms.
if (!(lstneighbours[i].commFailTF)) // if (!(lstneighbours[i].commFailTF))
{ // {
neighbours.Add(new SimpleRegionInfo(lstneighbours[i])); // neighbours.Add(new SimpleRegionInfo(lstneighbours[i]));
} // }
} //}
// we're going to be using the above code once neighbour cache is correct. Currently it doesn't appear to be // we're going to be using the above code once neighbour cache is correct. Currently it doesn't appear to be
// So we're temporarily going back to the old method of grabbing it from the Grid Server Every time :/ // So we're temporarily going back to the old method of grabbing it from the Grid Server Every time :/
if (m_regionInfo != null) if (m_regionInfo != null)
{ {
neighbours = neighbours = RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
RequestNeighbors(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
} }
else else
{ {
m_log.Debug("[ENABLENEIGHBOURCHILDAGENTS]: m_regionInfo was null in EnableNeighbourChildAgents, is this a NPC?"); m_log.Debug("[ENABLENEIGHBOURCHILDAGENTS]: m_regionInfo was null in EnableNeighbourChildAgents, is this a NPC?");
} }
/// We need to find the difference between the new regions where there are no child agents /// We need to find the difference between the new regions where there are no child agents
/// and the regions where there are already child agents. We only send notification to the former. /// and the regions where there are already child agents. We only send notification to the former.
List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region
@ -547,7 +503,8 @@ namespace OpenSim.Region.Framework.Scenes
/// Create the necessary child agents /// Create the necessary child agents
List<AgentCircuitData> cagents = new List<AgentCircuitData>(); List<AgentCircuitData> cagents = new List<AgentCircuitData>();
foreach (SimpleRegionInfo neighbour in neighbours) //foreach (SimpleRegionInfo neighbour in neighbours)
foreach (GridRegion neighbour in neighbours)
{ {
if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle) if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
{ {
@ -588,7 +545,7 @@ namespace OpenSim.Region.Framework.Scenes
bool newAgent = false; bool newAgent = false;
int count = 0; int count = 0;
foreach (SimpleRegionInfo neighbour in neighbours) foreach (GridRegion neighbour in neighbours)
{ {
// Don't do it if there's already an agent in that region // Don't do it if there's already an agent in that region
if (newRegions.Contains(neighbour.RegionHandle)) if (newRegions.Contains(neighbour.RegionHandle))
@ -641,7 +598,7 @@ namespace OpenSim.Region.Framework.Scenes
/// This informs a single neighboring region about agent "avatar". /// This informs a single neighboring region about agent "avatar".
/// Calls an asynchronous method to do so.. so it doesn't lag the sim. /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
/// </summary> /// </summary>
public void InformNeighborChildAgent(ScenePresence avatar, SimpleRegionInfo region) public void InformNeighborChildAgent(ScenePresence avatar, GridRegion region)
{ {
AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
agent.BaseFolder = UUID.Zero; agent.BaseFolder = UUID.Zero;
@ -672,61 +629,63 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="regionhandle"></param> /// <param name="regionhandle"></param>
private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle) private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle)
{ {
m_log.Info("[INTERGRID]: Starting to inform neighbors that I'm here"); uint x = 0, y = 0;
//RegionUpData regiondata = new RegionUpData(region.RegionLocX, region.RegionLocY, region.ExternalHostName, region.InternalEndPoint.Port); Utils.LongToUInts(regionhandle, out x, out y);
//bool regionAccepted = GridRegion neighbour = null;
// m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region), regionhandle);
//bool regionAccepted = m_interregionCommsOut.SendHelloNeighbour(regionhandle, region);
bool regionAccepted = false;
if (neighbourService != null) if (neighbourService != null)
regionAccepted = neighbourService.HelloNeighbour(regionhandle, region); neighbour = neighbourService.HelloNeighbour(regionhandle, region);
else else
m_log.DebugFormat("[SCS]: No neighbour service provided for informing neigbhours of this region"); m_log.DebugFormat("[SCS]: No neighbour service provided for informing neigbhours of this region");
if (regionAccepted) if (neighbour != null)
{ {
m_log.Info("[INTERGRID]: Completed informing neighbors that I'm here"); m_log.DebugFormat("[INTERGRID]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize);
handlerRegionUp = OnRegionUp; m_scene.EventManager.TriggerOnRegionUp(neighbour);
// yes, we're notifying ourselves.
if (handlerRegionUp != null)
handlerRegionUp(region);
} }
else else
{ {
m_log.Warn("[INTERGRID]: Failed to inform neighbors that I'm here."); m_log.WarnFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize);
} }
} }
/// <summary>
/// Called by scene when region is initialized (not always when it's listening for agents)
/// This is an inter-region message that informs the surrounding neighbors that the sim is up.
/// </summary>
public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region) public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region)
{ {
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
for (int x = (int)region.RegionLocX - 1; x <= region.RegionLocX + 1; x++)
List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>(); for (int y = (int)region.RegionLocY - 1; y <= region.RegionLocY + 1; y++)
// This stays uncached because we don't already know about our neighbors at this point. if (!((x == region.RegionLocX) && (y == region.RegionLocY))) // skip this region
neighbours = m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
if (neighbours != null)
{
for (int i = 0; i < neighbours.Count; i++)
{ {
ulong handle = Utils.UIntsToLong((uint)x * Constants.RegionSize, (uint)y * Constants.RegionSize);
InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync; InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
d.BeginInvoke(neighbourService, region, neighbours[i].RegionHandle, d.BeginInvoke(neighbourService, region, handle,
InformNeighborsThatRegionisUpCompleted, InformNeighborsThatRegionisUpCompleted,
d); d);
} }
}
//List<GridRegion> neighbours = new List<GridRegion>();
//// This stays uncached because we don't already know about our neighbors at this point.
//neighbours = m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
//if (neighbours != null)
//{
// for (int i = 0; i < neighbours.Count; i++)
// {
// InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
// d.BeginInvoke(neighbourService, region, neighbours[i].RegionHandle,
// InformNeighborsThatRegionisUpCompleted,
// d);
// }
//}
//bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region)); //bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region));
} }
public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle); public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle);
/// <summary> /// <summary>
@ -822,41 +781,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
/// <summary>
/// Helper function to request neighbors from grid-comms
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public virtual RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
{
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionHandle.ToString());
return m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
}
/// <summary>
/// Helper function to request neighbors from grid-comms
/// </summary>
/// <param name="regionID"></param>
/// <returns></returns>
public virtual RegionInfo RequestNeighbouringRegionInfo(UUID regionID)
{
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionID);
return m_commsProvider.GridService.RequestNeighbourInfo(regionID);
}
/// <summary>
/// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
/// </summary>
/// <param name="minX"></param>
/// <param name="minY"></param>
/// <param name="maxX"></param>
/// <param name="maxY"></param>
public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
{
List<MapBlockData> mapBlocks;
mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4);
remoteClient.SendMapBlock(mapBlocks, 0);
}
/// <summary> /// <summary>
/// Try to teleport an agent to a new region. /// Try to teleport an agent to a new region.
@ -921,7 +845,10 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
if (reg != null) if (reg != null)
{ {
m_log.DebugFormat( m_log.DebugFormat(
@ -1228,10 +1155,10 @@ namespace OpenSim.Region.Framework.Scenes
return false; return false;
} }
private List<ulong> NeighbourHandles(List<SimpleRegionInfo> neighbours) private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
{ {
List<ulong> handles = new List<ulong>(); List<ulong> handles = new List<ulong>();
foreach (SimpleRegionInfo reg in neighbours) foreach (GridRegion reg in neighbours)
{ {
handles.Add(reg.RegionHandle); handles.Add(reg.RegionHandle);
} }
@ -1482,7 +1409,10 @@ namespace OpenSim.Region.Framework.Scenes
m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
SimpleRegionInfo neighbourRegion = RequestNeighbouringRegionInfo(neighbourHandle);
int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
if (neighbourRegion != null && agent.ValidateAttachments()) if (neighbourRegion != null && agent.ValidateAttachments())
{ {
pos = pos + (agent.Velocity); pos = pos + (agent.Velocity);
@ -1609,11 +1539,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
public Dictionary<string, string> GetGridSettings()
{
return m_commsProvider.GridService.GetGridSettings();
}
public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
{ {
m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat); m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat);
@ -1650,19 +1575,14 @@ namespace OpenSim.Region.Framework.Scenes
return m_commsProvider.GetUserFriendList(friendlistowner); return m_commsProvider.GetUserFriendList(friendlistowner);
} }
public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
{
return m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
}
public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
{ {
return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query); return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
} }
public List<RegionInfo> RequestNamedRegions(string name, int maxNumber) public List<GridRegion> RequestNamedRegions(string name, int maxNumber)
{ {
return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber); return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber);
} }
//private void Dump(string msg, List<ulong> handles) //private void Dump(string msg, List<ulong> handles)

View File

@ -36,6 +36,7 @@ using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes.Types; using OpenSim.Region.Framework.Scenes.Types;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes namespace OpenSim.Region.Framework.Scenes
{ {
@ -2934,8 +2935,9 @@ namespace OpenSim.Region.Framework.Scenes
else if (dir > 3 && dir < 7) // Heading Sout else if (dir > 3 && dir < 7) // Heading Sout
neighboury--; neighboury--;
ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); int x = (int)(neighbourx * Constants.RegionSize);
SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); int y = (int)(neighboury * Constants.RegionSize);
GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y);
if (neighbourRegion == null) if (neighbourRegion == null)
{ {

View File

@ -29,6 +29,7 @@ using System;
using NUnit.Framework; using NUnit.Framework;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes.Tests namespace OpenSim.Region.Framework.Scenes.Tests
{ {
@ -65,7 +66,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override bool OtherRegionUp(RegionInfo thisRegion) public override void OtherRegionUp(GridRegion otherRegion)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -50,6 +50,9 @@ using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
using OpenSim.Region.ScriptEngine.Shared.ScriptBase; using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
using OpenSim.Region.ScriptEngine.Interfaces; using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using AssetLandmark = OpenSim.Framework.AssetLandmark; using AssetLandmark = OpenSim.Framework.AssetLandmark;
@ -5226,12 +5229,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
List<SimpleRegionInfo> neighbors = World.CommsManager.GridService.RequestNeighbours(World.RegionInfo.RegionLocX, World.RegionInfo.RegionLocY); List<GridRegion> neighbors = World.GridService.GetNeighbours(World.RegionInfo.ScopeID, World.RegionInfo.RegionID);
uint neighborX = World.RegionInfo.RegionLocX + (uint)dir.x; uint neighborX = World.RegionInfo.RegionLocX + (uint)dir.x;
uint neighborY = World.RegionInfo.RegionLocY + (uint)dir.y; uint neighborY = World.RegionInfo.RegionLocY + (uint)dir.y;
foreach (SimpleRegionInfo sri in neighbors) foreach (GridRegion sri in neighbors)
{ {
if (sri.RegionLocX == neighborX && sri.RegionLocY == neighborY) if (sri.RegionLocX == neighborX && sri.RegionLocY == neighborY)
return 0; return 0;
@ -8181,7 +8184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
string reply = String.Empty; string reply = String.Empty;
RegionInfo info = m_ScriptEngine.World.RequestClosestRegion(simulator); GridRegion info = m_ScriptEngine.World.GridService.GetRegionByName(m_ScriptEngine.World.RegionInfo.ScopeID, simulator);
switch (data) switch (data)
{ {
@ -8208,7 +8211,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ConditionalScriptSleep(1000); ConditionalScriptSleep(1000);
return UUID.Zero.ToString(); return UUID.Zero.ToString();
} }
int access = info.RegionSettings.Maturity; int access = info.Maturity;
if (access == 0) if (access == 0)
reply = "PG"; reply = "PG";
else if (access == 1) else if (access == 1)

View File

@ -48,6 +48,8 @@ using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
using OpenSim.Region.ScriptEngine.Interfaces; using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
using TPFlags = OpenSim.Framework.Constants.TeleportFlags; using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
@ -599,8 +601,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (regionName.Contains(".") && regionName.Contains(":")) if (regionName.Contains(".") && regionName.Contains(":"))
{ {
// Try to link the region // Try to link the region
RegionInfo regInfo = HGHyperlink.TryLinkRegion(World, IHyperlinkService hyperService = World.RequestModuleInterface<IHyperlinkService>();
presence.ControllingClient, if (hyperService != null)
{
GridRegion regInfo = hyperService.TryLinkRegion(presence.ControllingClient,
regionName); regionName);
// Get the region name // Get the region name
if (regInfo != null) if (regInfo != null)
@ -612,6 +616,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// Might need to ping the client here in case of failure?? // Might need to ping the client here in case of failure??
} }
} }
}
presence.ControllingClient.SendTeleportLocationStart(); presence.ControllingClient.SendTeleportLocationStart();
World.RequestTeleportLocation(presence.ControllingClient, regionName, World.RequestTeleportLocation(presence.ControllingClient, regionName,
new Vector3((float)position.x, (float)position.y, (float)position.z), new Vector3((float)position.x, (float)position.y, (float)position.z),

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace OpenSim.Server.Base
{
public class ProtocolVersions
{
/// <value>
/// This is the external protocol versions. It is separate from the OpenSimulator project version.
///
/// These version numbers should be increased by 1 every time a code
/// change in the Service.Connectors and Server.Handlers, espectively,
/// makes the previous OpenSimulator revision incompatible
/// with the new revision.
///
/// Changes which are compatible with an older revision (e.g. older revisions experience degraded functionality
/// but not outright failure) do not need a version number increment.
///
/// Having this version number allows the grid service to reject connections from regions running a version
/// of the code that is too old.
///
/// </value>
// The range of acceptable servers for client-side connectors
public readonly static int ClientProtocolVersionMin = 0;
public readonly static int ClientProtocolVersionMax = 0;
// The range of acceptable clients in server-side handlers
public readonly static int ServerProtocolVersionMin = 0;
public readonly static int ServerProtocolVersionMax = 0;
}
}

View File

@ -118,6 +118,24 @@ namespace OpenSim.Server.Handlers.Grid
else else
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region"); m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region");
int versionNumberMin = 0, versionNumberMax = 0;
if (request.ContainsKey("VERSIONMIN"))
Int32.TryParse(request["VERSIONMIN"], out versionNumberMin);
else
m_log.WarnFormat("[GRID HANDLER]: no minimum protocol version in request to register region");
if (request.ContainsKey("VERSIONMAX"))
Int32.TryParse(request["VERSIONMAX"], out versionNumberMax);
else
m_log.WarnFormat("[GRID HANDLER]: no maximum protocol version in request to register region");
// Check the protocol version
if ((versionNumberMin > ProtocolVersions.ServerProtocolVersionMax && versionNumberMax < ProtocolVersions.ServerProtocolVersionMax))
{
// Can't do, there is no overlap in the acceptable ranges
return FailureResult();
}
Dictionary<string, object> rinfoData = new Dictionary<string, object>(); Dictionary<string, object> rinfoData = new Dictionary<string, object>();
foreach (KeyValuePair<string, string> kvp in request) foreach (KeyValuePair<string, string> kvp in request)
rinfoData[kvp.Key] = kvp.Value; rinfoData[kvp.Key] = kvp.Value;

View File

@ -36,7 +36,9 @@ using OpenSim.Server.Base;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Server.Handlers.Base; using OpenSim.Server.Handlers.Base;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenMetaverse;
using log4net; using log4net;
using Nwc.XmlRpc; using Nwc.XmlRpc;
@ -48,12 +50,26 @@ namespace OpenSim.Server.Handlers.Grid
LogManager.GetLogger( LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType); MethodBase.GetCurrentMethod().DeclaringType);
private List<SimpleRegionInfo> m_RegionsOnSim = new List<SimpleRegionInfo>(); private List<GridRegion> m_RegionsOnSim = new List<GridRegion>();
private IHyperlinkService m_HyperlinkService;
public HypergridServiceInConnector(IConfigSource config, IHttpServer server) : public HypergridServiceInConnector(IConfigSource config, IHttpServer server, IHyperlinkService hyperService) :
base(config, server) base(config, server)
{ {
server.AddXmlRPCHandler("linkk_region", LinkRegionRequest, false); m_HyperlinkService = hyperService;
server.AddXmlRPCHandler("link_region", LinkRegionRequest, false);
server.AddXmlRPCHandler("expect_hg_user", ExpectHGUser, false);
}
public void AddRegion(GridRegion rinfo)
{
m_RegionsOnSim.Add(rinfo);
}
public void RemoveRegion(GridRegion rinfo)
{
if (m_RegionsOnSim.Contains(rinfo))
m_RegionsOnSim.Remove(rinfo);
} }
/// <summary> /// <summary>
@ -70,8 +86,8 @@ namespace OpenSim.Server.Handlers.Grid
m_log.DebugFormat("[HGrid]: Hyperlink request"); m_log.DebugFormat("[HGrid]: Hyperlink request");
SimpleRegionInfo regInfo = null; GridRegion regInfo = null;
foreach (SimpleRegionInfo r in m_RegionsOnSim) foreach (GridRegion r in m_RegionsOnSim)
{ {
if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower())) if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower()))
{ {
@ -85,9 +101,9 @@ namespace OpenSim.Server.Handlers.Grid
Hashtable hash = new Hashtable(); Hashtable hash = new Hashtable();
hash["uuid"] = regInfo.RegionID.ToString(); hash["uuid"] = regInfo.RegionID.ToString();
m_log.Debug(">> Here " + regInfo.RegionID);
hash["handle"] = regInfo.RegionHandle.ToString(); hash["handle"] = regInfo.RegionHandle.ToString();
//m_log.Debug(">> Here " + regInfo.RegionHandle); hash["region_image"] = regInfo.TerrainImage.ToString();
//hash["region_image"] = regInfo.RegionSettings.TerrainImageID.ToString();
hash["region_name"] = regInfo.RegionName; hash["region_name"] = regInfo.RegionName;
hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
//m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port); //m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port);
@ -98,15 +114,95 @@ namespace OpenSim.Server.Handlers.Grid
return response; return response;
} }
public void AddRegion(SimpleRegionInfo rinfo) /// <summary>
/// Received from other HGrid nodes when a user wants to teleport here. This call allows
/// the region to prepare for direct communication from the client. Sends back an empty
/// xmlrpc response on completion.
/// This is somewhat similar to OGS1's ExpectUser, but with the additional task of
/// registering the user in the local user cache.
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse ExpectHGUser(XmlRpcRequest request, IPEndPoint remoteClient)
{ {
m_RegionsOnSim.Add(rinfo); Hashtable requestData = (Hashtable)request.Params[0];
ForeignUserProfileData userData = new ForeignUserProfileData();
userData.FirstName = (string)requestData["firstname"];
userData.SurName = (string)requestData["lastname"];
userData.ID = new UUID((string)requestData["agent_id"]);
UUID sessionID = new UUID((string)requestData["session_id"]);
userData.HomeLocation = new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]),
(float)Convert.ToDecimal((string)requestData["startpos_y"]),
(float)Convert.ToDecimal((string)requestData["startpos_z"]));
userData.UserServerURI = (string)requestData["userserver_id"];
userData.UserAssetURI = (string)requestData["assetserver_id"];
userData.UserInventoryURI = (string)requestData["inventoryserver_id"];
m_log.DebugFormat("[HGrid]: Prepare for connection from {0} {1} (@{2}) UUID={3}",
userData.FirstName, userData.SurName, userData.UserServerURI, userData.ID);
ulong userRegionHandle = 0;
int userhomeinternalport = 0;
if (requestData.ContainsKey("region_uuid"))
{
UUID uuid = UUID.Zero;
UUID.TryParse((string)requestData["region_uuid"], out uuid);
userData.HomeRegionID = uuid;
userRegionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
userData.UserHomeAddress = (string)requestData["home_address"];
userData.UserHomePort = (string)requestData["home_port"];
userhomeinternalport = Convert.ToInt32((string)requestData["internal_port"]);
m_log.Debug("[HGrid]: home_address: " + userData.UserHomeAddress +
"; home_port: " + userData.UserHomePort);
}
else
m_log.WarnFormat("[HGrid]: User has no home region information");
XmlRpcResponse resp = new XmlRpcResponse();
// Let's check if someone is trying to get in with a stolen local identity.
// The need for this test is a consequence of not having truly global names :-/
bool comingHome = false;
if (m_HyperlinkService.CheckUserAtEntry(userData.ID, sessionID, out comingHome) == false)
{
m_log.WarnFormat("[HGrid]: Access denied to foreign user.");
Hashtable respdata = new Hashtable();
respdata["success"] = "FALSE";
respdata["reason"] = "Foreign user has the same ID as a local user, or logins disabled.";
resp.Value = respdata;
return resp;
} }
public void RemoveRegion(SimpleRegionInfo rinfo) // Finally, everything looks ok
//m_log.Debug("XXX---- EVERYTHING OK ---XXX");
if (!comingHome)
{ {
if (m_RegionsOnSim.Contains(rinfo)) // We don't do this if the user is coming to the home grid
m_RegionsOnSim.Remove(rinfo); GridRegion home = new GridRegion();
home.RegionID = userData.HomeRegionID;
home.ExternalHostName = userData.UserHomeAddress;
home.HttpPort = Convert.ToUInt32(userData.UserHomePort);
uint x = 0, y = 0;
Utils.LongToUInts(userRegionHandle, out x, out y);
home.RegionLocX = (int)x;
home.RegionLocY = (int)y;
home.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)userhomeinternalport);
m_HyperlinkService.AcceptUser(userData, home);
} }
// else the user is coming to a non-home region of the home grid
// We simply drop this user information altogether
Hashtable respdata2 = new Hashtable();
respdata2["success"] = "TRUE";
resp.Value = respdata2;
return resp;
}
} }
} }

View File

@ -36,6 +36,7 @@ using OpenSim.Server.Handlers.Base;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers.HttpServer;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
@ -148,11 +149,14 @@ namespace OpenSim.Server.Handlers.Neighbour
} }
// Finally! // Finally!
bool success = m_NeighbourService.HelloNeighbour(regionhandle, aRegion); GridRegion thisRegion = m_NeighbourService.HelloNeighbour(regionhandle, aRegion);
OSDMap resp = new OSDMap(1); OSDMap resp = new OSDMap(1);
resp["success"] = OSD.FromBoolean(success); if (thisRegion != null)
resp["success"] = OSD.FromBoolean(true);
else
resp["success"] = OSD.FromBoolean(false);
httpResponse.StatusCode = (int)HttpStatusCode.OK; httpResponse.StatusCode = (int)HttpStatusCode.OK;

View File

@ -94,7 +94,8 @@ namespace OpenSim.Services.Connectors
sendData[kvp.Key] = (string)kvp.Value; sendData[kvp.Key] = (string)kvp.Value;
sendData["SCOPEID"] = scopeID.ToString(); sendData["SCOPEID"] = scopeID.ToString();
sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
sendData["METHOD"] = "register"; sendData["METHOD"] = "register";
string reqString = ServerUtils.BuildQueryString(sendData); string reqString = ServerUtils.BuildQueryString(sendData);

View File

@ -66,7 +66,7 @@ namespace OpenSim.Services.Connectors.Grid
IList paramList = new ArrayList(); IList paramList = new ArrayList();
paramList.Add(hash); paramList.Add(hash);
XmlRpcRequest request = new XmlRpcRequest("linkk_region", paramList); XmlRpcRequest request = new XmlRpcRequest("link_region", paramList);
string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
m_log.Debug("[HGrid]: Linking to " + uri); m_log.Debug("[HGrid]: Linking to " + uri);
XmlRpcResponse response = request.Send(uri, 10000); XmlRpcResponse response = request.Send(uri, 10000);
@ -82,6 +82,7 @@ namespace OpenSim.Services.Connectors.Grid
try try
{ {
UUID.TryParse((string)hash["uuid"], out uuid); UUID.TryParse((string)hash["uuid"], out uuid);
m_log.Debug(">> HERE, uuid: " + uuid);
info.RegionID = uuid; info.RegionID = uuid;
if ((string)hash["handle"] != null) if ((string)hash["handle"] != null)
{ {
@ -148,5 +149,94 @@ namespace OpenSim.Services.Connectors.Grid
} }
} }
public bool InformRegionOfUser(GridRegion regInfo, AgentCircuitData agentData, GridRegion home, string userServer, string assetServer, string inventoryServer)
{
string capsPath = agentData.CapsPath;
Hashtable loginParams = new Hashtable();
loginParams["session_id"] = agentData.SessionID.ToString();
loginParams["firstname"] = agentData.firstname;
loginParams["lastname"] = agentData.lastname;
loginParams["agent_id"] = agentData.AgentID.ToString();
loginParams["circuit_code"] = agentData.circuitcode.ToString();
loginParams["startpos_x"] = agentData.startpos.X.ToString();
loginParams["startpos_y"] = agentData.startpos.Y.ToString();
loginParams["startpos_z"] = agentData.startpos.Z.ToString();
loginParams["caps_path"] = capsPath;
if (home != null)
{
loginParams["region_uuid"] = home.RegionID.ToString();
loginParams["regionhandle"] = home.RegionHandle.ToString();
loginParams["home_address"] = home.ExternalHostName;
loginParams["home_port"] = home.HttpPort.ToString();
loginParams["internal_port"] = home.InternalEndPoint.Port.ToString();
m_log.Debug(" --------- Home -------");
m_log.Debug(" >> " + loginParams["home_address"] + " <<");
m_log.Debug(" >> " + loginParams["region_uuid"] + " <<");
m_log.Debug(" >> " + loginParams["regionhandle"] + " <<");
m_log.Debug(" >> " + loginParams["home_port"] + " <<");
m_log.Debug(" --------- ------------ -------");
}
else
m_log.WarnFormat("[HGrid]: Home region not found for {0} {1}", agentData.firstname, agentData.lastname);
loginParams["userserver_id"] = userServer;
loginParams["assetserver_id"] = assetServer;
loginParams["inventoryserver_id"] = inventoryServer;
ArrayList SendParams = new ArrayList();
SendParams.Add(loginParams);
// Send
string uri = "http://" + regInfo.ExternalHostName + ":" + regInfo.HttpPort + "/";
//m_log.Debug("XXX uri: " + uri);
XmlRpcRequest request = new XmlRpcRequest("expect_hg_user", SendParams);
XmlRpcResponse reply;
try
{
reply = request.Send(uri, 6000);
}
catch (Exception e)
{
m_log.Warn("[HGrid]: Failed to notify region about user. Reason: " + e.Message);
return false;
}
if (!reply.IsFault)
{
bool responseSuccess = true;
if (reply.Value != null)
{
Hashtable resp = (Hashtable)reply.Value;
if (resp.ContainsKey("success"))
{
if ((string)resp["success"] == "FALSE")
{
responseSuccess = false;
}
}
}
if (responseSuccess)
{
m_log.Info("[HGrid]: Successfully informed remote region about user " + agentData.AgentID);
return true;
}
else
{
m_log.ErrorFormat("[HGrid]: Region responded that it is not available to receive clients");
return false;
}
}
else
{
m_log.ErrorFormat("[HGrid]: XmlRpc request to region failed with message {0}, code {1} ", reply.FaultString, reply.FaultCode);
return false;
}
}
} }
} }

View File

@ -38,6 +38,7 @@ using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using OpenMetaverse; using OpenMetaverse;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Services.Connectors namespace OpenSim.Services.Connectors
{ {
@ -47,20 +48,20 @@ namespace OpenSim.Services.Connectors
LogManager.GetLogger( LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType); MethodBase.GetCurrentMethod().DeclaringType);
protected IGridServices m_MapService = null; protected IGridService m_GridService = null;
public LandServicesConnector() public LandServicesConnector()
{ {
} }
public LandServicesConnector(IGridServices gridServices) public LandServicesConnector(IGridService gridServices)
{ {
Initialise(gridServices); Initialise(gridServices);
} }
public virtual void Initialise(IGridServices gridServices) public virtual void Initialise(IGridService gridServices)
{ {
m_MapService = gridServices; m_GridService = gridServices;
} }
public virtual LandData GetLandData(ulong regionHandle, uint x, uint y) public virtual LandData GetLandData(ulong regionHandle, uint x, uint y)
@ -76,7 +77,9 @@ namespace OpenSim.Services.Connectors
try try
{ {
RegionInfo info = m_MapService.RequestNeighbourInfo(regionHandle); uint xpos = 0, ypos = 0;
Utils.LongToUInts(regionHandle, out xpos, out ypos);
GridRegion info = m_GridService.GetRegionByPosition(UUID.Zero, (int)xpos, (int)ypos);
if (info != null) // just to be sure if (info != null) // just to be sure
{ {
XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); XmlRpcRequest request = new XmlRpcRequest("land_data", paramList);

View File

@ -41,6 +41,8 @@ using OpenSim.Services.Interfaces;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Services.Connectors namespace OpenSim.Services.Connectors
{ {
public class NeighbourServicesConnector : INeighbourService public class NeighbourServicesConnector : INeighbourService
@ -49,37 +51,39 @@ namespace OpenSim.Services.Connectors
LogManager.GetLogger( LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType); MethodBase.GetCurrentMethod().DeclaringType);
protected IGridServices m_MapService = null; protected IGridService m_GridService = null;
public NeighbourServicesConnector() public NeighbourServicesConnector()
{ {
} }
public NeighbourServicesConnector(IGridServices gridServices) public NeighbourServicesConnector(IGridService gridServices)
{ {
Initialise(gridServices); Initialise(gridServices);
} }
public virtual void Initialise(IGridServices gridServices) public virtual void Initialise(IGridService gridServices)
{ {
m_MapService = gridServices; m_GridService = gridServices;
} }
public virtual bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) public virtual GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
{ {
RegionInfo regInfo = m_MapService.RequestNeighbourInfo(regionHandle); uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion regInfo = m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if ((regInfo != null) && if ((regInfo != null) &&
// Don't remote-call this instance; that's a startup hickup // Don't remote-call this instance; that's a startup hickup
!((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.HttpPort))) !((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.HttpPort)))
{ {
return DoHelloNeighbourCall(regInfo, thisRegion); DoHelloNeighbourCall(regInfo, thisRegion);
} }
//else //else
// m_log.Warn("[REST COMMS]: Region not found " + regionHandle); // m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
return false; return regInfo;
} }
public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) public bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion)
{ {
string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/";
//m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri);

View File

@ -122,9 +122,6 @@ namespace OpenSim.Services.Interfaces
} }
protected string m_regionName = String.Empty; protected string m_regionName = String.Empty;
protected bool Allow_Alternate_Ports;
public bool m_allow_alternate_ports;
protected string m_externalHostName; protected string m_externalHostName;
protected IPEndPoint m_internalEndPoint; protected IPEndPoint m_internalEndPoint;
@ -146,6 +143,11 @@ namespace OpenSim.Services.Interfaces
public UUID RegionID = UUID.Zero; public UUID RegionID = UUID.Zero;
public UUID ScopeID = UUID.Zero; public UUID ScopeID = UUID.Zero;
public UUID TerrainImage = UUID.Zero;
public byte Access;
public int Maturity;
public string RegionSecret;
public GridRegion() public GridRegion()
{ {
} }
@ -183,11 +185,29 @@ namespace OpenSim.Services.Interfaces
m_internalEndPoint = ConvertFrom.InternalEndPoint; m_internalEndPoint = ConvertFrom.InternalEndPoint;
m_externalHostName = ConvertFrom.ExternalHostName; m_externalHostName = ConvertFrom.ExternalHostName;
m_httpPort = ConvertFrom.HttpPort; m_httpPort = ConvertFrom.HttpPort;
m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports; RegionID = ConvertFrom.RegionID;
RegionID = UUID.Zero;
ServerURI = ConvertFrom.ServerURI; ServerURI = ConvertFrom.ServerURI;
TerrainImage = ConvertFrom.RegionSettings.TerrainImageID;
Access = ConvertFrom.AccessLevel;
Maturity = ConvertFrom.RegionSettings.Maturity;
RegionSecret = ConvertFrom.regionSecret;
} }
public GridRegion(GridRegion ConvertFrom)
{
m_regionName = ConvertFrom.RegionName;
m_regionLocX = ConvertFrom.RegionLocX;
m_regionLocY = ConvertFrom.RegionLocY;
m_internalEndPoint = ConvertFrom.InternalEndPoint;
m_externalHostName = ConvertFrom.ExternalHostName;
m_httpPort = ConvertFrom.HttpPort;
RegionID = ConvertFrom.RegionID;
ServerURI = ConvertFrom.ServerURI;
TerrainImage = ConvertFrom.TerrainImage;
Access = ConvertFrom.Access;
Maturity = ConvertFrom.Maturity;
RegionSecret = ConvertFrom.RegionSecret;
}
/// <value> /// <value>
/// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw.
@ -268,7 +288,10 @@ namespace OpenSim.Services.Interfaces
kvp["serverHttpPort"] = HttpPort.ToString(); kvp["serverHttpPort"] = HttpPort.ToString();
kvp["serverURI"] = ServerURI; kvp["serverURI"] = ServerURI;
kvp["serverPort"] = InternalEndPoint.Port.ToString(); kvp["serverPort"] = InternalEndPoint.Port.ToString();
kvp["regionMapTexture"] = TerrainImage.ToString();
kvp["access"] = Access.ToString();
kvp["regionSecret"] = RegionSecret;
// Maturity doesn't seem to exist in the DB
return kvp; return kvp;
} }
@ -312,6 +335,16 @@ namespace OpenSim.Services.Interfaces
if (kvp.ContainsKey("serverURI")) if (kvp.ContainsKey("serverURI"))
ServerURI = (string)kvp["serverURI"]; ServerURI = (string)kvp["serverURI"];
if (kvp.ContainsKey("regionMapTexture"))
UUID.TryParse((string)kvp["regionMapTexture"], out TerrainImage);
if (kvp.ContainsKey("access"))
Access = Byte.Parse((string)kvp["access"]);
if (kvp.ContainsKey("regionSecret"))
RegionSecret =(string)kvp["regionSecret"];
} }
} }

View File

@ -25,14 +25,25 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
namespace OpenSim.Framework.Communications using OpenSim.Framework;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenMetaverse;
namespace OpenSim.Services.Interfaces
{ {
public interface IHyperlink public interface IHyperlinkService
{ {
bool IsHyperlinkRegion(ulong handle); GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor);
RegionInfo GetHyperlinkRegion(ulong handle); GridRegion GetHyperlinkRegion(ulong handle);
ulong FindRegionHandle(ulong handle); ulong FindRegionHandle(ulong handle);
bool SendUserInformation(RegionInfo region, AgentCircuitData aCircuit);
bool SendUserInformation(GridRegion region, AgentCircuitData aCircuit);
void AdjustUserInformation(AgentCircuitData aCircuit); void AdjustUserInformation(AgentCircuitData aCircuit);
bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome);
void AcceptUser(ForeignUserProfileData user, GridRegion home);
bool IsLocalUser(UUID userID);
} }
} }

View File

@ -28,11 +28,12 @@
using System; using System;
using OpenSim.Framework; using OpenSim.Framework;
using OpenMetaverse; using OpenMetaverse;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Services.Interfaces namespace OpenSim.Services.Interfaces
{ {
public interface INeighbourService public interface INeighbourService
{ {
bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion); GridRegion HelloNeighbour(ulong regionHandle, RegionInfo otherRegion);
} }
} }

View File

@ -28,7 +28,7 @@ namespace OpenSim.Tests.Clients.GridClient
new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"); new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
log4net.Config.BasicConfigurator.Configure(consoleAppender); log4net.Config.BasicConfigurator.Configure(consoleAppender);
string serverURI = "http://127.0.0.1:8002"; string serverURI = "http://127.0.0.1:8001";
GridServicesConnector m_Connector = new GridServicesConnector(serverURI); GridServicesConnector m_Connector = new GridServicesConnector(serverURI);
GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000); GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000);

View File

@ -65,8 +65,6 @@ namespace OpenSim.Tests.Common.Mock
m_userService = lus; m_userService = lus;
m_userAdminService = lus; m_userAdminService = lus;
LocalBackEndServices gs = new LocalBackEndServices();
m_gridService = gs;
} }
} }
} }

View File

@ -13,7 +13,7 @@
; * server instance ; * server instance
; * ; *
[Network] [Network]
port = 8002 port = 8001
; * The following are for the remote console ; * The following are for the remote console
; * They have no effect for the local or basic console types ; * They have no effect for the local or basic console types

View File

@ -9,7 +9,7 @@
; * enable the experimental authentication service ; * enable the experimental authentication service
; * ; *
[Startup] [Startup]
ServiceConnectors = "OpenSim.Server.Handlers.dll:AssetServiceConnector,OpenSim.Server.Handlers.dll:InventoryServiceInConnector,OpenSim.Server.Handlers.dll:FreeswitchServerConnector" ServiceConnectors = "OpenSim.Server.Handlers.dll:AssetServiceConnector,OpenSim.Server.Handlers.dll:InventoryServiceInConnector,OpenSim.Server.Handlers.dll:FreeswitchServerConnector,OpenSim.Server.Handlers.dll:GridServiceConnector"
; * This is common for all services, it's the network setup for the entire ; * This is common for all services, it's the network setup for the entire
; * server instance ; * server instance
@ -70,3 +70,12 @@ StorageProvider = "OpenSim.Data.MySQL.dll"
ConnectionString = "Data Source=localhost;Database=grid;User ID=grid;Password=grid;" ConnectionString = "Data Source=localhost;Database=grid;User ID=grid;Password=grid;"
; Realm = "users" ; Realm = "users"
; * This is the new style grid service.
; * "Realm" is the table that is used for user lookup.
; * It defaults to "regions", which uses the legacy tables
; *
[GridService]
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
StorageProvider = "OpenSim.Data.MySQL.dll:MySqlRegionData"
ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=grid;"
Realm = "regions"

View File

@ -326,7 +326,7 @@
; The MessagingServer is a companion of the UserServer. It uses ; The MessagingServer is a companion of the UserServer. It uses
; user_send_key and user_recv_key, too ; user_send_key and user_recv_key, too
messaging_server_url = "http://127.0.0.1:8006" ;messaging_server_url = "http://127.0.0.1:8006"
; What is reported as the "X-Secondlife-Shard" ; What is reported as the "X-Secondlife-Shard"
; Defaults to the user server url if not set ; Defaults to the user server url if not set

View File

@ -12,5 +12,12 @@
InventoryServices = "RemoteInventoryServicesConnector" InventoryServices = "RemoteInventoryServicesConnector"
AuthorizationServices = "RemoteAuthorizationServicesConnector" AuthorizationServices = "RemoteAuthorizationServicesConnector"
NeighbourServices = "RemoteNeighbourServicesConnector" NeighbourServices = "RemoteNeighbourServicesConnector"
GridServices = "RemoteGridServicesConnector"
NeighbourServiceInConnector = true NeighbourServiceInConnector = true
LandServiceInConnector = true LandServiceInConnector = true
[GridService]
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
; for the LocalGridServicesConnector which is used by the Remote one
StorageProvider = "OpenSim.Data.Null.dll:NullRegionData"

View File

@ -15,6 +15,11 @@
; ;
InventoryServerURI = "http://myinventoryserver.com:8004" InventoryServerURI = "http://myinventoryserver.com:8004"
[GridService]
;
; change this to your grid-wide inventory server
;
GridServerURI = "http://mygridserver.com:8001"
[Modules] [Modules]
;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists. ;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists.

View File

@ -11,9 +11,10 @@
AssetServices = "HGAssetBroker" AssetServices = "HGAssetBroker"
InventoryServices = "HGInventoryBroker" InventoryServices = "HGInventoryBroker"
NeighbourServices = "RemoteNeighbourServicesConnector" NeighbourServices = "RemoteNeighbourServicesConnector"
GridServices = "HGGridServicesConnector"
NeighbourServiceInConnector = true NeighbourServiceInConnector = true
LandServiceInConnector = true LandServiceInConnector = true
HypergridServiceInConnector = true
[AssetService] [AssetService]
LocalGridAssetService = "OpenSim.Services.Connectors.dll:AssetServicesConnector" LocalGridAssetService = "OpenSim.Services.Connectors.dll:AssetServicesConnector"
@ -22,3 +23,11 @@
[InventoryService] [InventoryService]
LocalGridInventoryService = "OpenSim.Region.CoreModules.dll:RemoteInventoryServicesConnector" LocalGridInventoryService = "OpenSim.Region.CoreModules.dll:RemoteInventoryServicesConnector"
HypergridInventoryService = "OpenSim.Services.Connectors.dll:HGInventoryServiceConnector" HypergridInventoryService = "OpenSim.Services.Connectors.dll:HGInventoryServiceConnector"
[GridService]
; for the HGGridServicesConnector to instantiate
GridServiceConnectorModule = "OpenSim.Region.CoreModules.dll:RemoteGridServicesConnector"
; RemoteGridServicesConnector instantiates a LocalGridServicesConnector,
; which in turn uses this
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
StorageProvider = "OpenSim.Data.Null.dll:NullRegionData"

View File

@ -25,5 +25,4 @@
[GridService] [GridService]
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
StorageProvider = "OpenSim.Data.Null.dll:NullRegionData" Realm = "regions"

View File

@ -32,3 +32,10 @@
[FreeswitchService] [FreeswitchService]
;; Configuration for the freeswitch service goes here ;; Configuration for the freeswitch service goes here
LocalServiceModule = "OpenSim.Services.FreeswitchService.dll:FreeswitchService" LocalServiceModule = "OpenSim.Services.FreeswitchService.dll:FreeswitchService"
[GridService]
;; For in-memory region storage (default)
StorageProvider = "OpenSim.Data.Null.dll:NullRegionData"
;;--- For MySql region storage (alternative)
;StorageProvider = "OpenSim.Data.MySQL.dll:MySqlRegionData"
;ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=***;"

View File

@ -10,13 +10,15 @@
[Modules] [Modules]
AssetServices = "HGAssetBroker" AssetServices = "HGAssetBroker"
InventoryServices = "HGInventoryBroker" InventoryServices = "HGInventoryBroker"
NeighbourServices = "LocalNeighbourServicesConnector" NeighbourServices = "RemoteNeighbourServicesConnector"
AuthorizationServices = "LocalAuthorizationServicesConnector" AuthorizationServices = "LocalAuthorizationServicesConnector"
GridServices = "HGGridServicesConnector" GridServices = "HGGridServicesConnector"
InventoryServiceInConnector = true InventoryServiceInConnector = true
AssetServiceInConnector = true AssetServiceInConnector = true
HGAuthServiceInConnector = true HGAuthServiceInConnector = true
HypergridServiceInConnector = true HypergridServiceInConnector = true
NeighbourServiceInConnector = true
[AssetService] [AssetService]
; For the AssetServiceInConnector ; For the AssetServiceInConnector
@ -42,6 +44,8 @@
LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:HGAuthenticationService" LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:HGAuthenticationService"
[GridService] [GridService]
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" ; for the HGGridServicesConnector to instantiate
GridServiceConnectorModule = "OpenSim.Region.CoreModules.dll:LocalGridServicesConnector" GridServiceConnectorModule = "OpenSim.Region.CoreModules.dll:LocalGridServicesConnector"
StorageProvider = "OpenSim.Data.Null.dll:NullRegionData" ; LocalGridServicesConnector needs this
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
Realm = "regions"

View File

@ -980,6 +980,8 @@
<Reference name="OpenSim.Framework.Servers"/> <Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/> <Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Framework.Statistics"/> <Reference name="OpenSim.Framework.Statistics"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="OpenSim.Services.Connectors"/>
<Reference name="OpenSim.Grid.Framework"/> <Reference name="OpenSim.Grid.Framework"/>
<Reference name="OpenSim.Grid.Communications.OGS1"/> <Reference name="OpenSim.Grid.Communications.OGS1"/>
<Reference name="OpenMetaverse.dll"/> <Reference name="OpenMetaverse.dll"/>
@ -988,6 +990,7 @@
<Reference name="XMLRPC.dll"/> <Reference name="XMLRPC.dll"/>
<Reference name="log4net.dll"/> <Reference name="log4net.dll"/>
<Reference name="DotNetOpenId.dll"/> <Reference name="DotNetOpenId.dll"/>
<Reference name="Nini.dll"/>
<Files> <Files>
<Match pattern="*.cs" recurse="true"/> <Match pattern="*.cs" recurse="true"/>
@ -3655,6 +3658,7 @@
<Reference name="OpenSim.Region.Framework"/> <Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.CoreModules"/> <Reference name="OpenSim.Region.CoreModules"/>
<Reference name="OpenSim.Region.Physics.Manager"/> <Reference name="OpenSim.Region.Physics.Manager"/>
<Reference name="OpenSim.Services.Interfaces"/>
<!-- Unit tests --> <!-- Unit tests -->
<!-- <Reference name="OpenSim.Tests.Common"/> --> <!-- <Reference name="OpenSim.Tests.Common"/> -->
@ -3708,6 +3712,7 @@
<Reference name="OpenSim.Region.ClientStack"/> <Reference name="OpenSim.Region.ClientStack"/>
<Reference name="OpenSim.Region.ClientStack.LindenUDP"/> <Reference name="OpenSim.Region.ClientStack.LindenUDP"/>
<Reference name="OpenSim.Region.Framework"/> <Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="OpenSim.Tests.Common"/> <Reference name="OpenSim.Tests.Common"/>
<Files> <Files>