diff --git a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs
index 6a66116eeb..20cec046ca 100644
--- a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs
+++ b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs
@@ -69,7 +69,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
protected CommunicationsManager m_commsManager;
protected GridInfoService m_gridInfoService;
- protected IHyperlink HGServices = null;
protected IRegionCreator m_regionCreator;
@@ -144,7 +143,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
// We are in grid mode
InitialiseHGGridServices(libraryRootFolder);
}
- HGCommands.HGServices = HGServices;
}
protected void InitialiseStandardServices(LibraryRootFolder libraryRootFolder)
@@ -188,18 +186,11 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
protected virtual void InitialiseHGStandaloneServices(LibraryRootFolder libraryRootFolder)
{
- HGGridServicesStandalone gridService
- = new HGGridServicesStandalone(
- m_openSim.NetServersInfo, m_httpServer, m_openSim.SceneManager);
-
m_commsManager
= new HGCommunicationsStandalone(
m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer,
- gridService,
libraryRootFolder, false);
- HGServices = gridService;
-
CreateGridInfoService();
}
@@ -210,8 +201,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
m_openSim.NetServersInfo,
m_openSim.SceneManager, libraryRootFolder);
- HGServices = ((HGCommunicationsGridMode) m_commsManager).HGServices;
-
m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler());
m_httpServer.AddStreamHandler(new OpenSim.XSimStatusHandler(m_openSim));
if (m_openSim.userStatsURI != String.Empty)
diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs
index 73e2db0f9e..3419ce2650 100644
--- a/OpenSim/Framework/Communications/Clients/RegionClient.cs
+++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs
@@ -35,6 +35,8 @@ using System.Text;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
+
using log4net;
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);
- 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;
@@ -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
string uri = string.Empty;
@@ -260,7 +262,7 @@ namespace OpenSim.Framework.Communications.Clients
return true;
}
- public bool DoRetrieveRootAgentCall(RegionInfo region, UUID id, out IAgentData agent)
+ public bool DoRetrieveRootAgentCall(GridRegion region, UUID id, out IAgentData agent)
{
agent = null;
// 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;
try
@@ -391,7 +393,7 @@ namespace OpenSim.Framework.Communications.Clients
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);
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);
string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/";
@@ -646,7 +648,7 @@ namespace OpenSim.Framework.Communications.Clients
return false;
}
- public virtual void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit)
+ public virtual void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit)
{
}
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs
index e9a6adb095..9f377a6131 100644
--- a/OpenSim/Framework/Communications/CommunicationsManager.cs
+++ b/OpenSim/Framework/Communications/CommunicationsManager.cs
@@ -59,11 +59,6 @@ namespace OpenSim.Framework.Communications
}
protected IMessagingService m_messageService;
- public IGridServices GridService
- {
- get { return m_gridService; }
- }
- protected IGridServices m_gridService;
public UserProfileCacheService UserProfileCacheService
{
diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs
deleted file mode 100644
index 6365919047..0000000000
--- a/OpenSim/Framework/Communications/IGridServices.cs
+++ /dev/null
@@ -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; }
-
- ///
- /// If true, then regions will accept logins from the user service. If false, then they will not.
- ///
- bool RegionLoginsEnabled { get; set; }
-
- ///
- /// Register a region with the grid service.
- ///
- ///
- ///
- /// Thrown if region registration failed
- RegionCommsListener RegisterRegion(RegionInfo regionInfos);
-
- ///
- /// Deregister a region with the grid service.
- ///
- ///
- ///
- /// Thrown if region deregistration failed
- bool DeregisterRegion(RegionInfo regionInfo);
-
- ///
- /// Get information about the regions neighbouring the given co-ordinates.
- ///
- ///
- ///
- ///
- List 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 GetGridSettings();
- List 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);
-
- ///
- /// Get information about regions starting with the provided name.
- ///
- ///
- /// The name to match against.
- ///
- ///
- /// The maximum number of results to return.
- ///
- ///
- /// A list of s of regions with matching name. If the
- /// grid-server couldn't be contacted or returned an error, return null.
- ///
- List RequestNamedRegions(string name, int maxNumber);
- }
-}
diff --git a/OpenSim/Framework/IRegionCommsListener.cs b/OpenSim/Framework/IRegionCommsListener.cs
index ba4c6167f6..307c6bc8b9 100644
--- a/OpenSim/Framework/IRegionCommsListener.cs
+++ b/OpenSim/Framework/IRegionCommsListener.cs
@@ -46,8 +46,6 @@ namespace OpenSim.Framework
public delegate bool CloseAgentConnection(UUID agentID);
- public delegate bool RegionUp(RegionInfo region);
-
public delegate bool ChildAgentUpdate(ChildAgentDataUpdate cAgentData);
public delegate void LogOffUser(UUID agentID, UUID regionSecret, string message);
@@ -65,7 +63,6 @@ namespace OpenSim.Framework
event AcknowledgePrimCross OnAcknowledgePrimCrossed;
event UpdateNeighbours OnNeighboursUpdate;
event CloseAgentConnection OnCloseAgentConnection;
- event RegionUp OnRegionUp;
event ChildAgentUpdate OnChildAgentUpdate;
event LogOffUser OnLogOffUser;
event GetLandData OnGetLandData;
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs
index 2e2c703e95..d61e08ce8d 100644
--- a/OpenSim/Framework/IScene.cs
+++ b/OpenSim/Framework/IScene.cs
@@ -74,7 +74,7 @@ namespace OpenSim.Framework
void CloseAllAgents(uint circuitcode);
void Restart(int seconds);
- bool OtherRegionUp(RegionInfo thisRegion);
+ //RegionInfo OtherRegionUp(RegionInfo thisRegion);
string GetSimulatorVersion();
diff --git a/OpenSim/Framework/NetworkServersInfo.cs b/OpenSim/Framework/NetworkServersInfo.cs
index 3b00af3e3e..7e667424f5 100644
--- a/OpenSim/Framework/NetworkServersInfo.cs
+++ b/OpenSim/Framework/NetworkServersInfo.cs
@@ -102,8 +102,7 @@ namespace OpenSim.Framework
ConfigSettings.DefaultInventoryServerHttpPort.ToString());
secureInventoryServer = config.Configs["Network"].GetBoolean("secure_inventory_server", true);
- MessagingURL = config.Configs["Network"].GetString("messaging_server_url",
- "http://127.0.0.1:" + ConfigSettings.DefaultMessageServerHttpPort);
+ MessagingURL = config.Configs["Network"].GetString("messaging_server_url", string.Empty);
}
}
}
diff --git a/OpenSim/Framework/RegionCommsListener.cs b/OpenSim/Framework/RegionCommsListener.cs
index 016c78ca63..90200d6e91 100644
--- a/OpenSim/Framework/RegionCommsListener.cs
+++ b/OpenSim/Framework/RegionCommsListener.cs
@@ -47,7 +47,6 @@ namespace OpenSim.Framework
private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser
private UpdateNeighbours handlerNeighboursUpdate = null; // OnNeighboursUpdate;
private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
- private RegionUp handlerRegionUp = null; // OnRegionUp;
private LogOffUser handlerLogOffUser = null;
private GetLandData handlerGetLandData = null;
@@ -62,7 +61,6 @@ namespace OpenSim.Framework
public event AcknowledgeAgentCross OnAcknowledgeAgentCrossed;
public event AcknowledgePrimCross OnAcknowledgePrimCrossed;
public event CloseAgentConnection OnCloseAgentConnection;
- public event RegionUp OnRegionUp;
public event ChildAgentUpdate OnChildAgentUpdate;
public event LogOffUser OnLogOffUser;
public event GetLandData OnGetLandData;
@@ -108,17 +106,6 @@ namespace OpenSim.Framework
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)
{
handlerChildAgentUpdate = OnChildAgentUpdate;
diff --git a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
index ebb2691dfd..a0d40089f7 100644
--- a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
+++ b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
@@ -59,11 +59,11 @@ namespace OpenSim.Framework.Servers.HttpServer
int length = 0;
using (StreamWriter writer = new StreamWriter(buffer))
{
- writer.WriteLine(obj);
+ writer.Write(obj);
writer.Flush();
- length = (int)buffer.Length;
}
+ length = (int)obj.Length;
request.ContentLength = length;
Stream requestStream = request.GetRequestStream();
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 45b5a105fd..a28a6177b2 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1203,6 +1203,32 @@ namespace OpenSim.Framework
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
public static void FireAndForget(System.Threading.WaitCallback callback)
diff --git a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs
index 01d5537056..47bbeca147 100644
--- a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs
+++ b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs
@@ -34,6 +34,7 @@ using System.Text.RegularExpressions;
using log4net;
using Nwc.XmlRpc;
using OpenMetaverse;
+using Nini.Config;
using OpenSim.Data;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
@@ -42,6 +43,9 @@ using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Capabilities;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
+using OpenSim.Services.Interfaces;
+using OpenSim.Services.Connectors;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Grid.UserServer.Modules
{
@@ -63,6 +67,8 @@ namespace OpenSim.Grid.UserServer.Modules
public UserConfig m_config;
private readonly IRegionProfileRouter m_regionProfileService;
+ private IGridService m_GridService;
+
protected BaseHttpServer m_httpServer;
public UserLoginService(
@@ -76,6 +82,8 @@ namespace OpenSim.Grid.UserServer.Modules
m_defaultHomeY = m_config.DefaultY;
m_interInventoryService = inventoryService;
m_regionProfileService = regionProfileService;
+
+ m_GridService = new GridServicesConnector(config.GridServerURL.ToString());
}
public void RegisterHandlers(BaseHttpServer httpServer, bool registerLLSDHandler, bool registerOpenIDHandlers)
@@ -203,47 +211,38 @@ namespace OpenSim.Grid.UserServer.Modules
protected override RegionInfo RequestClosestRegion(string region)
{
- RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(region,
- m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey);
-
- if (profileData != null)
- {
- return profileData.ToRegionInfo();
- }
- else
- {
- return null;
- }
+ return GridRegionToRegionInfo(m_GridService.GetRegionByName(UUID.Zero, region));
}
protected override RegionInfo GetRegionInfo(ulong homeRegionHandle)
{
- RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionHandle,
- m_config.GridServerURL, m_config.GridSendKey,
- m_config.GridRecvKey);
- if (profileData != null)
- {
- return profileData.ToRegionInfo();
- }
- else
- {
- return null;
- }
+ uint x = 0, y = 0;
+ Utils.LongToUInts(homeRegionHandle, out x, out y);
+ return GridRegionToRegionInfo(m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y));
}
protected override RegionInfo GetRegionInfo(UUID homeRegionId)
{
- RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionId,
- m_config.GridServerURL, m_config.GridSendKey,
- m_config.GridRecvKey);
- if (profileData != null)
- {
- return profileData.ToRegionInfo();
- }
- else
- {
+ return GridRegionToRegionInfo(m_GridService.GetRegionByUUID(UUID.Zero, homeRegionId));
+ }
+
+ private RegionInfo GridRegionToRegionInfo(GridRegion gregion)
+ {
+ if (gregion == 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)
diff --git a/OpenSim/Region/Application/HGCommands.cs b/OpenSim/Region/Application/HGCommands.cs
index 1786e54aec..f503db75c1 100644
--- a/OpenSim/Region/Application/HGCommands.cs
+++ b/OpenSim/Region/Application/HGCommands.cs
@@ -43,16 +43,11 @@ namespace OpenSim
public class HGCommands
{
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,
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
new HGScene(
@@ -61,213 +56,5 @@ namespace OpenSim
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 :[:]");
- m_log.Info("Usage: link-region []");
- m_log.Info("Usage: link-region []");
- }
-
- private static void UnlinkRegionCmdUsage()
- {
- m_log.Info("Usage: unlink-region :");
- m_log.Info("Usage: unlink-region ");
- }
-
}
}
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index e9c9dc1372..c0bdc1e0aa 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -755,11 +755,6 @@ namespace OpenSim
}
break;
- case "link-region":
- case "unlink-region":
- case "link-mapping":
- HGCommands.RunHGCommand(command, cmdparams, m_sceneManager.CurrentOrFirstScene);
- break;
}
}
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 4d13e83ce0..821de3581e 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -399,7 +399,7 @@ namespace OpenSim
}
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
// line - we need to get the user's attention
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/MockScene.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/MockScene.cs
index c831f68fa1..34c21aaba7 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/Tests/MockScene.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/MockScene.cs
@@ -28,6 +28,7 @@
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
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 CloseAllAgents(uint circuitcode) {}
- public override bool OtherRegionUp(RegionInfo thisRegion) { return false; }
+ public override void OtherRegionUp(GridRegion otherRegion) { }
///
/// Doesn't really matter what the call is - we're using this to test that a packet has actually been received
diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs
index 80f2e79418..002ea178de 100644
--- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs
+++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs
@@ -40,21 +40,12 @@ namespace OpenSim.Region.Communications.Hypergrid
{
public class HGCommunicationsGridMode : CommunicationsManager // CommunicationsOGS1
{
- IHyperlink m_osw = null;
- public IHyperlink HGServices
- {
- get { return m_osw; }
- }
public HGCommunicationsGridMode(
NetworkServersInfo serversInfo,
SceneManager sman, LibraryRootFolder 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);
// This plugin arrangement could eventually be configurable rather than hardcoded here.
diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs
index e4e12d4b7a..f5126ca00e 100644
--- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs
+++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs
@@ -44,7 +44,6 @@ namespace OpenSim.Region.Communications.Hypergrid
ConfigSettings configSettings,
NetworkServersInfo serversInfo,
BaseHttpServer httpServer,
- HGGridServices gridService,
LibraryRootFolder libraryRootFolder,
bool dumpAssetsToFile)
: base(serversInfo, libraryRootFolder)
@@ -64,8 +63,6 @@ namespace OpenSim.Region.Communications.Hypergrid
m_avatarService = hgUserService;
m_messageService = hgUserService;
- gridService.UserProfileCache = m_userProfileCacheService;
- m_gridService = gridService;
}
}
}
diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs
deleted file mode 100644
index 54cde0f54b..0000000000
--- a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs
+++ /dev/null
@@ -1,1024 +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.Drawing;
-using System.Net;
-using System.Net.Sockets;
-using System.Reflection;
-using System.Runtime.Remoting;
-using System.Security.Authentication;
-using log4net;
-using Nwc.XmlRpc;
-using OpenMetaverse;
-using OpenMetaverse.Imaging;
-using OpenSim.Framework;
-using OpenSim.Framework.Communications;
-using OpenSim.Framework.Communications.Cache;
-using OpenSim.Framework.Servers;
-using OpenSim.Framework.Servers.HttpServer;
-using OpenSim.Region.Communications.OGS1;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Services.Interfaces;
-// using OpenSim.Region.Environment.Modules.Framework;
-
-namespace OpenSim.Region.Communications.Hypergrid
-{
- ///
- /// This class encapsulates the main hypergrid functions related to creating and managing
- /// hyperlinks, as well as processing all the inter-region comms between a region and
- /// an hyperlinked region.
- ///
- public class HGGridServices : IGridServices, IHyperlink
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
-
- public BaseHttpServer httpListener;
- public NetworkServersInfo serversInfo;
-
- protected List m_regionsOnInstance = new List();
-
- // Hyperlink regions are hyperlinks on the map
- protected List m_hyperlinkRegions = new List();
-
- // Known regions are home regions of visiting foreign users.
- // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when
- // the visitor goes away. They are mapped to X=0 on the map.
- // This is key-ed on agent ID
- protected Dictionary m_knownRegions = new Dictionary();
-
- protected UserProfileCacheService m_userProfileCache;
- protected SceneManager m_sceneman;
-
- private Dictionary m_queuedGridSettings = new Dictionary();
-
- public virtual string gdebugRegionName
- {
- get { return "Override me"; }
- set { ; }
- }
-
- public string rdebugRegionName
- {
- get { return _rdebugRegionName; }
- set { _rdebugRegionName = value; }
- }
- private string _rdebugRegionName = String.Empty;
-
- public virtual bool RegionLoginsEnabled
- {
- get { return true; }
- set { ; }
- }
-
- public UserProfileCacheService UserProfileCache
- {
- set { m_userProfileCache = value; }
- }
-
- private Random random;
-
- ///
- /// Contructor. Adds "expect_hg_user" and "check" xmlrpc method handlers
- ///
- ///
- public HGGridServices(NetworkServersInfo servers_info, SceneManager sman)
- {
- serversInfo = servers_info;
- m_sceneman = sman;
-
- random = new Random();
-
- MainServer.Instance.AddXmlRPCHandler("link_region", LinkRegionRequest);
- MainServer.Instance.AddXmlRPCHandler("expect_hg_user", ExpectHGUser);
-
- HGNetworkServersInfo.Init(servers_info.AssetURL, servers_info.InventoryURL, servers_info.UserURL);
- }
-
- // see IGridServices
- public virtual RegionCommsListener RegisterRegion(RegionInfo regionInfo)
- {
- // Region doesn't exist here. Trying to link remote region
-
- m_log.Info("[HGrid]: Linking remote region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort);
- regionInfo.RegionID = LinkRegion(regionInfo); // UUID.Random();
- if (!regionInfo.RegionID.Equals(UUID.Zero))
- {
- m_hyperlinkRegions.Add(regionInfo);
- m_log.Info("[HGrid]: Successfully linked to region_uuid " + regionInfo.RegionID);
-
- //Try get the map image
- GetMapImage(regionInfo);
- }
- else
- {
- m_log.Info("[HGrid]: No such region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "(" + regionInfo.InternalEndPoint.Port + ")");
- }
- // Note that these remote regions aren't registered in localBackend, so return null, no local listeners
- return null;
- }
-
- // see IGridServices
- public virtual bool DeregisterRegion(RegionInfo regionInfo)
- {
- if (m_hyperlinkRegions.Contains(regionInfo))
- {
- m_hyperlinkRegions.Remove(regionInfo);
- return true;
- }
- foreach (KeyValuePair kvp in m_knownRegions)
- {
- if (kvp.Value == regionInfo)
- {
- m_knownRegions.Remove(kvp.Key);
- return true;
- }
- }
- return false;
- }
-
- public virtual Dictionary GetGridSettings()
- {
- Dictionary returnGridSettings = new Dictionary();
- lock (m_queuedGridSettings)
- {
- foreach (string Dictkey in m_queuedGridSettings.Keys)
- {
- returnGridSettings.Add(Dictkey, m_queuedGridSettings[Dictkey]);
- }
-
- m_queuedGridSettings.Clear();
- }
-
- return returnGridSettings;
- }
-
- // see IGridServices
- public virtual List RequestNeighbours(uint x, uint y)
- {
- List neighbours = new List();
- foreach (RegionInfo reg in m_hyperlinkRegions)
- {
- 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;
- }
-
- ///
- /// Request information about a region.
- ///
- ///
- ///
- /// 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.
- ///
- public virtual RegionInfo RequestNeighbourInfo(UUID Region_UUID)
- {
- foreach (RegionInfo info in m_hyperlinkRegions)
- {
- if (info.RegionID == Region_UUID) return info;
- }
-
- // I don't trust region uuids to be unique...
- //foreach (RegionInfo info in m_knownRegions.Values)
- //{
- // if (info.RegionID == Region_UUID) return info;
- //}
-
- return null;
- }
-
- ///
- /// Request information about a region.
- ///
- ///
- ///
- public virtual RegionInfo RequestNeighbourInfo(ulong regionHandle)
- {
- //m_log.Debug(" >> RequestNeighbourInfo for " + regionHandle);
- foreach (RegionInfo info in m_hyperlinkRegions)
- {
- //m_log.Debug(" .. " + info.RegionHandle);
- if (info.RegionHandle == regionHandle) return info;
- }
-
- foreach (RegionInfo info in m_knownRegions.Values)
- {
- if (info.RegionHandle == regionHandle)
- {
- //m_log.Debug("XXX------ known region " + info.RegionHandle);
- return info;
- }
- }
-
- return null;
- }
-
- public virtual RegionInfo RequestNeighbourInfo(string name)
- {
- foreach (RegionInfo info in m_hyperlinkRegions)
- {
- //m_log.Debug(" .. " + info.RegionHandle);
- if (info.RegionName == name) return info;
- }
-
- foreach (RegionInfo info in m_knownRegions.Values)
- {
- if (info.RegionName == name)
- {
- //m_log.Debug("XXX------ known region " + info.RegionHandle);
- return info;
- }
- }
-
- return null;
- }
-
- public virtual RegionInfo RequestNeighbourInfo(string hostName, uint port)
- {
- foreach (RegionInfo info in m_hyperlinkRegions)
- {
- //m_log.Debug(" .. " + info.RegionHandle);
- if ((info.ExternalHostName == hostName) && (info.HttpPort == port))
- return info;
- }
-
- foreach (RegionInfo info in m_knownRegions.Values)
- {
- if ((info.ExternalHostName == hostName) && (info.HttpPort == port))
- {
- //m_log.Debug("XXX------ known region " + info.RegionHandle);
- return info;
- }
- }
-
- return null;
- }
-
- public virtual RegionInfo RequestClosestRegion(string regionName)
- {
- foreach (RegionInfo info in m_hyperlinkRegions)
- {
- if (info.RegionName == regionName) return info;
- }
-
- return null;
- }
-
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public virtual List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
- {
- List neighbours = new List();
-
- foreach (RegionInfo regInfo in m_hyperlinkRegions)
- {
- 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;
- // m_log.Debug("ImgID: " + map.MapImageId);
- map.Agents = 1;
- map.RegionFlags = 72458694;
- map.Access = regInfo.AccessLevel;
- neighbours.Add(map);
- }
- }
-
- return neighbours;
- }
-
-
- protected virtual void GetMapImage(RegionInfo info)
- {
- try
- {
- string regionimage = "regionImage" + info.RegionID.ToString();
- regionimage = regionimage.Replace("-", "");
-
- WebClient c = new WebClient();
- string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage;
- //m_log.Debug("JPEG: " + uri);
- c.DownloadFile(uri, info.RegionID.ToString() + ".jpg");
- Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg");
- //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
- byte[] imageData = OpenJPEG.EncodeFromImage(m, true);
- AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString());
- info.RegionSettings.TerrainImageID = ass.FullID;
- ass.Type = (int)AssetType.Texture;
- ass.Temporary = false;
- ass.Local = true;
- ass.Data = imageData;
-
- m_sceneman.CurrentOrFirstScene.AssetService.Store(ass);
-
- }
- catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
- {
- m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache");
- }
- }
-
- // A little ugly, since this code is exactly the same as OSG1's, and we're already
- // calling that for when the region in in grid mode... (for the grid regions)
- //
- public virtual LandData RequestLandData (ulong regionHandle, uint x, uint y)
- {
- m_log.DebugFormat("[HGrid]: requests land data in {0}, at {1}, {2}",
- regionHandle, x, y);
-
- // Remote region
-
- Hashtable hash = new Hashtable();
- hash["region_handle"] = regionHandle.ToString();
- hash["x"] = x.ToString();
- hash["y"] = y.ToString();
-
- IList paramList = new ArrayList();
- paramList.Add(hash);
- LandData landData = null;
-
- try
- {
- 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("[HGrid]: 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("[HGrid]: Got land data for parcel {0}", landData.Name);
- }
- catch (Exception e)
- {
- m_log.Error("[HGrid]: Got exception while parsing land-data:", e);
- }
- }
- }
- else m_log.WarnFormat("[HGrid]: Couldn't find region with handle {0}", regionHandle);
- }
- catch (Exception e)
- {
- m_log.ErrorFormat("[HGrid]: Couldn't contact region {0}: {1}", regionHandle, e);
- }
-
- return landData;
- }
-
- // Grid Request Processing
- public virtual List RequestNamedRegions (string name, int maxNumber)
- {
- List infos = new List();
- foreach (RegionInfo info in m_hyperlinkRegions)
- {
- if (info.RegionName.ToLower().Contains(name))
- {
- infos.Add(info);
- }
- }
- return infos;
- }
-
-
- private UUID LinkRegion(RegionInfo info)
- {
- UUID uuid = UUID.Zero;
-
- Hashtable hash = new Hashtable();
- hash["region_name"] = info.RegionName;
-
- IList paramList = new ArrayList();
- paramList.Add(hash);
-
- XmlRpcRequest request = new XmlRpcRequest("link_region", paramList);
- string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
- m_log.Debug("[HGrid]: Linking to " + uri);
- XmlRpcResponse response = request.Send(uri, 10000);
- if (response.IsFault)
- {
- m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
- }
- else
- {
- hash = (Hashtable)response.Value;
- //foreach (Object o in hash)
- // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
- try
- {
- UUID.TryParse((string)hash["uuid"], out uuid);
- info.RegionID = uuid;
- if ((string)hash["handle"] != null)
- {
- info.regionSecret = (string)hash["handle"];
- //m_log.Debug(">> HERE: " + info.regionSecret);
- }
- if (hash["region_image"] != null)
- {
- UUID img = UUID.Zero;
- UUID.TryParse((string)hash["region_image"], out img);
- info.RegionSettings.TerrainImageID = img;
- }
- if (hash["region_name"] != null)
- {
- info.RegionName = (string)hash["region_name"];
- //m_log.Debug(">> " + info.RegionName);
- }
- if (hash["internal_port"] != null)
- {
- int port = Convert.ToInt32((string)hash["internal_port"]);
- info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
- //m_log.Debug(">> " + info.InternalEndPoint.ToString());
- }
- if (hash["remoting_port"] != null)
- {
- info.RemotingPort = Convert.ToUInt32(hash["remoting_port"]);
- //m_log.Debug(">> " + info.RemotingPort);
- }
-
- }
- catch (Exception e)
- {
- m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace);
- }
- }
- return uuid;
- }
-
- ///
- /// Someone wants to link to us
- ///
- ///
- ///
- public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient)
- {
- Hashtable requestData = (Hashtable)request.Params[0];
- //string host = (string)requestData["host"];
- //string portstr = (string)requestData["port"];
- string name = (string)requestData["region_name"];
-
- m_log.DebugFormat("[HGrid]: Hyperlink request");
-
-
- RegionInfo regInfo = null;
- foreach (RegionInfo r in m_regionsOnInstance)
- {
- if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower()))
- {
- regInfo = r;
- break;
- }
- }
-
- if (regInfo == null)
- regInfo = m_regionsOnInstance[0]; // Send out the first region
-
- Hashtable hash = new Hashtable();
- hash["uuid"] = regInfo.RegionID.ToString();
- hash["handle"] = regInfo.RegionHandle.ToString();
- //m_log.Debug(">> Here " + regInfo.RegionHandle);
- hash["region_image"] = regInfo.RegionSettings.TerrainImageID.ToString();
- hash["region_name"] = regInfo.RegionName;
- hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
- hash["remoting_port"] = ConfigSettings.DefaultRegionRemotingPort.ToString();
- //m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port);
-
-
- XmlRpcResponse response = new XmlRpcResponse();
- response.Value = hash;
- return response;
- }
-
- public bool InformRegionOfUser(RegionInfo regInfo, AgentCircuitData agentData)
- {
- //ulong regionHandle = regInfo.RegionHandle;
- try
- {
- //regionHandle = Convert.ToUInt64(regInfo.regionSecret);
- m_log.Info("[HGrid]: InformRegionOfUser: Remote hyperlinked region " + regInfo.regionSecret);
- }
- catch
- {
- m_log.Info("[HGrid]: InformRegionOfUser: Local grid region " + regInfo.regionSecret);
- }
-
- string capsPath = agentData.CapsPath;
- Hashtable loginParams = new Hashtable();
- loginParams["session_id"] = agentData.SessionID.ToString();
- loginParams["secure_session_id"] = agentData.SecureSessionID.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;
-
- CachedUserInfo u = m_userProfileCache.GetUserDetails(agentData.AgentID);
- if (u != null && u.UserProfile != null)
- {
- loginParams["region_uuid"] = u.UserProfile.HomeRegionID.ToString(); // This seems to be always Zero
- //m_log.Debug(" --------- Home Region UUID -------");
- //m_log.Debug(" >> " + loginParams["region_uuid"] + " <<");
- //m_log.Debug(" --------- ---------------- -------");
-
- string serverURI = "";
- if (u.UserProfile is ForeignUserProfileData)
- serverURI = HGNetworkServersInfo.ServerURI(((ForeignUserProfileData)u.UserProfile).UserServerURI);
- loginParams["userserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalUserServerURI : serverURI;
-
- serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserAssetURI);
- loginParams["assetserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalAssetServerURI : serverURI;
-
- serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserInventoryURI);
- loginParams["inventoryserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalInventoryServerURI : serverURI;
-
- loginParams["root_folder_id"] = u.UserProfile.RootInventoryFolderID;
-
- RegionInfo rinfo = RequestNeighbourInfo(u.UserProfile.HomeRegion);
- if (rinfo != null)
- {
- loginParams["internal_port"] = rinfo.InternalEndPoint.Port.ToString();
- if (!IsLocalUser(u))
- {
- loginParams["regionhandle"] = rinfo.regionSecret; // user.CurrentAgent.Handle.ToString();
- //m_log.Debug("XXX--- informregionofuser (foreign user) here handle: " + rinfo.regionSecret);
-
- loginParams["home_address"] = ((ForeignUserProfileData)(u.UserProfile)).UserHomeAddress;
- loginParams["home_port"] = ((ForeignUserProfileData)(u.UserProfile)).UserHomePort;
- loginParams["home_remoting"] = ((ForeignUserProfileData)(u.UserProfile)).UserHomeRemotingPort;
- }
- else
- {
- //m_log.Debug("XXX--- informregionofuser (local user) here handle: " + rinfo.regionSecret);
-
- //// local user about to jump out, let's process the name
- // On second thoughts, let's not do this for the *user*; let's only do it for the *agent*
- //loginParams["firstname"] = agentData.firstname + "." + agentData.lastname;
- //loginParams["lastname"] = serversInfo.UserURL;
-
- // local user, first time out. let's ask the grid about this user's home region
- loginParams["regionhandle"] = u.UserProfile.HomeRegion.ToString(); // user.CurrentAgent.Handle.ToString();
-
- loginParams["home_address"] = rinfo.ExternalHostName;
- m_log.Debug(" --------- Home Address -------");
- m_log.Debug(" >> " + loginParams["home_address"] + " <<");
- m_log.Debug(" --------- ------------ -------");
- loginParams["home_port"] = rinfo.HttpPort.ToString();
- loginParams["home_remoting"] = ConfigSettings.DefaultRegionRemotingPort.ToString(); ;
- }
- }
- else
- {
- m_log.Warn("[HGrid]: User's home region info not found: " + u.UserProfile.HomeRegionX + ", " + u.UserProfile.HomeRegionY);
- }
- }
-
- 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;
- }
- }
-
-
- ///
- /// 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.
- ///
- ///
- ///
- public XmlRpcResponse ExpectHGUser(XmlRpcRequest request, IPEndPoint remoteClient)
- {
- 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"]);
- 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"];
-
- UUID rootID = UUID.Zero;
- UUID.TryParse((string)requestData["root_folder_id"], out rootID);
- userData.RootInventoryFolderID = rootID;
-
- UUID uuid = UUID.Zero;
- UUID.TryParse((string)requestData["region_uuid"], out uuid);
- userData.HomeRegionID = uuid; // not quite comfortable about this...
- ulong userRegionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
- //userData.HomeRegion = userRegionHandle;
- userData.UserHomeAddress = (string)requestData["home_address"];
- userData.UserHomePort = (string)requestData["home_port"];
- int userhomeinternalport = Convert.ToInt32((string)requestData["internal_port"]);
- userData.UserHomeRemotingPort = (string)requestData["home_remoting"];
-
-
- m_log.DebugFormat("[HGrid]: Prepare for connection from {0} {1} (@{2}) UUID={3}",
- userData.FirstName, userData.SurName, userData.UserServerURI, userData.ID);
- m_log.Debug("[HGrid]: home_address: " + userData.UserHomeAddress +
- "; home_port: " + userData.UserHomePort + "; remoting: " + userData.UserHomeRemotingPort);
-
- 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 :-/
- CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(userData.ID);
- if ((uinfo != null) && !(uinfo.UserProfile is ForeignUserProfileData))
- {
- m_log.WarnFormat("[HGrid]: Foreign user trying to get in with local identity. Access denied.");
- Hashtable respdata = new Hashtable();
- respdata["success"] = "FALSE";
- respdata["reason"] = "Foreign user has the same ID as a local user.";
- resp.Value = respdata;
- return resp;
- }
-
- if (!RegionLoginsEnabled)
- {
- m_log.InfoFormat(
- "[HGrid]: Denying access for user {0} {1} because region login is currently disabled",
- userData.FirstName, userData.SurName);
-
- Hashtable respdata = new Hashtable();
- respdata["success"] = "FALSE";
- respdata["reason"] = "region login currently disabled";
- resp.Value = respdata;
- }
- else
- {
- // Finally, everything looks ok
- //m_log.Debug("XXX---- EVERYTHING OK ---XXX");
-
- // 1 - Preload the user data
- m_userProfileCache.PreloadUserCache(userData);
-
- if (m_knownRegions.ContainsKey(userData.ID))
- {
- // This was left here when the user departed
- m_knownRegions.Remove(userData.ID);
- }
-
- // 2 - Load the region info into list of known regions
- RegionInfo rinfo = new RegionInfo();
- rinfo.RegionID = userData.HomeRegionID;
- rinfo.ExternalHostName = userData.UserHomeAddress;
- rinfo.HttpPort = Convert.ToUInt32(userData.UserHomePort);
- rinfo.RemotingPort = Convert.ToUInt32(userData.UserHomeRemotingPort);
- rinfo.RegionID = userData.HomeRegionID;
- // X=0 on the map
- rinfo.RegionLocX = 0;
- rinfo.RegionLocY = (uint)(random.Next(0, Int32.MaxValue)); //(uint)m_knownRegions.Count;
- rinfo.regionSecret = userRegionHandle.ToString();
- //m_log.Debug("XXX--- Here: handle = " + rinfo.regionSecret);
- try
- {
- rinfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)userhomeinternalport);
- }
- catch (Exception e)
- {
- m_log.Warn("[HGrid]: Exception while constructing internal endpoint: " + e);
- }
- rinfo.RemotingAddress = rinfo.ExternalEndPoint.Address.ToString(); //userData.UserHomeAddress;
-
- if (!IsComingHome(userData))
- {
- // Change the user's home region here!!!
- userData.HomeRegion = rinfo.RegionHandle;
- }
-
- if (!m_knownRegions.ContainsKey(userData.ID))
- m_knownRegions.Add(userData.ID, rinfo);
-
- // 3 - Send the reply
- Hashtable respdata = new Hashtable();
- respdata["success"] = "TRUE";
- resp.Value = respdata;
-
- DumpUserData(userData);
- DumpRegionData(rinfo);
-
- }
-
- return resp;
- }
-
- public bool SendUserInformation(RegionInfo regInfo, AgentCircuitData agentData)
- {
- CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(agentData.AgentID);
-
- if ((IsLocalUser(uinfo) && IsHyperlinkRegion(regInfo.RegionHandle)) ||
- (!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo)))
- {
- m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere");
- if (!InformRegionOfUser(regInfo, agentData))
- {
- 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) && IsHyperlinkRegion(regInfo.RegionHandle))
- {
- agentData.firstname = agentData.firstname + "." + agentData.lastname;
- agentData.lastname = "@" + serversInfo.UserURL.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI;
- }
-
- return true;
- }
-
-
- #region Methods triggered by calls from external instances
-
- ///
- ///
- ///
- ///
- ///
- ///
- public void AdjustUserInformation(AgentCircuitData agentData)
- {
- CachedUserInfo uinfo = m_userProfileCache.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!");
- }
- #endregion
-
-
- #region IHyperGrid interface
-
- public virtual bool IsHyperlinkRegion(ulong ihandle)
- {
- if (GetHyperlinkRegion(ihandle) == null)
- return false;
- else
- return true;
- }
-
- public virtual RegionInfo GetHyperlinkRegion(ulong ihandle)
- {
- foreach (RegionInfo info in m_hyperlinkRegions)
- {
- if (info.RegionHandle == ihandle)
- return info;
- }
-
- foreach (RegionInfo info in m_knownRegions.Values)
- {
- if (info.RegionHandle == ihandle)
- return info;
- }
-
- return null;
- }
-
- public virtual ulong FindRegionHandle(ulong ihandle)
- {
- long ohandle = -1;
- List rlist = new List(m_hyperlinkRegions);
- rlist.AddRange(m_knownRegions.Values);
- foreach (RegionInfo info in rlist)
- {
- if (info.RegionHandle == ihandle)
- {
- try
- {
- ohandle = Convert.ToInt64(info.regionSecret);
- m_log.Info("[HGrid] remote region " + ohandle);
- }
- catch
- {
- m_log.Error("[HGrid] Could not convert secret for " + ihandle + " (" + info.regionSecret + ")");
- }
- break;
- }
- }
- return ohandle < 0 ? ihandle : (ulong)ohandle;
- }
- #endregion
-
- #region Misc
-
- protected bool IsComingHome(ForeignUserProfileData userData)
- {
- return (userData.UserServerURI == HGNetworkServersInfo.Singleton.LocalUserServerURI);
- }
-
- protected bool IsGoingHome(CachedUserInfo uinfo, RegionInfo rinfo)
- {
- if (uinfo.UserProfile == null)
- return false;
-
- string userUserServerURI = String.Empty;
- if (uinfo.UserProfile is ForeignUserProfileData)
- {
- userUserServerURI = HGNetworkServersInfo.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
- }
-
- return ((uinfo.UserProfile.HomeRegionID == rinfo.RegionID) &&
- (userUserServerURI != HGNetworkServersInfo.Singleton.LocalUserServerURI));
- }
-
- protected bool IsLocalUser(CachedUserInfo uinfo)
- {
- if (uinfo == null)
- return true;
-
- if (uinfo.UserProfile is ForeignUserProfileData)
- return HGNetworkServersInfo.Singleton.IsLocalUser(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
- else
- return true;
-
- }
-
- protected bool IsLocalRegion(ulong handle)
- {
- foreach (RegionInfo reg in m_regionsOnInstance)
- if (reg.RegionHandle == handle)
- return true;
- return false;
- }
-
- 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(" >> HomeHandle: " + userData.HomeRegion);
- m_log.Info(" >> HomeX: " + userData.HomeRegionX);
- m_log.Info(" >> HomeY: " + userData.HomeRegionY);
- m_log.Info(" >> UserServer: " + userData.UserServerURI);
- m_log.Info(" >> InvServer: " + userData.UserInventoryURI);
- m_log.Info(" >> AssetServer: " + userData.UserAssetURI);
- m_log.Info(" ------------ -------------- ----------");
- }
-
- private void DumpRegionData(RegionInfo rinfo)
- {
- m_log.Info(" ------------ Region Data Dump ----------");
- m_log.Info(" >> handle: " + rinfo.RegionHandle);
- m_log.Info(" >> coords: " + rinfo.RegionLocX + ", " + rinfo.RegionLocY);
- m_log.Info(" >> secret: " + rinfo.regionSecret);
- m_log.Info(" >> remoting address: " + rinfo.RemotingAddress);
- m_log.Info(" >> remoting port: " + rinfo.RemotingPort);
- 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
-
-
- }
-}
diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs
deleted file mode 100644
index 5ce1e79c71..0000000000
--- a/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs
+++ /dev/null
@@ -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);
-
- ///
- /// Encapsulate remote backend services for manipulation of grid regions
- ///
- 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 RequestNeighbours(uint x, uint y)
- {
- List neighbours = m_remoteBackend.RequestNeighbours(x, y);
- //List 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 RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
- {
- List neighbours = m_remoteBackend.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
- List 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 RequestNamedRegions(string name, int maxNumber)
- {
- List infos = m_remoteBackend.RequestNamedRegions(name, maxNumber);
- List remotes = base.RequestNamedRegions(name, maxNumber);
- infos.AddRange(remotes);
- return infos;
- }
-
- #endregion
-
-
- }
-}
diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs
deleted file mode 100644
index 94cfc496bb..0000000000
--- a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs
+++ /dev/null
@@ -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);
-
- ///
- /// Encapsulate local backend services for manipulation of local regions
- ///
- protected LocalBackEndServices m_localBackend = new LocalBackEndServices();
-
- //private Dictionary m_deadRegionCache = new Dictionary();
-
- 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 RequestNeighbours(uint x, uint y)
- {
- List neighbours = m_localBackend.RequestNeighbours(x, y);
- //List 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 RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
- {
- //m_log.Info("[HGrid] Request map blocks " + minX + "-" + minY + "-" + maxX + "-" + maxY);
- List neighbours = m_localBackend.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
- List 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 RequestNamedRegions(string name, int maxNumber)
- {
- List infos = m_localBackend.RequestNamedRegions(name, maxNumber);
- List remotes = base.RequestNamedRegions(name, maxNumber);
- infos.AddRange(remotes);
- return infos;
- }
-
- #endregion
-
- #region XML Request Handlers
-
- ///
- /// A ping / version check
- ///
- ///
- ///
- 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
- ///
- /// Ooops, our Agent must be dead if we're getting this request!
- ///
- ///
- ///
- 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();
- }
-
- ///
- /// Someone asked us about parcel-information
- ///
- ///
- ///
- 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
-
- }
-}
diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
index a658416ce0..99bcea3d2a 100644
--- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
+++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
@@ -53,8 +53,6 @@ namespace OpenSim.Region.Communications.Local
m_avatarService = lus;
m_messageService = lus;
- m_gridService = new LocalBackEndServices();
-
//LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, backendService);
}
}
diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
deleted file mode 100644
index 0ab9374789..0000000000
--- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
+++ /dev/null
@@ -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 m_regions = new Dictionary();
-
- protected Dictionary m_regionListeners =
- new Dictionary();
-
- // private Dictionary m_remoteRegionInfoCache = new Dictionary();
-
- private Dictionary m_queuedGridSettings = new Dictionary();
-
- 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; }
- }
-
- ///
- /// Register a region method with the BackEnd Services.
- ///
- ///
- ///
- 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;
- }
-
- ///
- ///
- ///
- ///
- public List RequestNeighbours(uint x, uint y)
- {
- // m_log.Debug("Finding Neighbours to " + regionInfo.RegionHandle);
- List neighbours = new List();
-
- 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;
- }
-
- ///
- /// Get information about a neighbouring region
- ///
- ///
- ///
- public RegionInfo RequestNeighbourInfo(ulong regionHandle)
- {
- if (m_regions.ContainsKey(regionHandle))
- {
- return m_regions[regionHandle];
- }
-
- return null;
- }
-
- ///
- /// Get information about a neighbouring region
- ///
- ///
- ///
- 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;
- }
-
- ///
- /// Get information about a neighbouring region
- ///
- ///
- ///
- public RegionInfo RequestNeighbourInfo(string name)
- {
- foreach (RegionInfo info in m_regions.Values)
- {
- if (info.RegionName == name)
- return info;
- }
-
- return null;
- }
-
- ///
- /// Get information about a neighbouring region
- ///
- ///
- ///
- 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;
- }
-
- ///
- /// Get information about the closet region given a region name.
- ///
- ///
- ///
- public RegionInfo RequestClosestRegion(string regionName)
- {
- foreach (RegionInfo regInfo in m_regions.Values)
- {
- if (regInfo.RegionName == regionName)
- return regInfo;
- }
- return null;
- }
-
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
- {
- List mapBlocks = new List();
- 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 GetGridSettings()
- {
- Dictionary returnGridSettings = new Dictionary();
- lock (m_queuedGridSettings)
- {
- returnGridSettings = m_queuedGridSettings;
- m_queuedGridSettings.Clear();
- }
-
- return returnGridSettings;
- }
-
- public virtual void SetForcefulBanlistsDisallowed()
- {
- m_queuedGridSettings.Add("allow_forceful_banlines", "FALSE");
- }
-
-
- ///
- /// Is a Sandbox mode method, used by the local Login server to inform a region of a connection user/session
- ///
- ///
- ///
- ///
- 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 RequestNamedRegions (string name, int maxNumber)
- {
- List lowercase_regions = new List();
- List regions = new List();
- 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;
- }
- }
-}
diff --git a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs
index 8b5779feb4..c2b8f26972 100644
--- a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs
+++ b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs
@@ -39,8 +39,6 @@ namespace OpenSim.Region.Communications.OGS1
LibraryRootFolder libraryRootFolder)
: base(serversInfo, libraryRootFolder)
{
- OGS1GridServices gridInterComms = new OGS1GridServices(serversInfo);
- m_gridService = gridInterComms;
// This plugin arrangement could eventually be configurable rather than hardcoded here.
OGS1UserServices userServices = new OGS1UserServices(this);
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
deleted file mode 100644
index 47c7fe4057..0000000000
--- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
+++ /dev/null
@@ -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;
- ///
- /// Encapsulate local backend services for manipulation of local regions
- ///
- private LocalBackEndServices m_localBackend = new LocalBackEndServices();
-
- private Dictionary m_remoteRegionInfoCache = new Dictionary();
- // private List m_knownRegions = new List();
- private Dictionary m_deadRegionCache = new Dictionary();
- private Dictionary m_queuedGridSettings = new Dictionary();
- private List m_regionsOnInstance = new List();
-
- 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; }
- }
-
- ///
- /// Contructor. Adds "expect_user" and "check" xmlrpc method handlers
- ///
- ///
- ///
- 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 GetGridSettings()
- {
- Dictionary returnGridSettings = new Dictionary();
- 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 RequestNeighbours(uint x, uint y)
- {
- Hashtable respData = MapBlockQuery((int) x - 1, (int) y - 1, (int) x + 1, (int) y + 1);
-
- List neighbours = new List();
-
- 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;
- }
-
- ///
- /// Request information about a region.
- ///
- ///
- ///
- /// 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.
- ///
- 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;
- }
-
- ///
- /// Request information about a region.
- ///
- ///
- ///
- 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;
- }
-
- ///
- /// Get information about a neighbouring region
- ///
- ///
- ///
- public RegionInfo RequestNeighbourInfo(string name)
- {
- // Not implemented yet
- return null;
- }
-
- ///
- /// Get information about a neighbouring region
- ///
- ///
- ///
- 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;
- }
-
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public List 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 neighbours = new List();
-
- 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;
- }
-
- ///
- /// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates
- ///
- /// REDUNDANT - OGS1 is to be phased out in favour of OGS2
- /// Minimum X value
- /// Minimum Y value
- /// Maximum X value
- /// Maximum Y value
- /// Hashtable of hashtables containing map data elements
- 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();
- }
- }
-
- ///
- /// A ping / version check
- ///
- ///
- ///
- 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;
- }
-
- ///
- /// 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.
- ///
- ///
- ///
- 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
- ///
- /// Ooops, our Agent must be dead if we're getting this request!
- ///
- ///
- ///
- 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
- ///
- /// Someone asked us about parcel-information
- ///
- ///
- ///
- 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 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 infos = new List();
- 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;
- }
- }
- }
-}
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 49b2b5c804..dd9b318b1a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -40,6 +40,7 @@ using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.Avatar.Friends
{
@@ -108,7 +109,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
private Dictionary m_scenes = new Dictionary();
private IMessageTransferModule m_TransferModule = null;
- private IGridServices m_gridServices = null;
+ private IGridService m_gridServices = null;
#region IRegionModule Members
@@ -142,7 +143,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (m_scenes.Count > 0)
{
m_TransferModule = m_initialScene.RequestModuleInterface();
- m_gridServices = m_initialScene.CommsManager.GridService;
+ m_gridServices = m_initialScene.GridService;
}
if (m_TransferModule == null)
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 tpdAway = new List();
// 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)
{
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)
{
// 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)
{
m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}", destRegionHandle);
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index 4495303038..e5159b3817 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -36,6 +36,7 @@ using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{
@@ -497,7 +498,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{
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)
{
Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im);
@@ -559,7 +563,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
/// RegionInfo we pull the data out of to send the request to
/// The Instant Message data Hashtable
/// Bool if the message was successfully delivered at the other side.
- protected virtual bool doIMSending(RegionInfo reginfo, Hashtable xmlrpcdata)
+ protected virtual bool doIMSending(GridRegion reginfo, Hashtable xmlrpcdata)
{
ArrayList SendParams = new ArrayList();
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
index ebd9a72d85..ad05babec3 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
@@ -35,6 +35,7 @@ using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
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.
// 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;
}
result[indices[i]] = new PresenceInfo(uuids[i], regionID);
@@ -349,6 +353,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
private void NotifyMessageServerOfShutdown(Scene scene)
{
+ if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
+ return;
+
Hashtable xmlrpcdata = new Hashtable();
xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString();
ArrayList SendParams = new ArrayList();
@@ -372,6 +379,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
private void NotifyMessageServerOfAgentLocation(UUID agentID, UUID region, ulong regionHandle)
{
+ if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
+ return;
+
Hashtable xmlrpcdata = new Hashtable();
xmlrpcdata["AgentID"] = agentID.ToString();
xmlrpcdata["RegionUUID"] = region.ToString();
@@ -397,6 +407,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
private void NotifyMessageServerOfAgentLeaving(UUID agentID, UUID region, ulong regionHandle)
{
+ if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
+ return;
+
Hashtable xmlrpcdata = new Hashtable();
xmlrpcdata["AgentID"] = agentID.ToString();
xmlrpcdata["RegionUUID"] = region.ToString();
diff --git a/OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs b/OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs
deleted file mode 100644
index 8c92727041..0000000000
--- a/OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs
+++ /dev/null
@@ -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);
-
- }
-
- ///
- /// Returns an XML RPC response to a simulator profile request
- ///
- ///
- ///
- 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 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;
- }
-
- }
-}
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
index 677406052b..a0ccdc7276 100644
--- a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
@@ -34,6 +34,7 @@ using OpenSim.Framework;
using OpenSim.Region.CoreModules.World.WorldMap;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
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)
{
- List mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4);
+ List mapBlocks = new List();
+ List 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
FillInMap(mapBlocks, minX, minY, maxX, maxY);
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
index 4fbee7f4c8..9bf31a4131 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
@@ -37,6 +37,8 @@ using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;
using OpenSim.Server.Handlers.Base;
using OpenSim.Server.Handlers.Grid;
+using OpenSim.Services.Interfaces;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
{
@@ -94,6 +96,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
if (!m_Enabled)
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)
{
m_Registered = true;
@@ -102,27 +117,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
Object[] args = new Object[] { m_Config, MainServer.Instance };
- m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance);
- //ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
+ m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance, scene.RequestModuleInterface());
+ //ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
}
- SimpleRegionInfo rinfo = new SimpleRegionInfo(scene.RegionInfo);
+ GridRegion rinfo = new GridRegion(scene.RegionInfo);
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
}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs
index a31ce8e59f..8a903701fa 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs
@@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour
#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}",
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);
- return false;
+ return null;
}
#endregion INeighbourService
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
index 36915effb5..0974372cd4 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
@@ -86,7 +86,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
private void RunHGCommand(string command, string[] cmdparams)
{
- if (command.Equals("linkk-mapping"))
+ if (command.Equals("link-mapping"))
{
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)
{
@@ -187,7 +187,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
}
return;
}
- else if (command.Equals("unlinkk-region"))
+ else if (command.Equals("unlink-region"))
{
if (cmdparams.Length < 1)
{
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
index 0c2a835c13..1eb481e0a7 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
@@ -31,6 +31,7 @@ using System.Net;
using System.Reflection;
using System.Xml;
+using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
@@ -47,15 +48,19 @@ using Nini.Config;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
{
- public class HGGridConnector : ISharedRegionModule, IGridService
+ public class HGGridConnector : ISharedRegionModule, IGridService, IHyperlinkService
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
+ private static string LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI;
private bool m_Enabled = false;
private bool m_Initialized = false;
+ private Scene m_aScene;
+ private Dictionary m_LocalScenes = new Dictionary();
+
private IGridService m_GridServiceConnector;
private HypergridServiceConnector m_HypergridServiceConnector;
@@ -130,6 +135,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public void PostInitialise()
{
+ if (m_Enabled)
+ ((ISharedRegionModule)m_GridServiceConnector).PostInitialise();
}
public void Close()
@@ -141,12 +148,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if (!m_Enabled)
return;
+ m_LocalScenes[scene.RegionInfo.RegionHandle] = scene;
scene.RegisterModuleInterface(this);
+ scene.RegisterModuleInterface(this);
+
+ ((ISharedRegionModule)m_GridServiceConnector).AddRegion(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)
@@ -156,29 +172,28 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
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);
+
HGCommands hgCommands = new HGCommands(this, scene);
- MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-region",
+ MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-region",
"link-region :[:] ",
"Link a hypergrid region", hgCommands.RunCommand);
- MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlinkk-region",
+ MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlink-region",
"unlink-region or : ",
"Unlink a hypergrid region", hgCommands.RunCommand);
- MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-mapping", "link-mapping [ ] ",
+ MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-mapping", "link-mapping [ ] ",
"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;
}
-
-
- //scene.AddCommand("HGGridServicesConnector", "linkk-region",
- // "link-region :[:] ",
- // "Link a hypergrid region", hgCommands.RunCommand);
- //scene.AddCommand("HGGridServicesConnector", "unlinkk-region",
- // "unlink-region or : ",
- // "Unlink a hypergrid region", hgCommands.RunCommand);
- //scene.AddCommand("HGGridServicesConnector", "linkk-mapping", "link-mapping [ ] ",
- // "Set local coordinate to map HG regions to", hgCommands.RunCommand);
-
}
#endregion
@@ -250,7 +265,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
// Try the foreign users home collection
foreach (GridRegion r in m_knownRegions.Values)
if (r.RegionID == regionID)
- return m_knownRegions[regionID];
+ return r;
// Finally, try the normal route
return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID);
@@ -271,7 +286,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
foreach (GridRegion r in m_knownRegions.Values)
{
if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
+ {
return r;
+ }
}
// Finally, try the normal route
@@ -338,8 +355,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle)
{
- m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo);
- m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle);
+ m_HyperlinkRegions[regionInfo.RegionID] = regionInfo;
+ m_HyperlinkHandles[regionInfo.RegionID] = regionHandle;
}
private void RemoveHyperlinkRegion(UUID regionID)
@@ -350,8 +367,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle)
{
- m_knownRegions.Add(userID, regionInfo);
- m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle);
+ m_knownRegions[userID] = regionInfo;
+ m_HyperlinkHandles[regionInfo.RegionID] = regionHandle;
}
private void RemoveHyperlinkHomeRegion(UUID regionID)
@@ -367,10 +384,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
}
#endregion
- #region Hyperlinks
+ #region IHyperlinkService
private static Random random = new Random();
+
public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc)
{
string host = "127.0.0.1";
@@ -417,10 +435,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return null;
}
+
// From the map search and secondlife://blah
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);
}
@@ -447,15 +466,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
}
// Finally, link it
- try
- {
- RegisterRegion(UUID.Zero, regInfo);
- }
- catch (Exception e)
- {
- m_log.Warn("[HGrid]: Unable to link region: " + e.Message);
- return false;
- }
+ if (!RegisterRegion(UUID.Zero, regInfo))
+ {
+ m_log.Warn("[HGrid]: Unable to link region");
+ return false;
+ }
int x, y;
if (!Check4096(m_scene, regInfo, out x, out y))
@@ -554,7 +569,227 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
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
+ #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
+
+
}
}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
index 743d3b9a66..6c2928a3d6 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
@@ -31,6 +31,7 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using OpenSim.Framework;
+using OpenSim.Framework.Console;
using OpenSim.Server.Base;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
@@ -47,7 +48,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
+ private static LocalGridServicesConnector m_MainInstance;
+
private IGridService m_GridService;
+ private Dictionary m_LocalCache = new Dictionary();
private bool m_Enabled = false;
@@ -58,6 +62,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public LocalGridServicesConnector(IConfigSource source)
{
m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated");
+ m_MainInstance = this;
InitialiseService(source);
}
@@ -82,6 +87,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if (name == Name)
{
InitialiseService(source);
+ m_MainInstance = this;
m_Enabled = true;
m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled");
}
@@ -120,6 +126,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
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()
@@ -128,14 +140,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public void AddRegion(Scene scene)
{
- if (!m_Enabled)
- return;
+ if (m_Enabled)
+ scene.RegisterModuleInterface(this);
- scene.RegisterModuleInterface(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)
{
+ if (m_MainInstance == this)
+ {
+ m_LocalCache[scene.RegionInfo.RegionID].Clear();
+ m_LocalCache.Remove(scene.RegionInfo.RegionID);
+ }
}
public void RegionLoaded(Scene scene)
@@ -158,7 +182,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public List 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();
+ }
+
+ // Don't go to the DB
+ //return m_GridService.GetNeighbours(scopeID, regionID);
}
public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
@@ -187,5 +222,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
}
#endregion
+
+ public void NeighboursCommand(string module, string[] cmdparams)
+ {
+ foreach (KeyValuePair kvp in m_LocalCache)
+ {
+ m_log.InfoFormat("*** Neighbours of {0} {1} ***", kvp.Key, kvp.Value.RegionName);
+ List 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);
+ }
+ }
}
}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs
new file mode 100644
index 0000000000..ea205a24c1
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs
@@ -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 m_neighbours = new Dictionary();
+
+ 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 GetNeighbours()
+ {
+ return new List(m_neighbours.Values);
+ }
+ }
+}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
index 91a808b21f..72c00fc02d 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
@@ -104,6 +104,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public void PostInitialise()
{
+ if (m_LocalGridService != null)
+ ((ISharedRegionModule)m_LocalGridService).PostInitialise();
}
public void Close()
@@ -112,14 +114,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public void AddRegion(Scene scene)
{
- if (!m_Enabled)
- return;
+ if (m_Enabled)
+ scene.RegisterModuleInterface(this);
- scene.RegisterModuleInterface(this);
+ if (m_LocalGridService != null)
+ ((ISharedRegionModule)m_LocalGridService).AddRegion(scene);
}
public void RemoveRegion(Scene scene)
{
+ if (m_LocalGridService != null)
+ ((ISharedRegionModule)m_LocalGridService).RemoveRegion(scene);
}
public void RegionLoaded(Scene scene)
@@ -146,7 +151,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
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 GetNeighbours(UUID scopeID, UUID regionID)
+ {
+ return m_LocalGridService.GetNeighbours(scopeID, regionID);
+ }
public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
{
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
index 9519e23375..696225cddc 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
@@ -42,6 +42,8 @@ using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Hypergrid;
using OpenSim.Region.Framework.Scenes.Serialization;
+using OpenSim.Services.Interfaces;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
{
@@ -59,6 +61,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
protected RegionToRegionClient m_regionClient;
+ protected IHyperlinkService m_hyperlinkService;
+
protected bool m_safemode;
protected IPAddress m_thisIP;
@@ -134,7 +138,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
m_localBackend = new LocalInterregionComms();
m_commsManager = scene.CommsManager;
m_aScene = scene;
- m_regionClient = new RegionToRegionClient(m_aScene);
+ m_hyperlinkService = m_aScene.RequestModuleInterface();
+ m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService);
m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName);
}
@@ -161,7 +166,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing
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)
{
m_regionClient.SendUserInformation(regInfo, aCircuit);
@@ -183,7 +190,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing
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)
{
return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData);
@@ -204,7 +213,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing
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)
{
return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData);
@@ -225,7 +236,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing
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)
{
return m_regionClient.DoRetrieveRootAgentCall(regInfo, id, out agent);
@@ -257,7 +270,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing
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)
{
return m_regionClient.DoCloseAgentCall(regInfo, id);
@@ -284,7 +299,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
// else do the remote thing
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)
{
return m_regionClient.DoCreateObjectCall(
@@ -776,16 +793,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
protected class RegionToRegionClient : RegionClient
{
Scene m_aScene = null;
+ IHyperlinkService m_hyperlinkService;
- public RegionToRegionClient(Scene s)
+ public RegionToRegionClient(Scene s, IHyperlinkService hyperService)
{
m_aScene = s;
+ m_hyperlinkService = hyperService;
}
public override ulong GetRegionHandle(ulong handle)
{
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;
}
@@ -793,29 +815,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
public override bool IsHyperlink(ulong handle)
{
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;
}
- public override void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit)
+ public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit)
{
- try
- {
- if (m_aScene.SceneGridService is HGSceneCommunicationService)
- {
- ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.SendUserInformation(regInfo, aCircuit);
- }
- }
- catch // Bad cast
- { }
+ if (m_hyperlinkService != null)
+ m_hyperlinkService.SendUserInformation(regInfo, aCircuit);
}
public override void AdjustUserInformation(AgentCircuitData aCircuit)
{
- if (m_aScene.SceneGridService is HGSceneCommunicationService)
- ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.AdjustUserInformation(aCircuit);
+ if (m_hyperlinkService != null)
+ m_hyperlinkService.AdjustUserInformation(aCircuit);
}
}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index 1c66254aca..fd1a75926a 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -525,7 +525,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
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('/');
if ((userInventoryServerURI == uri) || (userInventoryServerURI == ""))
@@ -544,7 +549,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
if ((uinfo == null) || (uinfo.UserProfile == null))
return invURI;
- string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI);
+ string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
if ((userInventoryServerURI != null) &&
(userInventoryServerURI != ""))
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs
index a52c70be55..b0ace3959d 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs
@@ -37,6 +37,7 @@ using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using OpenSim.Server.Base;
+
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land
{
public class RemoteLandServicesConnector :
@@ -89,7 +90,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land
if (!m_Enabled)
return;
- m_MapService = scene.CommsManager.GridService;
+ m_GridService = scene.GridService;
m_LocalService.AddRegion(scene);
scene.RegisterModuleInterface(this);
}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
index 61bf481984..daba0b3bb4 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
@@ -119,7 +119,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
#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}",
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);
- return false;
+ return null;
}
#endregion INeighbourService
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs
index c5bc03b0ed..c6fc2a1475 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs
@@ -118,7 +118,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
if (!m_Enabled)
return;
- m_MapService = scene.CommsManager.GridService;
m_LocalService.AddRegion(scene);
scene.RegisterModuleInterface(this);
}
@@ -134,16 +133,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
if (!m_Enabled)
return;
+ m_GridService = scene.GridService;
+
m_log.InfoFormat("[NEIGHBOUR CONNECTOR]: Enabled remote neighbours for region {0}", scene.RegionInfo.RegionName);
}
#region INeighbourService
- public override bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
+ public override GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
{
- if (m_LocalService.HelloNeighbour(regionHandle, thisRegion))
- return true;
+ GridRegion region = m_LocalService.HelloNeighbour(regionHandle, thisRegion);
+ if (region != null)
+ return region;
return base.HelloNeighbour(regionHandle, thisRegion);
}
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 76ff6da969..fdff61e187 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -36,10 +36,12 @@ using OpenSim.Framework;
using OpenSim.Framework.Capabilities;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
+using OpenSim.Services.Interfaces;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Physics.Manager;
using Caps=OpenSim.Framework.Capabilities.Caps;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.World.Land
{
@@ -1301,7 +1303,7 @@ namespace OpenSim.Region.CoreModules.World.Land
else
{
// 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)
parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y);
}
@@ -1359,9 +1361,10 @@ namespace OpenSim.Region.CoreModules.World.Land
}
else
{
- extLandData.landData = m_scene.CommsManager.GridService.RequestLandData(extLandData.regionHandle,
- extLandData.x,
- extLandData.y);
+ ILandService landService = m_scene.RequestModuleInterface();
+ extLandData.landData = landService.GetLandData(extLandData.regionHandle,
+ extLandData.x,
+ extLandData.y);
if (extLandData.landData == null)
{
// we didn't find the region/land => don't cache
@@ -1373,20 +1376,27 @@ namespace OpenSim.Region.CoreModules.World.Land
if (data != null) // if we found some data, send it
{
- RegionInfo info;
+ GridRegion info;
if (data.regionHandle == m_scene.RegionInfo.RegionHandle)
{
- info = m_scene.RegionInfo;
+ info = new GridRegion(m_scene.RegionInfo);
}
else
{
// 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.
m_log.DebugFormat("[LAND] got parcelinfo for parcel {0} in region {1}; sending...",
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
m_log.Debug("[LAND] got no parcelinfo; not sending");
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index 4783b3525e..436f332f1d 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -33,6 +33,8 @@ using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Hypergrid;
+using OpenSim.Services.Interfaces;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.World.WorldMap
{
@@ -92,13 +94,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
}
// try to fetch from GridServer
- List regionInfos = m_scene.SceneGridService.RequestNamedRegions(mapName, 20);
+ List regionInfos = m_scene.GridService.GetRegionsByName(UUID.Zero, mapName, 20);
if (regionInfos == null)
{
m_log.Warn("[MAPSEARCHMODULE]: RequestNamedRegions returned null. Old gridserver?");
// service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region
- regionInfos = new List();
- RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName);
+ regionInfos = new List();
+ GridRegion info = m_scene.GridService.GetRegionByName(UUID.Zero, mapName);
if (info != null) regionInfos.Add(info);
}
@@ -109,11 +111,15 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
if (mapName.Contains(".") && mapName.Contains(":"))
{
// It probably is a domain name. Try to link to it.
- RegionInfo regInfo;
+ GridRegion regInfo;
Scene cScene = GetClientScene(remoteClient);
- regInfo = HGHyperlink.TryLinkRegion(cScene, remoteClient, mapName);
- if (regInfo != null)
- regionInfos.Add(regInfo);
+ IHyperlinkService hyperService = cScene.RequestModuleInterface();
+ if (hyperService != null)
+ {
+ regInfo = hyperService.TryLinkRegion(remoteClient, mapName);
+ if (regInfo != null)
+ regionInfos.Add(regInfo);
+ }
}
}
@@ -122,17 +128,17 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
MapBlockData data;
if (regionInfos.Count > 0)
{
- foreach (RegionInfo info in regionInfos)
+ foreach (GridRegion info in regionInfos)
{
data = new MapBlockData();
data.Agents = 0;
- data.Access = info.AccessLevel;
- data.MapImageId = info.RegionSettings.TerrainImageID;
+ data.Access = info.Access;
+ data.MapImageId = info.TerrainImage;
data.Name = info.RegionName;
data.RegionFlags = 0; // TODO not used?
data.WaterHeight = 0; // not used
- data.X = (ushort)info.RegionLocX;
- data.Y = (ushort)info.RegionLocY;
+ data.X = (ushort)(info.RegionLocX / Constants.RegionSize);
+ data.Y = (ushort)(info.RegionLocY / Constants.RegionSize);
blocks.Add(data);
}
}
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 1f25f28f9c..05ed70a15d 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -48,6 +48,7 @@ using OpenSim.Region.Framework.Scenes;
using Caps=OpenSim.Framework.Capabilities.Caps;
using OSDArray=OpenMetaverse.StructuredData.OSDArray;
using OSDMap=OpenMetaverse.StructuredData.OSDMap;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.World.WorldMap
{
@@ -232,10 +233,20 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
}
if (lookup)
{
- List mapBlocks;
+ List mapBlocks = new List(); ;
- 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);
- avatarPresence.ControllingClient.SendMapBlock(mapBlocks,0);
+ List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
+ (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)
cachedMapBlocks = mapBlocks;
@@ -579,7 +590,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
}
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)
{
@@ -719,15 +732,25 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
{
List response = new List();
- // this should return one mapblock at most. But make sure: Look whether the one we requested is in there
- List mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
- if (mapBlocks != null)
+ // this should return one mapblock at most.
+ // (diva note: why?? in that case we should GetRegionByPosition)
+ // But make sure: Look whether the one we requested is in there
+ List 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
+ MapBlockData block = new MapBlockData();
+ MapBlockFromGridRegion(block, r);
response.Add(block);
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)
{
- List mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4);
+ List mapBlocks = new List();
+ List 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);
}
+ 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)
{
m_log.Debug("[WORLD MAP]: Sending map image jpeg");
@@ -874,31 +917,34 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
m_log.InfoFormat(
"[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath);
- List mapBlocks =
- m_scene.CommsManager.GridService.RequestNeighbourMapBlocks(
- (int)(m_scene.RegionInfo.RegionLocX - 9),
- (int)(m_scene.RegionInfo.RegionLocY - 9),
- (int)(m_scene.RegionInfo.RegionLocX + 9),
- (int)(m_scene.RegionInfo.RegionLocY + 9));
+ List mapBlocks = new List();
+ List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
+ (int)(m_scene.RegionInfo.RegionLocX - 9) * (int)Constants.RegionSize,
+ (int)(m_scene.RegionInfo.RegionLocX + 9) * (int)Constants.RegionSize,
+ (int)(m_scene.RegionInfo.RegionLocY - 9) * (int)Constants.RegionSize,
+ (int)(m_scene.RegionInfo.RegionLocY + 9) * (int)Constants.RegionSize);
List textures = new List();
List bitImages = new List();
- 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());
if (texAsset != null)
{
textures.Add(texAsset);
}
- else
- {
- texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
- if (texAsset != null)
- {
- textures.Add(texAsset);
- }
- }
+ //else
+ //{
+ // // WHAT?!? This doesn't seem right. Commenting (diva)
+ // texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
+ // if (texAsset != null)
+ // {
+ // textures.Add(texAsset);
+ // }
+ //}
}
foreach (AssetBase asset in textures)
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 287d8d9f7a..7424b24781 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -32,6 +32,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Client;
using OpenSim.Region.Framework.Interfaces;
using Caps=OpenSim.Framework.Capabilities.Caps;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
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 event Attach OnAttach;
+ public delegate void RegionUp(GridRegion region);
+ public event RegionUp OnRegionUp;
+
public class MoneyTransferArgs : EventArgs
{
public UUID sender;
@@ -446,6 +450,7 @@ namespace OpenSim.Region.Framework.Scenes
private EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = null;
private Attach handlerOnAttach = null;
+ private RegionUp handlerOnRegionUp = null;
public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID)
{
@@ -1035,5 +1040,13 @@ namespace OpenSim.Region.Framework.Scenes
if (handlerSetRootAgentScene != null)
handlerSetRootAgentScene(agentID, scene);
}
+
+ public void TriggerOnRegionUp(GridRegion otherRegion)
+ {
+ handlerOnRegionUp = OnRegionUp;
+ if (handlerOnRegionUp != null)
+ handlerOnRegionUp(otherRegion);
+ }
+
}
}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
index 62efd60506..b6fa41de6a 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Communications.Clients;
using OpenSim.Region.Framework.Scenes.Serialization;
+using OpenSim.Services.Interfaces;
//using HyperGrid.Framework;
//using OpenSim.Region.Communications.Hypergrid;
@@ -50,6 +51,18 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
// private Dictionary m_inventoryServers = new Dictionary();
private Scene m_scene;
+
+ private IHyperlinkService m_hyper;
+ IHyperlinkService HyperlinkService
+ {
+ get
+ {
+ if (m_hyper == null)
+ m_hyper = m_scene.RequestModuleInterface();
+ return m_hyper;
+ }
+ }
+
#endregion
#region Constructor
@@ -79,22 +92,6 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
// 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)
{
@@ -170,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
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
// and place an entry in m_assetMap
@@ -228,7 +225,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
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
// and place an entry in m_assetMap
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs
deleted file mode 100644
index a576febf1b..0000000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs
+++ /dev/null
@@ -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;
- }
- }
-
- ///
- /// Cope with this viewer limitation.
- ///
- ///
- ///
- 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;
- }
-
- }
-}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
index bf55df7c42..b1981b6536 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
@@ -29,6 +29,7 @@ using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes.Hypergrid
{
@@ -50,7 +51,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
if (UserProfile != null)
{
- RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion);
+ GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
//if (regionInfo != null)
//{
// UserProfile.HomeRegionID = regionInfo.RegionID;
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
index efc644dbd4..1217f9bd9a 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
@@ -38,6 +38,8 @@ using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Capabilities;
using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Services.Interfaces;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
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);
- public readonly IHyperlink m_hg;
-
- public HGSceneCommunicationService(CommunicationsManager commsMan, IHyperlink hg) : base(commsMan)
+ private IHyperlinkService m_hg;
+ IHyperlinkService HyperlinkService
+ {
+ get
+ {
+ if (m_hg == null)
+ m_hg = m_scene.RequestModuleInterface();
+ return m_hg;
+ }
+ }
+
+ public HGSceneCommunicationService(CommunicationsManager commsMan) : base(commsMan)
{
- m_hg = hg;
}
@@ -112,7 +122,10 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
}
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)
{
@@ -125,13 +138,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
/// Hypergrid mod start
///
///
- bool isHyperLink = m_hg.IsHyperlinkRegion(reg.RegionHandle);
+ bool isHyperLink = (HyperlinkService.GetHyperlinkRegion(reg.RegionHandle) != null);
bool isHomeUser = true;
ulong realHandle = regionHandle;
CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID);
if (uinfo != null)
{
- isHomeUser = HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile);
+ isHomeUser = HyperlinkService.IsLocalUser(uinfo.UserProfile.ID);
realHandle = m_hg.FindRegionHandle(regionHandle);
m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString());
}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d8478a24f2..bb47ff407f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -49,6 +49,7 @@ using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Region.Physics.Manager;
using Timer=System.Timers.Timer;
using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
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();
+
+ 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 IWorldComm m_worldCommModule;
protected IAvatarFactory m_AvatarFactory;
@@ -566,10 +587,7 @@ namespace OpenSim.Region.Framework.Scenes
}
///
- /// Another region is up. Gets called from Grid Comms:
- /// (OGS1 -> LocalBackEnd -> RegionListened -> SceneCommunicationService)
- /// We have to tell all our ScenePresences about it, and add it to the
- /// neighbor list.
+ /// Another region is up.
///
/// 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
@@ -578,47 +596,30 @@ namespace OpenSim.Region.Framework.Scenes
///
/// RegionInfo handle for the new region.
/// True after all operations complete, throws exceptions otherwise.
- 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)
{
- 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
- int resultX = Math.Abs((int)otherRegion.RegionLocX - (int)RegionInfo.RegionLocX);
- int resultY = Math.Abs((int)otherRegion.RegionLocY - (int)RegionInfo.RegionLocY);
+ int resultX = Math.Abs((int)xcell - (int)RegionInfo.RegionLocX);
+ int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY);
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
{
ForEachScenePresence(delegate(ScenePresence agent)
@@ -632,7 +633,7 @@ namespace OpenSim.Region.Framework.Scenes
List old = new List();
old.Add(otherRegion.RegionHandle);
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.
m_log.Error("[SCENE]: Couldn't inform client of regionup because we got a null reference exception");
}
+
}
else
{
@@ -651,7 +653,6 @@ namespace OpenSim.Region.Framework.Scenes
otherRegion.RegionLocY.ToString() + ")");
}
}
- return true;
}
public void AddNeighborRegion(RegionInfo region)
@@ -683,9 +684,10 @@ namespace OpenSim.Region.Framework.Scenes
}
// 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);
}
///
@@ -1336,24 +1338,31 @@ namespace OpenSim.Region.Framework.Scenes
RegisterCommsEvents();
// 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(), RegionInfo);
- Dictionary dGridSettings = m_sceneGridService.GetGridSettings();
+ //Dictionary dGridSettings = m_sceneGridService.GetGridSettings();
- if (dGridSettings.ContainsKey("allow_forceful_banlines"))
- {
- if (dGridSettings["allow_forceful_banlines"] != "TRUE")
- {
- m_log.Info("[GRID]: Grid is disabling forceful parcel banlists");
- EventManager.TriggerSetAllowForcefulBan(false);
- }
- else
- {
- m_log.Info("[GRID]: Grid is allowing forceful parcel banlists");
- EventManager.TriggerSetAllowForcefulBan(true);
- }
- }
+ //if (dGridSettings.ContainsKey("allow_forceful_banlines"))
+ //{
+ // if (dGridSettings["allow_forceful_banlines"] != "TRUE")
+ // {
+ // m_log.Info("[GRID]: Grid is disabling forceful parcel banlists");
+ // EventManager.TriggerSetAllowForcefulBan(false);
+ // }
+ // else
+ // {
+ // m_log.Info("[GRID]: Grid is allowing forceful parcel banlists");
+ // EventManager.TriggerSetAllowForcefulBan(true);
+ // }
+ //}
}
///
@@ -2717,10 +2726,12 @@ namespace OpenSim.Region.Framework.Scenes
UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId);
if (UserProfile != null)
{
- RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegionID);
+ GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
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
{
UserProfile.HomeRegionID = regionInfo.RegionID;
@@ -3074,7 +3085,7 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGridService.OnExpectUser += HandleNewUserConnection;
m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing;
m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent;
- m_sceneGridService.OnRegionUp += OtherRegionUp;
+ //m_eventManager.OnRegionUp += OtherRegionUp;
//m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup;
//m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
@@ -3102,7 +3113,7 @@ namespace OpenSim.Region.Framework.Scenes
//m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup;
//m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
- m_sceneGridService.OnRegionUp -= OtherRegionUp;
+ //m_eventManager.OnRegionUp -= OtherRegionUp;
m_sceneGridService.OnExpectUser -= HandleNewUserConnection;
m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing;
m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent;
@@ -3111,7 +3122,11 @@ namespace OpenSim.Region.Framework.Scenes
if (m_interregionCommsIn != null)
m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
+ // this does nothing; should be removed
m_sceneGridService.Close();
+
+ if (!GridService.DeregisterRegion(m_regInfo.RegionID))
+ m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", m_regInfo.RegionName);
}
///
@@ -3556,30 +3571,6 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours);
}
- ///
- /// Requests information about this region from gridcomms
- ///
- ///
- ///
- public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
- {
- return m_sceneGridService.RequestNeighbouringRegionInfo(regionHandle);
- }
-
- ///
- /// Requests textures for map from minimum region to maximum region in world cordinates
- ///
- ///
- ///
- ///
- ///
- ///
- 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);
- }
-
///
/// Tries to teleport agent to other region.
///
@@ -3591,7 +3582,7 @@ namespace OpenSim.Region.Framework.Scenes
public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position,
Vector3 lookat, uint teleportFlags)
{
- RegionInfo regionInfo = m_sceneGridService.RequestClosestRegion(regionName);
+ GridRegion regionInfo = GridService.GetRegionByName(UUID.Zero, regionName);
if (regionInfo == null)
{
// can't find the region: Tell viewer and abort
@@ -3680,7 +3671,7 @@ namespace OpenSim.Region.Framework.Scenes
///
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)
{
@@ -3864,10 +3855,6 @@ namespace OpenSim.Region.Framework.Scenes
return LandChannel.GetLandObject((int)x, (int)y).landData;
}
- public RegionInfo RequestClosestRegion(string name)
- {
- return m_sceneGridService.RequestClosestRegion(name);
- }
#endregion
@@ -4178,14 +4165,18 @@ namespace OpenSim.Region.Framework.Scenes
public void RegionHandleRequest(IClientAPI client, UUID regionID)
{
- RegionInfo info;
+ ulong handle = 0;
if (regionID == RegionInfo.RegionID)
- info = RegionInfo;
+ handle = RegionInfo.RegionHandle;
else
- info = CommsManager.GridService.RequestNeighbourInfo(regionID);
+ {
+ GridRegion r = GridService.GetRegionByUUID(UUID.Zero, regionID);
+ if (r != null)
+ handle = r.RegionHandle;
+ }
- if (info != null)
- client.SendRegionHandle(regionID, info.RegionHandle);
+ if (handle != 0)
+ client.SendRegionHandle(regionID, handle);
}
public void TerrainUnAcked(IClientAPI client, int patchX, int patchY)
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 2a822371b3..2af98cc8e6 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -36,6 +36,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes
{
@@ -227,7 +228,7 @@ namespace OpenSim.Region.Framework.Scenes
return false;
}
- public abstract bool OtherRegionUp(RegionInfo thisRegion);
+ public abstract void OtherRegionUp(GridRegion otherRegion);
public virtual string GetSimulatorVersion()
{
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 5f2333e66c..4a2db5eda0 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -41,6 +41,7 @@ using OpenSim.Framework.Capabilities;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Services.Interfaces;
using OSD = OpenMetaverse.StructuredData.OSD;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes
{
@@ -58,6 +59,7 @@ namespace OpenSim.Region.Framework.Scenes
protected CommunicationsManager m_commsProvider;
protected IInterregionCommsOut m_interregionCommsOut;
protected RegionInfo m_regionInfo;
+ protected Scene m_scene;
protected RegionCommsListener regionCommsHost;
@@ -91,10 +93,10 @@ namespace OpenSim.Region.Framework.Scenes
///
public event PrimCrossing OnPrimCrossingIntoRegion;
- ///
- /// A New Region is up and available
- ///
- public event RegionUp OnRegionUp;
+ /////
+ ///// A New Region is up and available
+ /////
+ //public event RegionUp OnRegionUp;
///
/// 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 CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
- private RegionUp handlerRegionUp = null; // OnRegionUp;
+ //private RegionUp handlerRegionUp = null; // OnRegionUp;
private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate;
//private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar;
private LogOffUser handlerLogOffUser = null;
@@ -131,6 +133,13 @@ namespace OpenSim.Region.Framework.Scenes
m_agentsInTransit = new List();
}
+ public void SetScene(Scene s)
+ {
+ m_scene = s;
+ m_regionInfo = s.RegionInfo;
+ m_interregionCommsOut = m_scene.RequestModuleInterface();
+ }
+
///
/// Register a region with the grid
///
@@ -138,40 +147,30 @@ namespace OpenSim.Region.Framework.Scenes
/// Thrown if region registration fails.
public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos)
{
- m_interregionCommsOut = comms_out;
+ //m_interregionCommsOut = comms_out;
- m_regionInfo = regionInfos;
- m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName;
- regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo);
+ //m_regionInfo = regionInfos;
+ //m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName;
+ //regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo);
- if (regionCommsHost != null)
- {
- //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString());
+ //if (regionCommsHost != null)
+ //{
+ // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString());
- regionCommsHost.debugRegionName = regionInfos.RegionName;
- regionCommsHost.OnExpectPrim += IncomingPrimCrossing;
- regionCommsHost.OnExpectUser += NewUserConnection;
- regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
- regionCommsHost.OnCloseAgentConnection += CloseConnection;
- regionCommsHost.OnRegionUp += newRegionUp;
- regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
- regionCommsHost.OnLogOffUser += GridLogOffUser;
- regionCommsHost.OnGetLandData += FetchLandData;
- }
- else
- {
- //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null");
- }
- }
-
- ///
- /// Returns a region with the name closest to string provided
- ///
- /// Partial Region Name for matching
- /// Region Information for the region
- public RegionInfo RequestClosestRegion(string name)
- {
- return m_commsProvider.GridService.RequestClosestRegion(name);
+ // regionCommsHost.debugRegionName = regionInfos.RegionName;
+ // regionCommsHost.OnExpectPrim += IncomingPrimCrossing;
+ // regionCommsHost.OnExpectUser += NewUserConnection;
+ // regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
+ // regionCommsHost.OnCloseAgentConnection += CloseConnection;
+ // regionCommsHost.OnRegionUp += newRegionUp;
+ // regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
+ // regionCommsHost.OnLogOffUser += GridLogOffUser;
+ // regionCommsHost.OnGetLandData += FetchLandData;
+ //}
+ //else
+ //{
+ // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null");
+ //}
}
///
@@ -180,30 +179,31 @@ namespace OpenSim.Region.Framework.Scenes
///
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;
+
+ //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
- {
- 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);
- }
+ // 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;
- }
+ // regionCommsHost = null;
+ //}
}
#region CommsManager Event handlers
@@ -238,22 +238,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- ///
- /// A New Region is now available. Inform the scene that there is a new region available.
- ///
- /// Information about the new region that is available
- /// True if the event was handled
- 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;
- }
-
///
/// Inform the scene that we've got an update about a child agent that we have
///
@@ -337,7 +321,7 @@ namespace OpenSim.Region.Framework.Scenes
#region Inform Client of Neighbours
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)
{
@@ -355,7 +339,7 @@ namespace OpenSim.Region.Framework.Scenes
///
///
///
- private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg,
+ private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, GridRegion reg,
IPEndPoint endPoint, bool newAgent)
{
// Let's wait just a little to give time to originating regions to catch up with closing child agents
@@ -373,8 +357,7 @@ namespace OpenSim.Region.Framework.Scenes
string reason = String.Empty;
- //bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a);
-
+
bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason);
if (regionAccepted && newAgent)
@@ -407,17 +390,7 @@ namespace OpenSim.Region.Framework.Scenes
}
- public void RequestNeighbors(RegionInfo region)
- {
- // List 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 RequestNeighbors(Scene pScene, uint pRegionLocX, uint pRegionLocY)
+ public List RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
{
Border[] northBorders = pScene.NorthBorders.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.
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
{
Vector2 extent = Vector2.Zero;
- for (int i=0;i extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
}
- for (int i=0;i extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
}
- List neighbourList = new List();
-
// Loss of fraction on purpose
extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
- int startX = (int) pRegionLocX - 1;
- int startY = (int) pRegionLocY - 1;
+ int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize;
+ int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize;
- int endX = (int) pRegionLocX + (int)extent.X;
- int endY = (int) pRegionLocY + (int)extent.Y;
+ int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize;
+ int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize;
- for (int i=startX;i neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
+ neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
- ulong regionHandle = Util.UIntsToLong((uint)(i * Constants.RegionSize),
- (uint)(j * Constants.RegionSize));
- RegionInfo neighborreg = m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
- if (neighborreg != null)
- {
- neighbourList.Add(neighborreg);
- }
- }
- }
- return neighbourList;
+ return neighbours;
//SimpleRegionInfo regionData = m_commsProvider.GridService.RequestNeighbourInfo()
//return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY);
}
@@ -482,29 +439,28 @@ namespace OpenSim.Region.Framework.Scenes
///
public void EnableNeighbourChildAgents(ScenePresence avatar, List lstneighbours)
{
- List neighbours = new List();
+ //List neighbours = new List();
+ List neighbours = new List();
- //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
- for (int i = 0; i < lstneighbours.Count; i++)
- {
- // We don't want to keep sending to regions that consistently fail on comms.
- if (!(lstneighbours[i].commFailTF))
- {
- neighbours.Add(new SimpleRegionInfo(lstneighbours[i]));
- }
- }
+ ////m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
+ //for (int i = 0; i < lstneighbours.Count; i++)
+ //{
+ // // We don't want to keep sending to regions that consistently fail on comms.
+ // if (!(lstneighbours[i].commFailTF))
+ // {
+ // 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
// So we're temporarily going back to the old method of grabbing it from the Grid Server Every time :/
if (m_regionInfo != null)
{
- neighbours =
- RequestNeighbors(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
+ neighbours = RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
}
else
{
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
/// and the regions where there are already child agents. We only send notification to the former.
@@ -547,8 +503,9 @@ namespace OpenSim.Region.Framework.Scenes
/// Create the necessary child agents
List cagents = new List();
- foreach (SimpleRegionInfo neighbour in neighbours)
- {
+ //foreach (SimpleRegionInfo neighbour in neighbours)
+ foreach (GridRegion neighbour in neighbours)
+ {
if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
{
@@ -588,7 +545,7 @@ namespace OpenSim.Region.Framework.Scenes
bool newAgent = false;
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
if (newRegions.Contains(neighbour.RegionHandle))
@@ -641,7 +598,7 @@ namespace OpenSim.Region.Framework.Scenes
/// This informs a single neighboring region about agent "avatar".
/// Calls an asynchronous method to do so.. so it doesn't lag the sim.
///
- public void InformNeighborChildAgent(ScenePresence avatar, SimpleRegionInfo region)
+ public void InformNeighborChildAgent(ScenePresence avatar, GridRegion region)
{
AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
agent.BaseFolder = UUID.Zero;
@@ -672,61 +629,63 @@ namespace OpenSim.Region.Framework.Scenes
///
private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle)
{
- m_log.Info("[INTERGRID]: Starting to inform neighbors that I'm here");
- //RegionUpData regiondata = new RegionUpData(region.RegionLocX, region.RegionLocY, region.ExternalHostName, region.InternalEndPoint.Port);
+ uint x = 0, y = 0;
+ Utils.LongToUInts(regionhandle, out x, out y);
- //bool regionAccepted =
- // m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region), regionhandle);
-
- //bool regionAccepted = m_interregionCommsOut.SendHelloNeighbour(regionhandle, region);
- bool regionAccepted = false;
+ GridRegion neighbour = null;
if (neighbourService != null)
- regionAccepted = neighbourService.HelloNeighbour(regionhandle, region);
+ neighbour = neighbourService.HelloNeighbour(regionhandle, region);
else
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");
- handlerRegionUp = OnRegionUp;
-
- // yes, we're notifying ourselves.
- if (handlerRegionUp != null)
- handlerRegionUp(region);
+ m_log.DebugFormat("[INTERGRID]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize);
+ m_scene.EventManager.TriggerOnRegionUp(neighbour);
}
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);
}
}
- ///
- /// 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.
- ///
+
public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region)
{
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
-
- List neighbours = new List();
- // This stays uncached because we don't already know about our neighbors at this point.
- neighbours = m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
- if (neighbours != null)
- {
- for (int i = 0; i < neighbours.Count; i++)
- {
- InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
+ for (int x = (int)region.RegionLocX - 1; x <= region.RegionLocX + 1; x++)
+ for (int y = (int)region.RegionLocY - 1; y <= region.RegionLocY + 1; y++)
+ if (!((x == region.RegionLocX) && (y == region.RegionLocY))) // skip this region
+ {
+ ulong handle = Utils.UIntsToLong((uint)x * Constants.RegionSize, (uint)y * Constants.RegionSize);
+ InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
- d.BeginInvoke(neighbourService, region, neighbours[i].RegionHandle,
- InformNeighborsThatRegionisUpCompleted,
- d);
- }
- }
+ d.BeginInvoke(neighbourService, region, handle,
+ InformNeighborsThatRegionisUpCompleted,
+ d);
+ }
+
+ //List neighbours = new List();
+ //// 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));
}
+
public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle);
///
@@ -822,41 +781,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- ///
- /// Helper function to request neighbors from grid-comms
- ///
- ///
- ///
- 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);
- }
-
- ///
- /// Helper function to request neighbors from grid-comms
- ///
- ///
- ///
- 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);
- }
-
- ///
- /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
- ///
- ///
- ///
- ///
- ///
- public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
- {
- List mapBlocks;
- mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4);
- remoteClient.SendMapBlock(mapBlocks, 0);
- }
///
/// Try to teleport an agent to a new region.
@@ -921,7 +845,10 @@ namespace OpenSim.Region.Framework.Scenes
}
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)
{
m_log.DebugFormat(
@@ -1228,10 +1155,10 @@ namespace OpenSim.Region.Framework.Scenes
return false;
}
- private List NeighbourHandles(List neighbours)
+ private List NeighbourHandles(List neighbours)
{
List handles = new List();
- foreach (SimpleRegionInfo reg in neighbours)
+ foreach (GridRegion reg in neighbours)
{
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);
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())
{
pos = pos + (agent.Velocity);
@@ -1609,11 +1539,6 @@ namespace OpenSim.Region.Framework.Scenes
}
- public Dictionary GetGridSettings()
- {
- return m_commsProvider.GridService.GetGridSettings();
- }
-
public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
{
m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat);
@@ -1650,19 +1575,14 @@ namespace OpenSim.Region.Framework.Scenes
return m_commsProvider.GetUserFriendList(friendlistowner);
}
- public List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
- {
- return m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
- }
-
public List GenerateAgentPickerRequestResponse(UUID queryID, string query)
{
return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
}
- public List RequestNamedRegions(string name, int maxNumber)
+ public List 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 handles)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 6772f75d60..286b7ca32d 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -36,6 +36,7 @@ using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes.Types;
using OpenSim.Region.Physics.Manager;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes
{
@@ -2934,8 +2935,9 @@ namespace OpenSim.Region.Framework.Scenes
else if (dir > 3 && dir < 7) // Heading Sout
neighboury--;
- ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
- SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle);
+ int x = (int)(neighbourx * Constants.RegionSize);
+ int y = (int)(neighboury * Constants.RegionSize);
+ GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y);
if (neighbourRegion == null)
{
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
index f6737a5628..5c9e66f883 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
@@ -29,6 +29,7 @@ using System;
using NUnit.Framework;
using OpenMetaverse;
using OpenSim.Framework;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes.Tests
{
@@ -65,7 +66,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
throw new NotImplementedException();
}
- public override bool OtherRegionUp(RegionInfo thisRegion)
+ public override void OtherRegionUp(GridRegion otherRegion)
{
throw new NotImplementedException();
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 4c52b114ea..1ebe24e2e1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -50,6 +50,9 @@ using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
+using OpenSim.Services.Interfaces;
+
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using AssetLandmark = OpenSim.Framework.AssetLandmark;
@@ -5226,12 +5229,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
- List neighbors = World.CommsManager.GridService.RequestNeighbours(World.RegionInfo.RegionLocX, World.RegionInfo.RegionLocY);
+ List neighbors = World.GridService.GetNeighbours(World.RegionInfo.ScopeID, World.RegionInfo.RegionID);
uint neighborX = World.RegionInfo.RegionLocX + (uint)dir.x;
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)
return 0;
@@ -8181,7 +8184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
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)
{
@@ -8208,7 +8211,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ConditionalScriptSleep(1000);
return UUID.Zero.ToString();
}
- int access = info.RegionSettings.Maturity;
+ int access = info.Maturity;
if (access == 0)
reply = "PG";
else if (access == 1)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index ccdd4c50a9..0b95abc599 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -48,6 +48,8 @@ using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
+using OpenSim.Services.Interfaces;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using System.Text.RegularExpressions;
using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
@@ -599,17 +601,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (regionName.Contains(".") && regionName.Contains(":"))
{
// Try to link the region
- RegionInfo regInfo = HGHyperlink.TryLinkRegion(World,
- presence.ControllingClient,
- regionName);
- // Get the region name
- if (regInfo != null)
+ IHyperlinkService hyperService = World.RequestModuleInterface();
+ if (hyperService != null)
{
- regionName = regInfo.RegionName;
- }
- else
- {
- // Might need to ping the client here in case of failure??
+ GridRegion regInfo = hyperService.TryLinkRegion(presence.ControllingClient,
+ regionName);
+ // Get the region name
+ if (regInfo != null)
+ {
+ regionName = regInfo.RegionName;
+ }
+ else
+ {
+ // Might need to ping the client here in case of failure??
+ }
}
}
presence.ControllingClient.SendTeleportLocationStart();
diff --git a/OpenSim/Server/Base/ProtocolVersions.cs b/OpenSim/Server/Base/ProtocolVersions.cs
new file mode 100644
index 0000000000..6df27b7a4a
--- /dev/null
+++ b/OpenSim/Server/Base/ProtocolVersions.cs
@@ -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
+ {
+ ///
+ /// 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.
+ ///
+ ///
+
+ // 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;
+ }
+}
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
index b9a4867a9b..e22328dc66 100644
--- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
@@ -118,6 +118,24 @@ namespace OpenSim.Server.Handlers.Grid
else
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 rinfoData = new Dictionary();
foreach (KeyValuePair kvp in request)
rinfoData[kvp.Key] = kvp.Value;
diff --git a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
index ad634853dc..c47f652294 100644
--- a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
+++ b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
@@ -36,7 +36,9 @@ using OpenSim.Server.Base;
using OpenSim.Services.Interfaces;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Server.Handlers.Base;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
+using OpenMetaverse;
using log4net;
using Nwc.XmlRpc;
@@ -48,12 +50,26 @@ namespace OpenSim.Server.Handlers.Grid
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
- private List m_RegionsOnSim = new List();
+ private List m_RegionsOnSim = new List();
+ private IHyperlinkService m_HyperlinkService;
- public HypergridServiceInConnector(IConfigSource config, IHttpServer server) :
+ public HypergridServiceInConnector(IConfigSource config, IHttpServer server, IHyperlinkService hyperService) :
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);
}
///
@@ -70,8 +86,8 @@ namespace OpenSim.Server.Handlers.Grid
m_log.DebugFormat("[HGrid]: Hyperlink request");
- SimpleRegionInfo regInfo = null;
- foreach (SimpleRegionInfo r in m_RegionsOnSim)
+ GridRegion regInfo = null;
+ foreach (GridRegion r in m_RegionsOnSim)
{
if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower()))
{
@@ -85,9 +101,9 @@ namespace OpenSim.Server.Handlers.Grid
Hashtable hash = new Hashtable();
hash["uuid"] = regInfo.RegionID.ToString();
+ m_log.Debug(">> Here " + regInfo.RegionID);
hash["handle"] = regInfo.RegionHandle.ToString();
- //m_log.Debug(">> Here " + regInfo.RegionHandle);
- //hash["region_image"] = regInfo.RegionSettings.TerrainImageID.ToString();
+ hash["region_image"] = regInfo.TerrainImage.ToString();
hash["region_name"] = regInfo.RegionName;
hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
//m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port);
@@ -98,15 +114,95 @@ namespace OpenSim.Server.Handlers.Grid
return response;
}
- public void AddRegion(SimpleRegionInfo rinfo)
+ ///
+ /// 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.
+ ///
+ ///
+ ///
+ 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;
+ }
+
+ // Finally, everything looks ok
+ //m_log.Debug("XXX---- EVERYTHING OK ---XXX");
+
+ if (!comingHome)
+ {
+ // We don't do this if the user is coming to the home grid
+ 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;
}
- public void RemoveRegion(SimpleRegionInfo rinfo)
- {
- if (m_RegionsOnSim.Contains(rinfo))
- m_RegionsOnSim.Remove(rinfo);
- }
}
}
diff --git a/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs b/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs
index c0933a8607..d6ef22e71b 100644
--- a/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs
+++ b/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs
@@ -36,6 +36,7 @@ using OpenSim.Server.Handlers.Base;
using OpenSim.Services.Interfaces;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
@@ -148,11 +149,14 @@ namespace OpenSim.Server.Handlers.Neighbour
}
// Finally!
- bool success = m_NeighbourService.HelloNeighbour(regionhandle, aRegion);
-
+ GridRegion thisRegion = m_NeighbourService.HelloNeighbour(regionhandle, aRegion);
+
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;
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
index 748892a03f..ba46b0d71f 100644
--- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
@@ -94,7 +94,8 @@ namespace OpenSim.Services.Connectors
sendData[kvp.Key] = (string)kvp.Value;
sendData["SCOPEID"] = scopeID.ToString();
-
+ sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
+ sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
sendData["METHOD"] = "register";
string reqString = ServerUtils.BuildQueryString(sendData);
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
index b5e87439bf..dd19b01b81 100644
--- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
@@ -66,7 +66,7 @@ namespace OpenSim.Services.Connectors.Grid
IList paramList = new ArrayList();
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 + "/";
m_log.Debug("[HGrid]: Linking to " + uri);
XmlRpcResponse response = request.Send(uri, 10000);
@@ -82,6 +82,7 @@ namespace OpenSim.Services.Connectors.Grid
try
{
UUID.TryParse((string)hash["uuid"], out uuid);
+ m_log.Debug(">> HERE, uuid: " + uuid);
info.RegionID = uuid;
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;
+ }
+ }
+
}
}
diff --git a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs
index 0243f1fd8a..06bc11cebe 100644
--- a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs
@@ -38,6 +38,7 @@ using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using OpenMetaverse;
using Nwc.XmlRpc;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Services.Connectors
{
@@ -47,20 +48,20 @@ namespace OpenSim.Services.Connectors
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
- protected IGridServices m_MapService = null;
+ protected IGridService m_GridService = null;
public LandServicesConnector()
{
}
- public LandServicesConnector(IGridServices gridServices)
+ public LandServicesConnector(IGridService 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)
@@ -76,7 +77,9 @@ namespace OpenSim.Services.Connectors
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
{
XmlRpcRequest request = new XmlRpcRequest("land_data", paramList);
diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs
index 7fff5377bb..145f212590 100644
--- a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs
@@ -41,6 +41,8 @@ using OpenSim.Services.Interfaces;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
+
namespace OpenSim.Services.Connectors
{
public class NeighbourServicesConnector : INeighbourService
@@ -49,37 +51,39 @@ namespace OpenSim.Services.Connectors
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
- protected IGridServices m_MapService = null;
+ protected IGridService m_GridService = null;
public NeighbourServicesConnector()
{
}
- public NeighbourServicesConnector(IGridServices gridServices)
+ public NeighbourServicesConnector(IGridService 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) &&
// Don't remote-call this instance; that's a startup hickup
!((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.HttpPort)))
{
- return DoHelloNeighbourCall(regInfo, thisRegion);
+ DoHelloNeighbourCall(regInfo, thisRegion);
}
//else
// 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 + "/";
//m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri);
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index ce432ab8cd..46a7f09b1a 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -122,9 +122,6 @@ namespace OpenSim.Services.Interfaces
}
protected string m_regionName = String.Empty;
- protected bool Allow_Alternate_Ports;
- public bool m_allow_alternate_ports;
-
protected string m_externalHostName;
protected IPEndPoint m_internalEndPoint;
@@ -146,6 +143,11 @@ namespace OpenSim.Services.Interfaces
public UUID RegionID = UUID.Zero;
public UUID ScopeID = UUID.Zero;
+ public UUID TerrainImage = UUID.Zero;
+ public byte Access;
+ public int Maturity;
+ public string RegionSecret;
+
public GridRegion()
{
}
@@ -183,11 +185,29 @@ namespace OpenSim.Services.Interfaces
m_internalEndPoint = ConvertFrom.InternalEndPoint;
m_externalHostName = ConvertFrom.ExternalHostName;
m_httpPort = ConvertFrom.HttpPort;
- m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
- RegionID = UUID.Zero;
+ RegionID = ConvertFrom.RegionID;
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;
+ }
///
/// 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["serverURI"] = ServerURI;
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;
}
@@ -312,6 +335,16 @@ namespace OpenSim.Services.Interfaces
if (kvp.ContainsKey("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"];
+
}
}
diff --git a/OpenSim/Framework/Communications/IHyperlink.cs b/OpenSim/Services/Interfaces/IHyperlink.cs
similarity index 75%
rename from OpenSim/Framework/Communications/IHyperlink.cs
rename to OpenSim/Services/Interfaces/IHyperlink.cs
index 505738676e..ed3ff237de 100644
--- a/OpenSim/Framework/Communications/IHyperlink.cs
+++ b/OpenSim/Services/Interfaces/IHyperlink.cs
@@ -25,14 +25,25 @@
* 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);
- RegionInfo GetHyperlinkRegion(ulong handle);
+ GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor);
+ GridRegion GetHyperlinkRegion(ulong handle);
ulong FindRegionHandle(ulong handle);
- bool SendUserInformation(RegionInfo region, AgentCircuitData aCircuit);
+
+ bool SendUserInformation(GridRegion region, 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);
}
}
diff --git a/OpenSim/Services/Interfaces/INeighbourService.cs b/OpenSim/Services/Interfaces/INeighbourService.cs
index 39444869bf..960e13d036 100644
--- a/OpenSim/Services/Interfaces/INeighbourService.cs
+++ b/OpenSim/Services/Interfaces/INeighbourService.cs
@@ -28,11 +28,12 @@
using System;
using OpenSim.Framework;
using OpenMetaverse;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Services.Interfaces
{
public interface INeighbourService
{
- bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion);
+ GridRegion HelloNeighbour(ulong regionHandle, RegionInfo otherRegion);
}
}
diff --git a/OpenSim/Tests/Clients/Grid/GridClient.cs b/OpenSim/Tests/Clients/Grid/GridClient.cs
index 941406e693..ccda661f7a 100644
--- a/OpenSim/Tests/Clients/Grid/GridClient.cs
+++ b/OpenSim/Tests/Clients/Grid/GridClient.cs
@@ -28,7 +28,7 @@ namespace OpenSim.Tests.Clients.GridClient
new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
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);
GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000);
diff --git a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs
index 4313c968b1..de73663460 100644
--- a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs
+++ b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs
@@ -65,8 +65,6 @@ namespace OpenSim.Tests.Common.Mock
m_userService = lus;
m_userAdminService = lus;
- LocalBackEndServices gs = new LocalBackEndServices();
- m_gridService = gs;
}
}
}
diff --git a/bin/OpenSim.GridServer.ini.example b/bin/OpenSim.GridServer.ini.example
index 695bf9e758..8bd126fdc6 100644
--- a/bin/OpenSim.GridServer.ini.example
+++ b/bin/OpenSim.GridServer.ini.example
@@ -13,7 +13,7 @@
; * server instance
; *
[Network]
- port = 8002
+ port = 8001
; * The following are for the remote console
; * They have no effect for the local or basic console types
diff --git a/bin/OpenSim.Server.ini.example b/bin/OpenSim.Server.ini.example
index 5696f079e8..635ba1ebec 100644
--- a/bin/OpenSim.Server.ini.example
+++ b/bin/OpenSim.Server.ini.example
@@ -9,7 +9,7 @@
; * enable the experimental authentication service
; *
[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
; * server instance
@@ -70,3 +70,12 @@ StorageProvider = "OpenSim.Data.MySQL.dll"
ConnectionString = "Data Source=localhost;Database=grid;User ID=grid;Password=grid;"
; 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"
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index 7a65efea2d..8055ba4b94 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -326,7 +326,7 @@
; The MessagingServer is a companion of the UserServer. It uses
; 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"
; Defaults to the user server url if not set
diff --git a/bin/config-include/Grid.ini b/bin/config-include/Grid.ini
index 10f7dbdb28..261c1b8d48 100644
--- a/bin/config-include/Grid.ini
+++ b/bin/config-include/Grid.ini
@@ -12,5 +12,12 @@
InventoryServices = "RemoteInventoryServicesConnector"
AuthorizationServices = "RemoteAuthorizationServicesConnector"
NeighbourServices = "RemoteNeighbourServicesConnector"
+ GridServices = "RemoteGridServicesConnector"
NeighbourServiceInConnector = 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"
+
\ No newline at end of file
diff --git a/bin/config-include/GridCommon.ini.example b/bin/config-include/GridCommon.ini.example
index 3a8ec3523e..e9d3728677 100644
--- a/bin/config-include/GridCommon.ini.example
+++ b/bin/config-include/GridCommon.ini.example
@@ -15,6 +15,11 @@
;
InventoryServerURI = "http://myinventoryserver.com:8004"
+[GridService]
+ ;
+ ; change this to your grid-wide inventory server
+ ;
+ GridServerURI = "http://mygridserver.com:8001"
[Modules]
;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists.
diff --git a/bin/config-include/GridHypergrid.ini b/bin/config-include/GridHypergrid.ini
index 8b65ab80cc..1bfcf89ef2 100644
--- a/bin/config-include/GridHypergrid.ini
+++ b/bin/config-include/GridHypergrid.ini
@@ -11,9 +11,10 @@
AssetServices = "HGAssetBroker"
InventoryServices = "HGInventoryBroker"
NeighbourServices = "RemoteNeighbourServicesConnector"
+ GridServices = "HGGridServicesConnector"
NeighbourServiceInConnector = true
LandServiceInConnector = true
-
+ HypergridServiceInConnector = true
[AssetService]
LocalGridAssetService = "OpenSim.Services.Connectors.dll:AssetServicesConnector"
@@ -22,3 +23,11 @@
[InventoryService]
LocalGridInventoryService = "OpenSim.Region.CoreModules.dll:RemoteInventoryServicesConnector"
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"
diff --git a/bin/config-include/Standalone.ini b/bin/config-include/Standalone.ini
index 5a5cbffde7..a6c089c353 100644
--- a/bin/config-include/Standalone.ini
+++ b/bin/config-include/Standalone.ini
@@ -25,5 +25,4 @@
[GridService]
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
- StorageProvider = "OpenSim.Data.Null.dll:NullRegionData"
-
\ No newline at end of file
+ Realm = "regions"
diff --git a/bin/config-include/StandaloneCommon.ini.example b/bin/config-include/StandaloneCommon.ini.example
index bac7983960..b0e2de35d1 100644
--- a/bin/config-include/StandaloneCommon.ini.example
+++ b/bin/config-include/StandaloneCommon.ini.example
@@ -32,3 +32,10 @@
[FreeswitchService]
;; Configuration for the freeswitch service goes here
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=***;"
diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini
index b14517df9f..75cdad943f 100644
--- a/bin/config-include/StandaloneHypergrid.ini
+++ b/bin/config-include/StandaloneHypergrid.ini
@@ -10,13 +10,15 @@
[Modules]
AssetServices = "HGAssetBroker"
InventoryServices = "HGInventoryBroker"
- NeighbourServices = "LocalNeighbourServicesConnector"
+ NeighbourServices = "RemoteNeighbourServicesConnector"
AuthorizationServices = "LocalAuthorizationServicesConnector"
GridServices = "HGGridServicesConnector"
InventoryServiceInConnector = true
AssetServiceInConnector = true
HGAuthServiceInConnector = true
HypergridServiceInConnector = true
+ NeighbourServiceInConnector = true
+
[AssetService]
; For the AssetServiceInConnector
@@ -42,6 +44,8 @@
LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:HGAuthenticationService"
[GridService]
- LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
+ ; for the HGGridServicesConnector to instantiate
GridServiceConnectorModule = "OpenSim.Region.CoreModules.dll:LocalGridServicesConnector"
- StorageProvider = "OpenSim.Data.Null.dll:NullRegionData"
\ No newline at end of file
+ ; LocalGridServicesConnector needs this
+ LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
+ Realm = "regions"
diff --git a/prebuild.xml b/prebuild.xml
index 6ac7b68f9f..76da2e169c 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -980,6 +980,8 @@
+
+
@@ -988,6 +990,7 @@
+
@@ -3655,6 +3658,7 @@
+
@@ -3708,6 +3712,7 @@
+