Merge branch 'master' into vehicles

0.6.8-post-fixes
Melanie 2009-10-01 14:08:15 +01:00
commit 41ff39414b
307 changed files with 3296 additions and 5638 deletions

View File

@ -53,6 +53,11 @@
</exec>
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.servers.tests)==0}" />
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.framework.serialization.tests">
<arg value="./bin/OpenSim.Framework.Serialization.Tests.dll" />
</exec>
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.serialization.tests)==0}" />
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.region.clientstack.lindenudp.tests">
<arg value="./bin/OpenSim.Region.ClientStack.LindenUDP.Tests.dll" />
</exec>
@ -223,6 +228,11 @@
<arg value="-xml=test-results/OpenSim.Framework.Communications.Tests.dll-Results.xml" />
</exec>
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.framework.serialization.tests">
<arg value="./bin/OpenSim.Framework.Serialization.Tests.dll" />
<arg value="-xml=test-results/OpenSim.Framework.Serialization.Tests.dll-Results.xml" />
</exec>
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.framework.servers.tests">
<arg value="./bin/OpenSim.Framework.Servers.Tests.dll" />
<arg value="-xml=test-results/OpenSim.Framework.Servers.Tests.dll-Results.xml" />

View File

@ -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)

View File

@ -69,7 +69,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
private string m_name = "RemoteAdminPlugin";
private string m_version = "0.0";
//AnakinLohner 0.6.5-post-fixes
//guard for XmlRpc-related methods
private void FailIfRemoteAdminDisabled(string requestName)
{
@ -469,7 +468,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
m_log.Info("[RADMIN]: CreateRegion: new request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("CreateRegion");
XmlRpcResponse response = new XmlRpcResponse();
@ -477,7 +475,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
lock (rslock)
{
int m_regionLimit = m_config.GetInt("region_limit", 0);
bool m_enableVoiceForNewRegions = m_config.GetBoolean("create_region_enable_voice", false);
bool m_publicAccess = m_config.GetBoolean("create_region_public", true);
@ -561,7 +558,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
region.ExternalHostName = (string) requestData["external_address"];
string masterFirst = (string) requestData["region_master_first"];
@ -989,7 +985,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
m_log.Info("[RADMIN]: CreateUser: new request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("CreateUser");
XmlRpcResponse response = new XmlRpcResponse();
@ -1101,7 +1096,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
m_log.Info("[RADMIN]: UserExists: new request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("UserExists");
XmlRpcResponse response = new XmlRpcResponse();
@ -1134,7 +1128,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
responseData["lastlogin"] = userInfo.UserProfile.LastLogin;
}
response.Value = responseData;
}
catch (Exception e)
@ -1308,7 +1301,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
m_log.Info("[RADMIN]: UpdateUserAccount: request complete");
return response;
}
/// <summary>
@ -1321,7 +1313,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
private void updateUserAppearance(Hashtable responseData, Hashtable requestData, UUID userid)
{
m_log.DebugFormat("[RADMIN] updateUserAppearance");
string dmale = m_config.GetString("default_male", "Default Male");
@ -1402,7 +1393,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
private void establishAppearance(UUID dest, UUID srca)
{
m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", dest, srca);
AvatarAppearance ava = m_app.CommunicationsManager.AvatarService.GetUserAppearance(srca);
@ -1423,7 +1413,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
try
{
Dictionary<UUID,UUID> imap = new Dictionary<UUID,UUID>();
iserv.GetUserInventory(dest, dic.callback);
@ -1434,7 +1423,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (sic.OK && dic.OK)
{
InventoryFolderImpl efolder;
InventoryFolderImpl srcf = sic.root.FindFolderForType(5);
InventoryFolderImpl dstf = dic.root.FindFolderForType(5);
@ -1494,7 +1482,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
ava.SetWearable(i, dw);
}
}
}
else
{
@ -1502,7 +1489,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
m_app.CommunicationsManager.AvatarService.UpdateUserAppearance(dest, ava);
}
catch (Exception e)
{
@ -1512,7 +1498,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
return;
}
///<summary>
@ -1527,7 +1512,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
private bool createDefaultAvatars()
{
// Only load once
if (daload)
@ -1543,10 +1527,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
try
{
string dafn = null;
//AnakinLohner 0.6.5-post-fixes
//m_config may be null if RemoteAdmin configuration secition is missing or disabled in OpenSim.ini
if (m_config != null)
{
@ -1555,7 +1537,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (File.Exists(dafn))
{
XmlDocument doc = new XmlDocument();
string name = "*unknown*";
string email = "anon@anon";
@ -1670,7 +1651,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (uic.OK)
try
{
m_log.DebugFormat("[RADMIN] {0} folders, {1} items in inventory",
uic.folders.Count, uic.items.Count);
@ -1699,7 +1679,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
foreach (XmlElement outfit in outfits)
{
m_log.DebugFormat("[RADMIN] Loading outfit {0} for {1}",
GetStringAttribute(outfit,"name","?"), GetStringAttribute(avatar,"name","?"));
@ -1820,7 +1799,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
return true;
}
/// <summary>
@ -1859,7 +1837,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
m_log.Info("[RADMIN]: Received Load OAR Administrator Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Load OAR");
XmlRpcResponse response = new XmlRpcResponse();
@ -1962,7 +1939,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
m_log.Info("[RADMIN]: Received Save OAR Administrator Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Save OAR");
XmlRpcResponse response = new XmlRpcResponse();
@ -2003,7 +1979,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
IRegionArchiverModule archiver = scene.RequestModuleInterface<IRegionArchiverModule>();
if (archiver != null)
{
scene.EventManager.OnOarFileSaved += RemoteAdminOarSaveCompleted;
@ -2014,11 +1989,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController
else
throw new Exception("Archiver module not present for scene");
responseData["saved"] = true;
response.Value = responseData;
}
catch (Exception e)
{
@ -2045,7 +2018,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
m_log.Info("[RADMIN]: Received Load XML Administrator Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Load XML");
XmlRpcResponse response = new XmlRpcResponse();
@ -2129,12 +2101,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
}
public XmlRpcResponse XmlRpcSaveXMLMethod(XmlRpcRequest request, IPEndPoint remoteClient)
{
m_log.Info("[RADMIN]: Received Save XML Administrator Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Save XML");
XmlRpcResponse response = new XmlRpcResponse();
@ -2220,7 +2190,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
m_log.Info("[RADMIN]: Received Query XML Administrator Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Query XML");
XmlRpcResponse response = new XmlRpcResponse();
@ -2255,9 +2224,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
else throw new Exception("neither region_name nor region_uuid given");
Scene s = m_app.SceneManager.CurrentScene;
int health = s.GetHealth();
responseData["health"] = health;
response.Value = responseData;
@ -2280,7 +2247,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
m_log.Info("[RADMIN]: Received Command XML Administrator Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Command XML");
XmlRpcResponse response = new XmlRpcResponse();
@ -2320,10 +2286,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
public XmlRpcResponse XmlRpcAccessListClear(XmlRpcRequest request, IPEndPoint remoteClient)
{
m_log.Info("[RADMIN]: Received Access List Clear Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Access List Clear");
XmlRpcResponse response = new XmlRpcResponse();
@ -2360,7 +2324,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
s.RegionInfo.EstateSettings.EstateAccess = new UUID[]{};
if (s.RegionInfo.Persistent)
s.RegionInfo.EstateSettings.Save();
}
catch (Exception e)
{
@ -2368,7 +2331,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
responseData["success"] = false;
responseData["error"] = e.Message;
}
finally
{
@ -2381,10 +2343,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
public XmlRpcResponse XmlRpcAccessListAdd(XmlRpcRequest request, IPEndPoint remoteClient)
{
m_log.Info("[RADMIN]: Received Access List Add Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Access List Add");
XmlRpcResponse response = new XmlRpcResponse();
@ -2450,7 +2410,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
responseData["added"] = addk;
}
catch (Exception e)
{
@ -2458,7 +2417,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
responseData["success"] = false;
responseData["error"] = e.Message;
}
finally
{
@ -2471,10 +2429,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
public XmlRpcResponse XmlRpcAccessListRemove(XmlRpcRequest request, IPEndPoint remoteClient)
{
m_log.Info("[RADMIN]: Received Access List Remove Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Access List Remove");
XmlRpcResponse response = new XmlRpcResponse();
@ -2539,7 +2495,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
responseData["removed"] = remk;
}
catch (Exception e)
{
@ -2547,7 +2502,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
responseData["success"] = false;
responseData["error"] = e.Message;
}
finally
{
@ -2560,10 +2514,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
public XmlRpcResponse XmlRpcAccessListList(XmlRpcRequest request, IPEndPoint remoteClient)
{
m_log.Info("[RADMIN]: Received Access List List Request");
//AnakinLohner 0.6.5-post-fixes
FailIfRemoteAdminDisabled("Access List List");
XmlRpcResponse response = new XmlRpcResponse();
@ -2610,7 +2562,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
responseData["users"] = users;
}
catch (Exception e)
{
@ -2618,7 +2569,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
responseData["success"] = false;
responseData["error"] = e.Message;
}
finally
{
@ -2695,12 +2645,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController
public void Dispose()
{
}
}
class UICallback
{
private Object uilock = new Object();
internal InventoryFolderImpl root = null;
internal List<InventoryFolderImpl> folders;
@ -2720,7 +2668,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
public void GetInventory()
{
Dictionary<UUID, InventoryFolderImpl> fmap = new Dictionary<UUID, InventoryFolderImpl>();
if (OK == false)
@ -2774,8 +2721,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
fmap[item.Folder].Items.Add(item.ID, item);
}
}
}
}

View File

@ -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)
{
}

View File

@ -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
{

View File

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

View File

@ -650,15 +650,17 @@ namespace OpenSim.Framework.Communications
public virtual UUID AddUser(
string firstName, string lastName, string password, string email, uint regX, uint regY, UUID SetUUID)
{
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);
UserProfileData user = new UserProfileData();
user.PasswordSalt = Util.Md5Hash(UUID.Random().ToString());
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + user.PasswordSalt);
user.HomeLocation = new Vector3(128, 128, 100);
user.ID = SetUUID;
user.FirstName = firstName;
user.SurName = lastName;
user.PasswordHash = md5PasswdHash;
user.PasswordSalt = String.Empty;
user.Created = Util.UnixTimeSinceEpoch();
user.HomeLookAt = new Vector3(100, 100, 100);
user.HomeRegionX = regX;

View File

@ -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;

View File

@ -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();

View File

@ -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);
}
}
}

View File

@ -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;

View File

@ -0,0 +1,191 @@
/*
* 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.IO;
using System.Text;
using System.Xml;
using OpenMetaverse;
using OpenSim.Framework;
namespace OpenSim.Framework.Serialization.External
{
/// <summary>
/// Serialize and deserialize LandData as an external format.
/// </summary>
public class LandDataSerializer
{
protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding();
/// <summary>
/// Reify/deserialize landData
/// </summary>
/// <param name="serializedLandData"></param>
/// <returns></returns>
/// <exception cref="System.Xml.XmlException"></exception>
public static LandData Deserialize(byte[] serializedLandData)
{
return Deserialize(m_utf8Encoding.GetString(serializedLandData, 0, serializedLandData.Length));
}
/// <summary>
/// Reify/deserialize landData
/// </summary>
/// <param name="serializedLandData"></param>
/// <returns></returns>
/// <exception cref="System.Xml.XmlException"></exception>
public static LandData Deserialize(string serializedLandData)
{
LandData landData = new LandData();
StringReader sr = new StringReader(serializedLandData);
XmlTextReader xtr = new XmlTextReader(sr);
xtr.ReadStartElement("LandData");
landData.Area = Convert.ToInt32( xtr.ReadElementString("Area"));
landData.AuctionID = Convert.ToUInt32( xtr.ReadElementString("AuctionID"));
landData.AuthBuyerID = UUID.Parse( xtr.ReadElementString("AuthBuyerID"));
landData.Category = (ParcelCategory)Convert.ToSByte( xtr.ReadElementString("Category"));
landData.ClaimDate = Convert.ToInt32( xtr.ReadElementString("ClaimDate"));
landData.ClaimPrice = Convert.ToInt32( xtr.ReadElementString("ClaimPrice"));
landData.GlobalID = UUID.Parse( xtr.ReadElementString("GlobalID"));
landData.GroupID = UUID.Parse( xtr.ReadElementString("GroupID"));
landData.IsGroupOwned = Convert.ToBoolean( xtr.ReadElementString("IsGroupOwned"));
landData.Bitmap = Convert.FromBase64String( xtr.ReadElementString("Bitmap"));
landData.Description = xtr.ReadElementString("Description");
landData.Flags = Convert.ToUInt32( xtr.ReadElementString("Flags"));
landData.LandingType = Convert.ToByte( xtr.ReadElementString("LandingType"));
landData.Name = xtr.ReadElementString("Name");
landData.Status = (ParcelStatus)Convert.ToSByte( xtr.ReadElementString("Status"));
landData.LocalID = Convert.ToInt32( xtr.ReadElementString("LocalID"));
landData.MediaAutoScale = Convert.ToByte( xtr.ReadElementString("MediaAutoScale"));
landData.MediaID = UUID.Parse( xtr.ReadElementString("MediaID"));
landData.MediaURL = xtr.ReadElementString("MediaURL");
landData.MusicURL = xtr.ReadElementString("MusicURL");
landData.OwnerID = UUID.Parse( xtr.ReadElementString("OwnerID"));
landData.ParcelAccessList = new List<ParcelManager.ParcelAccessEntry>();
xtr.Read();
if (xtr.Name != "ParcelAccessList")
throw new XmlException(String.Format("Expected \"ParcelAccessList\" element but got \"{0}\"", xtr.Name));
if (!xtr.IsEmptyElement)
{
while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
{
ParcelManager.ParcelAccessEntry pae = new ParcelManager.ParcelAccessEntry();
xtr.ReadStartElement("ParcelAccessEntry");
pae.AgentID = UUID.Parse( xtr.ReadElementString("AgentID"));
pae.Time = Convert.ToDateTime( xtr.ReadElementString("Time"));
pae.Flags = (AccessList)Convert.ToUInt32( xtr.ReadElementString("AccessList"));
xtr.ReadEndElement();
landData.ParcelAccessList.Add(pae);
}
}
xtr.Read();
landData.PassHours = Convert.ToSingle( xtr.ReadElementString("PassHours"));
landData.PassPrice = Convert.ToInt32( xtr.ReadElementString("PassPrice"));
landData.SalePrice = Convert.ToInt32( xtr.ReadElementString("SalePrice"));
landData.SnapshotID = UUID.Parse( xtr.ReadElementString("SnapshotID"));
landData.UserLocation = Vector3.Parse( xtr.ReadElementString("UserLocation"));
landData.UserLookAt = Vector3.Parse( xtr.ReadElementString("UserLookAt"));
landData.Dwell = Convert.ToInt32( xtr.ReadElementString("Dwell"));
landData.OtherCleanTime = Convert.ToInt32( xtr.ReadElementString("OtherCleanTime"));
xtr.ReadEndElement();
xtr.Close();
sr.Close();
return landData;
}
public static string Serialize(LandData landData)
{
StringWriter sw = new StringWriter();
XmlTextWriter xtw = new XmlTextWriter(sw);
xtw.Formatting = Formatting.Indented;
xtw.WriteStartDocument();
xtw.WriteStartElement("LandData");
xtw.WriteElementString("Area", Convert.ToString(landData.Area));
xtw.WriteElementString("AuctionID", Convert.ToString(landData.AuctionID));
xtw.WriteElementString("AuthBuyerID", landData.AuthBuyerID.ToString());
xtw.WriteElementString("Category", Convert.ToString((sbyte)landData.Category));
xtw.WriteElementString("ClaimDate", Convert.ToString(landData.ClaimDate));
xtw.WriteElementString("ClaimPrice", Convert.ToString(landData.ClaimPrice));
xtw.WriteElementString("GlobalID", landData.GlobalID.ToString());
xtw.WriteElementString("GroupID", landData.GroupID.ToString());
xtw.WriteElementString("IsGroupOwned", Convert.ToString(landData.IsGroupOwned));
xtw.WriteElementString("Bitmap", Convert.ToBase64String(landData.Bitmap));
xtw.WriteElementString("Description", landData.Description);
xtw.WriteElementString("Flags", Convert.ToString((uint)landData.Flags));
xtw.WriteElementString("LandingType", Convert.ToString((byte)landData.LandingType));
xtw.WriteElementString("Name", landData.Name);
xtw.WriteElementString("Status", Convert.ToString((sbyte)landData.Status));
xtw.WriteElementString("LocalID", landData.LocalID.ToString());
xtw.WriteElementString("MediaAutoScale", Convert.ToString(landData.MediaAutoScale));
xtw.WriteElementString("MediaID", landData.MediaID.ToString());
xtw.WriteElementString("MediaURL", landData.MediaURL);
xtw.WriteElementString("MusicURL", landData.MusicURL);
xtw.WriteElementString("OwnerID", landData.OwnerID.ToString());
xtw.WriteStartElement("ParcelAccessList");
foreach (ParcelManager.ParcelAccessEntry pal in landData.ParcelAccessList)
{
xtw.WriteStartElement("ParcelAccessEntry");
xtw.WriteElementString("AgentID", pal.AgentID.ToString());
xtw.WriteElementString("Time", pal.Time.ToString("s"));
xtw.WriteElementString("AccessList", Convert.ToString((uint)pal.Flags));
xtw.WriteEndElement();
}
xtw.WriteEndElement();
xtw.WriteElementString("PassHours", Convert.ToString(landData.PassHours));
xtw.WriteElementString("PassPrice", Convert.ToString(landData.PassPrice));
xtw.WriteElementString("SalePrice", Convert.ToString(landData.SalePrice));
xtw.WriteElementString("SnapshotID", landData.SnapshotID.ToString());
xtw.WriteElementString("UserLocation", landData.UserLocation.ToString());
xtw.WriteElementString("UserLookAt", landData.UserLookAt.ToString());
xtw.WriteElementString("Dwell", Convert.ToString(landData.Dwell));
xtw.WriteElementString("OtherCleanTime", Convert.ToString(landData.OtherCleanTime));
xtw.WriteEndElement();
xtw.Close();
sw.Close();
return sw.ToString();
}
}
}

View File

@ -0,0 +1,131 @@
/*
* 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 OpenSim.Framework;
using OpenSim.Framework.Serialization.External;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using NUnit.Framework;
namespace OpenSim.Framework.Serialization.Tests
{
[TestFixture]
public class LandDataSerializerTest
{
private LandData land;
private LandData landWithParcelAccessList;
private static string preSerialized = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\n<LandData>\n <Area>128</Area>\n <AuctionID>0</AuctionID>\n <AuthBuyerID>00000000-0000-0000-0000-000000000000</AuthBuyerID>\n <Category>10</Category>\n <ClaimDate>0</ClaimDate>\n <ClaimPrice>0</ClaimPrice>\n <GlobalID>54ff9641-dd40-4a2c-b1f1-47dd3af24e50</GlobalID>\n <GroupID>d740204e-bbbf-44aa-949d-02c7d739f6a5</GroupID>\n <IsGroupOwned>False</IsGroupOwned>\n <Bitmap>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</Bitmap>\n <Description>land data to test LandDataSerializer</Description>\n <Flags>536870944</Flags>\n <LandingType>2</LandingType>\n <Name>LandDataSerializerTest Land</Name>\n <Status>0</Status>\n <LocalID>0</LocalID>\n <MediaAutoScale>1</MediaAutoScale>\n <MediaID>d4452578-2f25-4b97-a81b-819af559cfd7</MediaID>\n <MediaURL>http://videos.opensimulator.org/bumblebee.mp4</MediaURL>\n <MusicURL />\n <OwnerID>1b8eedf9-6d15-448b-8015-24286f1756bf</OwnerID>\n <ParcelAccessList />\n <PassHours>0</PassHours>\n <PassPrice>0</PassPrice>\n <SalePrice>0</SalePrice>\n <SnapshotID>00000000-0000-0000-0000-000000000000</SnapshotID>\n <UserLocation>&lt;0, 0, 0&gt;</UserLocation>\n <UserLookAt>&lt;0, 0, 0&gt;</UserLookAt>\n <Dwell>0</Dwell>\n <OtherCleanTime>0</OtherCleanTime>\n</LandData>";
private static string preSerializedWithParcelAccessList = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\n<LandData>\n <Area>128</Area>\n <AuctionID>0</AuctionID>\n <AuthBuyerID>00000000-0000-0000-0000-000000000000</AuthBuyerID>\n <Category>10</Category>\n <ClaimDate>0</ClaimDate>\n <ClaimPrice>0</ClaimPrice>\n <GlobalID>54ff9641-dd40-4a2c-b1f1-47dd3af24e50</GlobalID>\n <GroupID>d740204e-bbbf-44aa-949d-02c7d739f6a5</GroupID>\n <IsGroupOwned>False</IsGroupOwned>\n <Bitmap>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</Bitmap>\n <Description>land data to test LandDataSerializer</Description>\n <Flags>536870944</Flags>\n <LandingType>2</LandingType>\n <Name>LandDataSerializerTest Land</Name>\n <Status>0</Status>\n <LocalID>0</LocalID>\n <MediaAutoScale>1</MediaAutoScale>\n <MediaID>d4452578-2f25-4b97-a81b-819af559cfd7</MediaID>\n <MediaURL>http://videos.opensimulator.org/bumblebee.mp4</MediaURL>\n <MusicURL />\n <OwnerID>1b8eedf9-6d15-448b-8015-24286f1756bf</OwnerID>\n <ParcelAccessList>\n <ParcelAccessEntry>\n <AgentID>62d65d45-c91a-4f77-862c-46557d978b6c</AgentID>\n <Time>2009-10-01T00:00:00</Time>\n <AccessList>2</AccessList>\n </ParcelAccessEntry>\n <ParcelAccessEntry>\n <AgentID>ec2a8d18-2378-4fe0-8b68-2a31b57c481e</AgentID>\n <Time>2010-10-20T00:00:00</Time>\n <AccessList>1</AccessList>\n </ParcelAccessEntry>\n </ParcelAccessList>\n <PassHours>0</PassHours>\n <PassPrice>0</PassPrice>\n <SalePrice>0</SalePrice>\n <SnapshotID>00000000-0000-0000-0000-000000000000</SnapshotID>\n <UserLocation>&lt;0, 0, 0&gt;</UserLocation>\n <UserLookAt>&lt;0, 0, 0&gt;</UserLookAt>\n <Dwell>0</Dwell>\n <OtherCleanTime>0</OtherCleanTime>\n</LandData>";
[SetUp]
public void setup()
{
// setup LandData object
this.land = new LandData();
this.land.AABBMax = new Vector3(0, 0, 0);
this.land.AABBMin = new Vector3(128, 128, 128);
this.land.Area = 128;
this.land.AuctionID = 0;
this.land.AuthBuyerID = new UUID();
this.land.Category = ParcelCategory.Residential;
this.land.ClaimDate = 0;
this.land.ClaimPrice = 0;
this.land.GlobalID = new UUID("54ff9641-dd40-4a2c-b1f1-47dd3af24e50");
this.land.GroupID = new UUID("d740204e-bbbf-44aa-949d-02c7d739f6a5");
this.land.GroupPrims = 0;
this.land.Description = "land data to test LandDataSerializer";
this.land.Flags = (uint)(ParcelFlags.AllowDamage | ParcelFlags.AllowVoiceChat);
this.land.LandingType = (byte)LandingType.Direct;
this.land.Name = "LandDataSerializerTest Land";
this.land.Status = ParcelStatus.Leased;
this.land.LocalID = 0;
this.land.MediaAutoScale = (byte)0x01;
this.land.MediaID = new UUID("d4452578-2f25-4b97-a81b-819af559cfd7");
this.land.MediaURL = "http://videos.opensimulator.org/bumblebee.mp4";
this.land.OwnerID = new UUID("1b8eedf9-6d15-448b-8015-24286f1756bf");
this.landWithParcelAccessList = this.land.Copy();
this.landWithParcelAccessList.ParcelAccessList.Clear();
ParcelManager.ParcelAccessEntry pae0 = new ParcelManager.ParcelAccessEntry();
pae0.AgentID = new UUID("62d65d45-c91a-4f77-862c-46557d978b6c");
pae0.Flags = AccessList.Ban;
pae0.Time = new DateTime(2009, 10, 01);
this.landWithParcelAccessList.ParcelAccessList.Add(pae0);
ParcelManager.ParcelAccessEntry pae1 = new ParcelManager.ParcelAccessEntry();
pae1.AgentID = new UUID("ec2a8d18-2378-4fe0-8b68-2a31b57c481e");
pae1.Flags = AccessList.Access;
pae1.Time = new DateTime(2010, 10, 20);
this.landWithParcelAccessList.ParcelAccessList.Add(pae1);
}
/// <summary>
/// Test the LandDataSerializer.Serialize() method
/// </summary>
[Test]
public void LandDataSerializerSerializeTest()
{
string serialized = LandDataSerializer.Serialize(this.land);
Assert.That(serialized.Length > 0, "Serialize(LandData) returned empty string");
Assert.That(serialized == LandDataSerializerTest.preSerialized,
"result of Serialize(LandData) does not match expected result");
string serializedWithParcelAccessList = LandDataSerializer.Serialize(this.landWithParcelAccessList);
Assert.That(serializedWithParcelAccessList.Length > 0,
"Serialize(LandData) returned empty string for LandData object with ParcelAccessList");
Assert.That(serializedWithParcelAccessList == LandDataSerializerTest.preSerializedWithParcelAccessList,
"result of Serialize(LandData) does not match expected result (pre-serialized with parcel access list");
}
/// <summary>
/// Test the LandDataSerializer.Deserialize() method
/// </summary>
[Test]
public void TestLandDataSerializerDeserializeFromStringTest()
{
LandData reifiedLandData = LandDataSerializer.Deserialize(LandDataSerializerTest.preSerialized);
Assert.That(reifiedLandData != null, "Deserialize(string) returned null");
Assert.That(reifiedLandData.GlobalID == this.land.GlobalID, "Reified LandData.GlobalID != original LandData.GlobalID");
Assert.That(reifiedLandData.Name == this.land.Name, "Reified LandData.Name != original LandData.Name");
LandData reifiedLandDataWithParcelAccessList = LandDataSerializer.Deserialize(LandDataSerializerTest.preSerializedWithParcelAccessList);
Assert.That(reifiedLandDataWithParcelAccessList != null,
"Deserialize(string) returned null (pre-serialized with parcel access list)");
Assert.That(reifiedLandDataWithParcelAccessList.GlobalID == this.landWithParcelAccessList.GlobalID,
"Reified LandData.GlobalID != original LandData.GlobalID (pre-serialized with parcel access list)");
Assert.That(reifiedLandDataWithParcelAccessList.Name == this.landWithParcelAccessList.Name,
"Reified LandData.Name != original LandData.Name (pre-serialized with parcel access list)");
}
}
}

View File

@ -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();

View File

@ -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)

View File

@ -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();
return GridRegionToRegionInfo(m_GridService.GetRegionByUUID(UUID.Zero, homeRegionId));
}
else
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)
@ -280,9 +279,8 @@ namespace OpenSim.Grid.UserServer.Modules
//response.SeedCapability = serverURI + CapsUtil.GetCapsSeedPath(capsPath);
// Take off trailing / so that the caps path isn't //CAPS/someUUID
if (regionInfo.httpServerURI.EndsWith("/"))
regionInfo.httpServerURI = regionInfo.httpServerURI.Substring(0, regionInfo.httpServerURI.Length - 1);
response.SeedCapability = regionInfo.httpServerURI + CapsUtil.GetCapsSeedPath(capsPath);
string uri = regionInfo.httpServerURI.Trim(new char[] { '/' });
response.SeedCapability = uri + CapsUtil.GetCapsSeedPath(capsPath);
// Notify the target of an incoming user

View File

@ -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 <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]");
m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]");
m_log.Info("Usage: link-region <URI_of_xml> [<exclude>]");
}
private static void UnlinkRegionCmdUsage()
{
m_log.Info("Usage: unlink-region <HostName>:<HttpPort>");
m_log.Info("Usage: unlink-region <LocalName>");
}
}
}

View File

@ -497,7 +497,7 @@ namespace OpenSim
{
if (cmd.Length < 4)
{
m_log.Error("Usage: create region <region name> <region_file.xml>");
m_log.Error("Usage: create region <region name> <region_file.ini>");
return;
}
if (cmd[3].EndsWith(".xml"))
@ -524,7 +524,7 @@ namespace OpenSim
}
else
{
m_log.Error("Usage: create region <region name> <region_file.xml>");
m_log.Error("Usage: create region <region name> <region_file.ini>");
return;
}
}
@ -755,11 +755,6 @@ namespace OpenSim
}
break;
case "link-region":
case "unlink-region":
case "link-mapping":
HGCommands.RunHGCommand(command, cmdparams, m_sceneManager.CurrentOrFirstScene);
break;
}
}

View File

@ -399,7 +399,7 @@ namespace OpenSim
}
catch (Exception e)
{
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

View File

@ -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) { }
/// <summary>
/// Doesn't really matter what the call is - we're using this to test that a packet has actually been received

View File

@ -40,21 +40,12 @@ namespace OpenSim.Region.Communications.Hypergrid
{
public class HGCommunicationsGridMode : CommunicationsManager // CommunicationsOGS1
{
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.

View File

@ -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;
}
}
}

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

@ -39,8 +39,6 @@ namespace OpenSim.Region.Communications.OGS1
LibraryRootFolder libraryRootFolder)
: 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);

View File

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

View File

@ -40,6 +40,7 @@ using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.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<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>();
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<IMessageTransferModule>();
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<UUID> tpdAway = new List<UUID>();
// 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);

View File

@ -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
/// <param name="reginfo">RegionInfo we pull the data out of to send the request to</param>
/// <param name="xmlrpcdata">The Instant Message data Hashtable</param>
/// <returns>Bool if the message was successfully delivered at the other side.</returns>
protected virtual bool doIMSending(RegionInfo reginfo, Hashtable xmlrpcdata)
protected virtual bool doIMSending(GridRegion reginfo, Hashtable xmlrpcdata)
{
ArrayList SendParams = new ArrayList();

View File

@ -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();

View File

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

View File

@ -34,6 +34,7 @@ using OpenSim.Framework;
using OpenSim.Region.CoreModules.World.WorldMap;
using OpenSim.Region.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<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4);
List<MapBlockData> mapBlocks = new List<MapBlockData>();
List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
(minX - 4) * (int)Constants.RegionSize, (maxX + 4) * (int)Constants.RegionSize,
(minY - 4) * (int)Constants.RegionSize, (maxY + 4) * (int)Constants.RegionSize);
foreach (GridRegion r in regions)
{
MapBlockData block = new MapBlockData();
MapBlockFromGridRegion(block, r);
mapBlocks.Add(block);
}
// Different from super
FillInMap(mapBlocks, minX, minY, maxX, maxY);

View File

@ -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
{
@ -90,6 +92,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
}
public void AddRegion(Scene scene)
{
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_Enabled)
return;
@ -102,27 +120,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
Object[] args = new Object[] { m_Config, MainServer.Instance };
m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance);
m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance, scene.RequestModuleInterface<IHyperlinkService>());
//ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
}
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
}

View File

@ -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

View File

@ -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)
{

View File

@ -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<ulong, Scene> m_LocalScenes = new Dictionary<ulong, Scene>();
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<IGridService>(this);
scene.RegisterModuleInterface<IHyperlinkService>(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 <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
"Link a hypergrid region", hgCommands.RunCommand);
MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlinkk-region",
MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlink-region",
"unlink-region <local name> or <HostName>:<HttpPort> <cr>",
"Unlink a hypergrid region", hgCommands.RunCommand);
MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-mapping", "link-mapping [<x> <y>] <cr>",
MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
"Set local coordinate to map HG regions to", hgCommands.RunCommand);
// 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 <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
// "Link a hypergrid region", hgCommands.RunCommand);
//scene.AddCommand("HGGridServicesConnector", "unlinkk-region",
// "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
// "Unlink a hypergrid region", hgCommands.RunCommand);
//scene.AddCommand("HGGridServicesConnector", "linkk-mapping", "link-mapping [<x> <y>] <cr>",
// "Set local coordinate to map HG regions to", hgCommands.RunCommand);
}
#endregion
@ -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,8 +286,10 @@ 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
return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y);
@ -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,13 +466,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
}
// Finally, link it
try
if (!RegisterRegion(UUID.Zero, regInfo))
{
RegisterRegion(UUID.Zero, regInfo);
}
catch (Exception e)
{
m_log.Warn("[HGrid]: Unable to link region: " + e.Message);
m_log.Warn("[HGrid]: Unable to link region");
return false;
}
@ -539,8 +554,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
x = (int)(ux / Constants.RegionSize);
y = (int)(uy / Constants.RegionSize);
if ((Math.Abs((int)(m_scene.RegionInfo.RegionLocX / Constants.RegionSize) - x) >= 4096) ||
(Math.Abs((int)(m_scene.RegionInfo.RegionLocY / Constants.RegionSize) - y) >= 4096))
if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - x) >= 4096) ||
(Math.Abs((int)m_scene.RegionInfo.RegionLocY - y) >= 4096))
{
return false;
}
@ -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
}
}

View File

@ -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<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>();
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,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
if (m_Enabled)
scene.RegisterModuleInterface<IGridService>(this);
if (m_MainInstance == this)
{
if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID))
m_log.ErrorFormat("[LOCAL GRID CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!");
else
m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene));
}
}
public void RemoveRegion(Scene scene)
{
if (m_MainInstance == this)
{
m_LocalCache[scene.RegionInfo.RegionID].Clear();
m_LocalCache.Remove(scene.RegionInfo.RegionID);
}
}
public void RegionLoaded(Scene scene)
@ -158,7 +181,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
{
return m_GridService.GetNeighbours(scopeID, regionID);
if (m_LocalCache.ContainsKey(regionID))
{
List<GridRegion> neighbours = m_LocalCache[regionID].GetNeighbours();
if (neighbours.Count == 0)
// try the DB
neighbours = m_GridService.GetNeighbours(scopeID, regionID);
return neighbours;
}
else
{
m_log.WarnFormat("[LOCAL GRID CONNECTOR]: GetNeighbours: Requested region {0} is not on this sim", regionID);
return new List<GridRegion>();
}
// Don't go to the DB
//return m_GridService.GetNeighbours(scopeID, regionID);
}
public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
@ -187,5 +225,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
}
#endregion
public void NeighboursCommand(string module, string[] cmdparams)
{
foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache)
{
m_log.InfoFormat("*** Neighbours of {0} {1} ***", kvp.Key, kvp.Value.RegionName);
List<GridRegion> regions = kvp.Value.GetNeighbours();
foreach (GridRegion r in regions)
m_log.InfoFormat(" {0} @ {1}={2}", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize);
}
}
}
}

View File

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

View File

@ -104,6 +104,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public void PostInitialise()
{
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<IGridService>(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<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
{
return m_LocalGridService.GetNeighbours(scopeID, regionID);
}
public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
{

View File

@ -78,6 +78,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
r1.ExternalHostName = "127.0.0.1";
r1.HttpPort = 9001;
r1.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
Scene s = new Scene(new RegionInfo());
s.RegionInfo.RegionID = r1.RegionID;
m_LocalConnector.AddRegion(s);
GridRegion r2 = new GridRegion();
r2.RegionName = "Test Region 2";
@ -87,6 +91,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
r2.ExternalHostName = "127.0.0.1";
r2.HttpPort = 9002;
r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
s = new Scene(new RegionInfo());
s.RegionInfo.RegionID = r1.RegionID;
m_LocalConnector.AddRegion(s);
GridRegion r3 = new GridRegion();
r3.RegionName = "Test Region 3";
@ -96,6 +103,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
r3.ExternalHostName = "127.0.0.1";
r3.HttpPort = 9003;
r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
s = new Scene(new RegionInfo());
s.RegionInfo.RegionID = r1.RegionID;
m_LocalConnector.AddRegion(s);
m_LocalConnector.RegisterRegion(UUID.Zero, r1);
GridRegion result = m_LocalConnector.GetRegionByName(UUID.Zero, "Test");

View File

@ -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<IHyperlinkService>();
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);
}
}

View File

@ -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 != ""))

View File

@ -107,7 +107,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
public void AddRegion(Scene scene)
{
m_Scene = scene;
m_log.Debug("[XXXX] Adding scene " + m_Scene.RegionInfo.RegionName);
//m_log.Debug("[XXXX] Adding scene " + m_Scene.RegionInfo.RegionName);
if (!m_Enabled)
return;

View File

@ -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<ILandService>(this);
}

View File

@ -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

View File

@ -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<INeighbourService>(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);
}

View File

@ -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,7 +1361,8 @@ namespace OpenSim.Region.CoreModules.World.Land
}
else
{
extLandData.landData = m_scene.CommsManager.GridService.RequestLandData(extLandData.regionHandle,
ILandService landService = m_scene.RequestModuleInterface<ILandService>();
extLandData.landData = landService.GetLandData(extLandData.regionHandle,
extLandData.x,
extLandData.y);
if (extLandData.landData == null)
@ -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");

View File

@ -35,6 +35,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Client;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Framework.Console;
namespace OpenSim.Region.CoreModules.World.Land
{
@ -61,6 +62,9 @@ namespace OpenSim.Region.CoreModules.World.Land
IConfig myConfig = source.Configs["Startup"];
enabledYN = myConfig.GetBoolean("CombineContiguousRegions", false);
//enabledYN = true;
if (enabledYN)
MainConsole.Instance.Commands.AddCommand("RegionCombinerModule", false, "fix-phantoms",
"Fix phantom objects", "Fixes phantom objects after an import to megaregions", FixPhantoms);
}
public void Close()
@ -910,5 +914,20 @@ namespace OpenSim.Region.CoreModules.World.Land
VirtualRegion.Permissions.OnTeleport += BigRegion.PermissionModule.CanTeleport; //NOT YET IMPLEMENTED
VirtualRegion.Permissions.OnUseObjectReturn += BigRegion.PermissionModule.CanUseObjectReturn; //NOT YET IMPLEMENTED
}
#region console commands
public void FixPhantoms(string module, string[] cmdparams)
{
List<Scene> scenes = new List<Scene>(m_startingScenes.Values);
foreach (Scene s in scenes)
{
s.ForEachSOG(delegate(SceneObjectGroup e)
{
e.AbsolutePosition = e.AbsolutePosition;
}
);
}
}
#endregion
}
}

View File

@ -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<RegionInfo> regionInfos = m_scene.SceneGridService.RequestNamedRegions(mapName, 20);
List<GridRegion> 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>();
RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName);
regionInfos = new List<GridRegion>();
GridRegion info = m_scene.GridService.GetRegionByName(UUID.Zero, mapName);
if (info != null) regionInfos.Add(info);
}
@ -109,30 +111,34 @@ 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);
IHyperlinkService hyperService = cScene.RequestModuleInterface<IHyperlinkService>();
if (hyperService != null)
{
regInfo = hyperService.TryLinkRegion(remoteClient, mapName);
if (regInfo != null)
regionInfos.Add(regInfo);
}
}
}
List<MapBlockData> blocks = new List<MapBlockData>();
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);
}
}

View File

@ -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,9 +233,19 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
}
if (lookup)
{
List<MapBlockData> mapBlocks;
List<MapBlockData> mapBlocks = new List<MapBlockData>(); ;
mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks((int)m_scene.RegionInfo.RegionLocX - 8, (int)m_scene.RegionInfo.RegionLocY - 8, (int)m_scene.RegionInfo.RegionLocX + 8, (int)m_scene.RegionInfo.RegionLocY + 8);
List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
(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)
@ -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<MapBlockData> response = new List<MapBlockData>();
// this should return one mapblock at most. But make sure: Look whether the one we requested is in there
List<MapBlockData> 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<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
minX * (int)Constants.RegionSize,
maxX * (int)Constants.RegionSize,
minY * (int)Constants.RegionSize,
maxY * (int)Constants.RegionSize);
if (regions != null)
{
foreach (MapBlockData block in mapBlocks)
foreach (GridRegion r in regions)
{
if (block.X == minX && block.Y == minY)
if ((r.RegionLocX == minX * (int)Constants.RegionSize) &&
(r.RegionLocY == minY * (int)Constants.RegionSize))
{
// found it => add it to response
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<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4);
List<MapBlockData> mapBlocks = new List<MapBlockData>();
List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
(minX - 4) * (int)Constants.RegionSize,
(maxX + 4) * (int)Constants.RegionSize,
(minY - 4) * (int)Constants.RegionSize,
(maxY + 4) * (int)Constants.RegionSize);
foreach (GridRegion r in regions)
{
MapBlockData block = new MapBlockData();
MapBlockFromGridRegion(block, r);
mapBlocks.Add(block);
}
remoteClient.SendMapBlock(mapBlocks, flag);
}
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<MapBlockData> 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<MapBlockData> mapBlocks = new List<MapBlockData>();
List<GridRegion> 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<AssetBase> textures = new List<AssetBase>();
List<Image> bitImages = new List<Image>();
foreach (MapBlockData mapBlock in mapBlocks)
foreach (GridRegion r in regions)
{
MapBlockData mapBlock = new MapBlockData();
MapBlockFromGridRegion(mapBlock, r);
AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
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)

View File

@ -94,7 +94,7 @@ namespace OpenSim.Region.Framework.Scenes
set { m_velocity = value; }
}
protected Quaternion m_rotation = new Quaternion(0f, 0f, 1f, 0f);
protected Quaternion m_rotation;
public virtual Quaternion Rotation
{
@ -102,6 +102,14 @@ namespace OpenSim.Region.Framework.Scenes
set { m_rotation = value; }
}
protected Vector3 m_scale;
public virtual Vector3 Scale
{
get { return m_scale; }
set { m_scale = value; }
}
protected uint m_localId;
public virtual uint LocalId
@ -115,13 +123,9 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
public EntityBase()
{
m_uuid = UUID.Zero;
m_pos = Vector3.Zero;
m_velocity = Vector3.Zero;
Rotation = Quaternion.Identity;
m_rotation = Quaternion.Identity;
m_scale = Vector3.One;
m_name = "(basic entity)";
m_rotationalvelocity = Vector3.Zero;
}
/// <summary>

View File

@ -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);
}
}
}

View File

@ -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<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
private Scene m_scene;
private IHyperlinkService m_hyper;
IHyperlinkService HyperlinkService
{
get
{
if (m_hyper == null)
m_hyper = m_scene.RequestModuleInterface<IHyperlinkService>();
return m_hyper;
}
}
#endregion
#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

View File

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

View File

@ -29,6 +29,7 @@ using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.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;

View File

@ -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<IHyperlinkService>();
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());
}

View File

@ -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<IGridService>();
if (m_GridService == null)
{
throw new Exception("No IGridService available. This could happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. Please also check that you have the correct version of your inventory service dll. Sometimes old versions of this dll will still exist. Do a clean checkout and re-create the opensim.ini from the opensim.ini.example.");
}
}
return m_GridService;
}
}
protected IXMLRPC m_xmlrpcModule;
protected IWorldComm m_worldCommModule;
protected IAvatarFactory m_AvatarFactory;
@ -566,10 +587,7 @@ namespace OpenSim.Region.Framework.Scenes
}
/// <summary>
/// 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
/// </summary>
/// <param name="otherRegion">RegionInfo handle for the new region.</param>
/// <returns>True after all operations complete, throws exceptions otherwise.</returns>
public override bool OtherRegionUp(RegionInfo otherRegion)
public override void OtherRegionUp(GridRegion otherRegion)
{
m_log.InfoFormat("[SCENE]: Region {0} up in coords {1}-{2}", otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY);
uint xcell = (uint)((int)otherRegion.RegionLocX / (int)Constants.RegionSize);
uint ycell = (uint)((int)otherRegion.RegionLocY / (int)Constants.RegionSize);
m_log.InfoFormat("[SCENE]: (on region {0}): Region {1} up in coords {2}-{3}",
RegionInfo.RegionName, otherRegion.RegionName, xcell, ycell);
if (RegionInfo.RegionHandle != otherRegion.RegionHandle)
{
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<ulong> old = new List<ulong>();
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);
}
/// <summary>
@ -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<INeighbourService>(), RegionInfo);
Dictionary<string, string> dGridSettings = m_sceneGridService.GetGridSettings();
//Dictionary<string, string> 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);
// }
//}
}
/// <summary>
@ -2296,8 +2305,8 @@ namespace OpenSim.Region.Framework.Scenes
"to avatar {0} at position {1}",
sp.UUID.ToString(), grp.AbsolutePosition);
AttachObject(sp.ControllingClient,
grp.LocalId, (uint)0,
grp.GroupRotation,
grp.LocalId, 0,
grp.Rotation,
grp.AbsolutePosition, false);
RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
grp.SendGroupFullUpdate();
@ -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);
}
/// <summary>
@ -3556,30 +3571,6 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours);
}
/// <summary>
/// Requests information about this region from gridcomms
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
{
return m_sceneGridService.RequestNeighbouringRegionInfo(regionHandle);
}
/// <summary>
/// Requests textures for map from minimum region to maximum region in world cordinates
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="minX"></param>
/// <param name="minY"></param>
/// <param name="maxX"></param>
/// <param name="maxY"></param>
public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
{
m_log.DebugFormat("[MAPBLOCK]: {0}-{1}, {2}-{3}", minX, minY, maxX, maxY);
m_sceneGridService.RequestMapBlocks(remoteClient, minX, minY, maxX, maxY);
}
/// <summary>
/// Tries to teleport agent to other region.
/// </summary>
@ -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
/// <param name="position"></param>
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
@ -4154,6 +4141,11 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGraph.ForEachClient(action);
}
public void ForEachSOG(Action<SceneObjectGroup> action)
{
m_sceneGraph.ForEachSOG(action);
}
/// <summary>
/// Returns a list of the entities in the scene. This is a new list so operations perform on the list itself
/// will not affect the original list of objects in the scene.
@ -4178,14 +4170,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)

View File

@ -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()
{

View File

@ -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
/// </summary>
public event PrimCrossing OnPrimCrossingIntoRegion;
/// <summary>
/// A New Region is up and available
/// </summary>
public event RegionUp OnRegionUp;
///// <summary>
///// A New Region is up and available
///// </summary>
//public event RegionUp OnRegionUp;
/// <summary>
/// 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<UUID>();
}
public void SetScene(Scene s)
{
m_scene = s;
m_regionInfo = s.RegionInfo;
m_interregionCommsOut = m_scene.RequestModuleInterface<IInterregionCommsOut>();
}
/// <summary>
/// Register a region with the grid
/// </summary>
@ -138,40 +147,30 @@ namespace OpenSim.Region.Framework.Scenes
/// <exception cref="System.Exception">Thrown if region registration fails.</exception>
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");
}
}
/// <summary>
/// Returns a region with the name closest to string provided
/// </summary>
/// <param name="name">Partial Region Name for matching</param>
/// <returns>Region Information for the region</returns>
public RegionInfo RequestClosestRegion(string name)
{
return m_commsProvider.GridService.RequestClosestRegion(name);
// 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");
//}
}
/// <summary>
@ -180,30 +179,31 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
public void Close()
{
if (regionCommsHost != null)
{
regionCommsHost.OnLogOffUser -= GridLogOffUser;
regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate;
regionCommsHost.OnRegionUp -= newRegionUp;
regionCommsHost.OnExpectUser -= NewUserConnection;
regionCommsHost.OnExpectPrim -= IncomingPrimCrossing;
regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing;
regionCommsHost.OnCloseAgentConnection -= CloseConnection;
regionCommsHost.OnGetLandData -= FetchLandData;
try
{
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);
}
//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;
regionCommsHost = null;
}
// try
// {
// m_commsProvider.GridService.DeregisterRegion(m_regionInfo);
// }
// catch (Exception e)
// {
// m_log.ErrorFormat(
// "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing",
// m_regionInfo.RegionName, e);
// }
// regionCommsHost = null;
//}
}
#region CommsManager Event handlers
@ -238,22 +238,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
/// <summary>
/// A New Region is now available. Inform the scene that there is a new region available.
/// </summary>
/// <param name="region">Information about the new region that is available</param>
/// <returns>True if the event was handled</returns>
protected bool newRegionUp(RegionInfo region)
{
handlerRegionUp = OnRegionUp;
if (handlerRegionUp != null)
{
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: newRegionUp Fired for User:" + region.RegionName);
handlerRegionUp(region);
}
return true;
}
/// <summary>
/// Inform the scene that we've got an update about a child agent that we have
/// </summary>
@ -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
/// <param name="a"></param>
/// <param name="regionHandle"></param>
/// <param name="endPoint"></param>
private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg,
private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, GridRegion reg,
IPEndPoint endPoint, bool newAgent)
{
// Let's wait just a little to give time to originating regions to catch up with closing child agents
@ -373,7 +357,6 @@ namespace OpenSim.Region.Framework.Scenes
string reason = String.Empty;
//bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a);
bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason);
@ -407,17 +390,7 @@ namespace OpenSim.Region.Framework.Scenes
}
public void RequestNeighbors(RegionInfo region)
{
// List<SimpleRegionInfo> neighbours =
m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
//IPEndPoint blah = new IPEndPoint();
//blah.Address = region.RemotingAddress;
//blah.Port = region.RemotingPort;
}
public List<SimpleRegionInfo> RequestNeighbors(Scene pScene, uint pRegionLocX, uint pRegionLocY)
public List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
{
Border[] northBorders = pScene.NorthBorders.ToArray();
Border[] southBorders = pScene.SouthBorders.ToArray();
@ -427,7 +400,7 @@ 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
{
@ -441,36 +414,20 @@ namespace OpenSim.Region.Framework.Scenes
extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
}
List<SimpleRegionInfo> neighbourList = new List<SimpleRegionInfo>();
// Loss of fraction on purpose
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<endX;i++)
{
for (int j=startY;j<endY;j++)
{
// Skip CurrentRegion
if (i == (int)pRegionLocX && j == (int)pRegionLocY)
continue;
List<GridRegion> neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
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,30 +439,29 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
{
List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
//List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
List<GridRegion> neighbours = new List<GridRegion>();
//m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
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.
List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region
@ -547,7 +503,8 @@ namespace OpenSim.Region.Framework.Scenes
/// Create the necessary child agents
List<AgentCircuitData> cagents = new List<AgentCircuitData>();
foreach (SimpleRegionInfo neighbour in neighbours)
//foreach (SimpleRegionInfo neighbour in neighbours)
foreach (GridRegion neighbour in neighbours)
{
if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
{
@ -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.
/// </summary>
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
/// <param name="regionhandle"></param>
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);
}
}
/// <summary>
/// Called by scene when region is initialized (not always when it's listening for agents)
/// This is an inter-region message that informs the surrounding neighbors that the sim is up.
/// </summary>
public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region)
{
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
// 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++)
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,
d.BeginInvoke(neighbourService, region, handle,
InformNeighborsThatRegionisUpCompleted,
d);
}
}
//List<GridRegion> neighbours = new List<GridRegion>();
//// This stays uncached because we don't already know about our neighbors at this point.
//neighbours = m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
//if (neighbours != null)
//{
// for (int i = 0; i < neighbours.Count; i++)
// {
// InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
// d.BeginInvoke(neighbourService, region, neighbours[i].RegionHandle,
// InformNeighborsThatRegionisUpCompleted,
// d);
// }
//}
//bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region));
}
public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle);
/// <summary>
@ -822,41 +781,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
/// <summary>
/// Helper function to request neighbors from grid-comms
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public virtual RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
{
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionHandle.ToString());
return m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
}
/// <summary>
/// Helper function to request neighbors from grid-comms
/// </summary>
/// <param name="regionID"></param>
/// <returns></returns>
public virtual RegionInfo RequestNeighbouringRegionInfo(UUID regionID)
{
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionID);
return m_commsProvider.GridService.RequestNeighbourInfo(regionID);
}
/// <summary>
/// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
/// </summary>
/// <param name="minX"></param>
/// <param name="minY"></param>
/// <param name="maxX"></param>
/// <param name="maxY"></param>
public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
{
List<MapBlockData> mapBlocks;
mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4);
remoteClient.SendMapBlock(mapBlocks, 0);
}
/// <summary>
/// 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<ulong> NeighbourHandles(List<SimpleRegionInfo> neighbours)
private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
{
List<ulong> handles = new List<ulong>();
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<string, string> 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<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
{
return m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
}
public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
{
return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
}
public List<RegionInfo> RequestNamedRegions(string name, int maxNumber)
public List<GridRegion> RequestNamedRegions(string name, int maxNumber)
{
return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber);
return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber);
}
//private void Dump(string msg, List<ulong> handles)

View File

@ -1134,6 +1134,23 @@ namespace OpenSim.Region.Framework.Scenes
}
}
protected internal void ForEachSOG(Action<SceneObjectGroup> action)
{
List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values);
foreach (SceneObjectGroup obj in objlist)
{
try
{
action(obj);
}
catch (Exception e)
{
// Catch it and move on. This includes situations where splist has inconsistent info
m_log.WarnFormat("[SCENE]: Problem processing action in ForEachSOG: ", e.Message);
}
}
}
#endregion
#region Client Event handlers

View File

@ -204,9 +204,22 @@ namespace OpenSim.Region.Framework.Scenes
get { return m_parts.Count; }
}
public Quaternion GroupRotation
public override Quaternion Rotation
{
get { return m_rootPart.RotationOffset; }
set { m_rootPart.RotationOffset = value; }
}
public override Vector3 Scale
{
get { return m_rootPart.Scale; }
set { m_rootPart.Scale = value; }
}
public override Vector3 Velocity
{
get { return m_rootPart.Velocity; }
set { m_rootPart.Velocity = value; }
}
public UUID GroupID
@ -535,7 +548,7 @@ namespace OpenSim.Region.Framework.Scenes
// Temporary commented to stop compiler warning
//Vector3 partPosition =
// new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z);
Quaternion parentrotation = GroupRotation;
Quaternion parentrotation = Rotation;
// Telling the prim to raytrace.
//EntityIntersection inter = part.TestIntersection(hRay, parentrotation);
@ -1878,14 +1891,17 @@ namespace OpenSim.Region.Framework.Scenes
checkAtTargets();
if (UsePhysics && ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1)
|| (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1)
|| (Math.Abs(lastPhysGroupRot.Y - GroupRotation.Y) > 0.1)
|| (Math.Abs(lastPhysGroupRot.Z - GroupRotation.Z) > 0.1)))
Quaternion rot = Rotation;
if (UsePhysics &&
((Math.Abs(lastPhysGroupRot.W - rot.W) > 0.1f)
|| (Math.Abs(lastPhysGroupRot.X - rot.X) > 0.1f)
|| (Math.Abs(lastPhysGroupRot.Y - rot.Y) > 0.1f)
|| (Math.Abs(lastPhysGroupRot.Z - rot.Z) > 0.1f)))
{
m_rootPart.UpdateFlag = 1;
lastPhysGroupRot = GroupRotation;
lastPhysGroupRot = rot;
}
foreach (SceneObjectPart part in m_parts.Values)

View File

@ -3451,7 +3451,7 @@ if (m_shape != null) {
}
else // it already has a physical representation
{
PhysActor.IsPhysical = UsePhysics;
pa.IsPhysical = UsePhysics;
DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim
if (m_parentGroup != null)
@ -3480,7 +3480,6 @@ if (m_shape != null) {
AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active
this.VolumeDetectActive = true;
}
}
else
{ // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like

View File

@ -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)
{

View File

@ -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();
}

View File

@ -52,7 +52,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
/// Test a teleport between two regions that are not neighbours and do not share any neighbours in common.
/// </summary>
/// Does not yet do what is says on the tin.
[Test, LongRunning]
/// Commenting for now
//[Test, LongRunning]
public void TestSimpleNotNeighboursTeleport()
{
TestHelper.InMethod();
@ -117,14 +118,15 @@ namespace OpenSim.Region.Framework.Scenes.Tests
// shared module
ISharedRegionModule interregionComms = new RESTInterregionComms();
Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000, cm);
SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms);
sceneA.RegisterRegionWithGrid();
Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, cm);
Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, cm, "grid");
SceneSetupHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms);
sceneB.RegisterRegionWithGrid();
Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000, cm, "grid");
SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms);
sceneA.RegisterRegionWithGrid();
UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000041");
TestClient client = SceneSetupHelpers.AddRootAgent(sceneA, agentId);

View File

@ -38,7 +38,7 @@ namespace OpenSim.Region.Framework.Scenes.Types
{
private Queue<SceneObjectPart> m_queue;
private List<UUID> m_ids;
private Dictionary<UUID, bool> m_ids;
private object m_syncObject = new object();
@ -50,7 +50,7 @@ namespace OpenSim.Region.Framework.Scenes.Types
public UpdateQueue()
{
m_queue = new Queue<SceneObjectPart>();
m_ids = new List<UUID>();
m_ids = new Dictionary<UUID, bool>();
}
public void Clear()
@ -66,9 +66,8 @@ namespace OpenSim.Region.Framework.Scenes.Types
{
lock (m_syncObject)
{
if (!m_ids.Contains(part.UUID))
{
m_ids.Add(part.UUID);
if (!m_ids.ContainsKey(part.UUID)) {
m_ids.Add(part.UUID, true);
m_queue.Enqueue(part);
}
}

View File

@ -3531,12 +3531,8 @@ namespace OpenSim.Region.Physics.OdePlugin
}
d.GeomDestroy(g);
removingHeightField = new float[0];
//removingHeightField = new float[0];
}
}
}
@ -3545,13 +3541,9 @@ namespace OpenSim.Region.Physics.OdePlugin
m_log.Warn("[PHYSICS]: Couldn't proceed with UnCombine. Region has inconsistant data.");
}
}
}
}
}
public override void SetWaterLevel(float baseheight)
{

View File

@ -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;
@ -2010,10 +2013,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
q = avatar.Rotation; // Currently infrequently updated so may be inaccurate
}
else
q = part.ParentGroup.GroupRotation; // Likely never get here but just in case
q = part.ParentGroup.Rotation; // Likely never get here but just in case
}
else
q = part.ParentGroup.GroupRotation; // just the group rotation
q = part.ParentGroup.Rotation; // just the group rotation
return new LSL_Rotation(q.X, q.Y, q.Z, q.W);
}
q = part.GetWorldRotation();
@ -5002,6 +5005,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (end > src.Length)
end = src.Length;
if (stride == 0)
stride = 1;
// There may be one or two ranges to be considered
if (start != end)
@ -5028,9 +5034,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// A negative stride reverses the direction of the
// scan producing an inverted list as a result.
if (stride == 0)
stride = 1;
if (stride > 0)
{
for (int i = 0; i < src.Length; i += stride)
@ -5053,9 +5056,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
else
{
if (start%stride == 0)
{
result.Add(src.Data[start]);
}
}
return result;
}
@ -5232,12 +5238,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
List<SimpleRegionInfo> neighbors = World.CommsManager.GridService.RequestNeighbours(World.RegionInfo.RegionLocX, World.RegionInfo.RegionLocY);
List<GridRegion> neighbors = World.GridService.GetNeighbours(World.RegionInfo.ScopeID, World.RegionInfo.RegionID);
uint neighborX = World.RegionInfo.RegionLocX + (uint)dir.x;
uint 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;
@ -7178,10 +7184,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
else
q = avatar.Rotation; // Currently infrequently updated so may be inaccurate
else
q = m_host.ParentGroup.GroupRotation; // Likely never get here but just in case
q = m_host.ParentGroup.Rotation; // Likely never get here but just in case
}
else
q = m_host.ParentGroup.GroupRotation; // just the group rotation
q = m_host.ParentGroup.Rotation; // just the group rotation
return new LSL_Rotation(q.X, q.Y, q.Z, q.W);
}
@ -8184,7 +8190,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)
{
@ -8211,7 +8217,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)

View File

@ -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,8 +601,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (regionName.Contains(".") && regionName.Contains(":"))
{
// Try to link the region
RegionInfo regInfo = HGHyperlink.TryLinkRegion(World,
presence.ControllingClient,
IHyperlinkService hyperService = World.RequestModuleInterface<IHyperlinkService>();
if (hyperService != null)
{
GridRegion regInfo = hyperService.TryLinkRegion(presence.ControllingClient,
regionName);
// Get the region name
if (regInfo != null)
@ -612,6 +616,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// Might need to ping the client here in case of failure??
}
}
}
presence.ControllingClient.SendTeleportLocationStart();
World.RequestTeleportLocation(presence.ControllingClient, regionName,
new Vector3((float)position.x, (float)position.y, (float)position.z),

View File

@ -573,8 +573,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
{
complete = true;
}
}
while(!complete);
} while (!complete);
break;
case enumCompileType.js:
results = JScodeProvider.CompileAssemblyFromSource(
@ -602,12 +601,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
{
foreach (CompilerError CompErr in results.Errors)
{
string severity = "Error";
if (CompErr.IsWarning)
{
severity = "Warning";
}
string severity = CompErr.IsWarning ? "Warning" : "Error";
KeyValuePair<int, int> lslPos;

View File

@ -218,16 +218,14 @@ namespace OpenSim.Region.ScriptEngine.Shared
}
}
Position = new LSL_Types.Vector3(part.AbsolutePosition.X,
part.AbsolutePosition.Y,
part.AbsolutePosition.Z);
Vector3 absPos = part.AbsolutePosition;
Position = new LSL_Types.Vector3(absPos.X, absPos.Y, absPos.Z);
Quaternion wr = part.ParentGroup.GroupRotation;
Quaternion wr = part.ParentGroup.Rotation;
Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W);
Velocity = new LSL_Types.Vector3(part.Velocity.X,
part.Velocity.Y,
part.Velocity.Z);
Vector3 vel = part.Velocity;
Velocity = new LSL_Types.Vector3(vel.X, vel.Y, vel.Z);
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
@ -24,3 +24,33 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace OpenSim.Server.Base
{
public class ProtocolVersions
{
/// <value>
/// This is the external protocol versions. It is separate from the OpenSimulator project version.
///
/// These version numbers should be increased by 1 every time a code
/// change in the Service.Connectors and Server.Handlers, espectively,
/// makes the previous OpenSimulator revision incompatible
/// with the new revision.
///
/// Changes which are compatible with an older revision (e.g. older revisions experience degraded functionality
/// but not outright failure) do not need a version number increment.
///
/// Having this version number allows the grid service to reject connections from regions running a version
/// of the code that is too old.
///
/// </value>
// The range of acceptable servers for client-side connectors
public readonly static int ClientProtocolVersionMin = 0;
public readonly static int ClientProtocolVersionMax = 0;
// The range of acceptable clients in server-side handlers
public readonly static int ServerProtocolVersionMin = 0;
public readonly static int ServerProtocolVersionMax = 0;
}
}

View File

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

View File

@ -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<SimpleRegionInfo> m_RegionsOnSim = new List<SimpleRegionInfo>();
private List<GridRegion> m_RegionsOnSim = new List<GridRegion>();
private IHyperlinkService m_HyperlinkService;
public HypergridServiceInConnector(IConfigSource config, IHttpServer server) :
public HypergridServiceInConnector(IConfigSource config, IHttpServer server, IHyperlinkService hyperService) :
base(config, server, String.Empty)
{
server.AddXmlRPCHandler("linkk_region", LinkRegionRequest, false);
m_HyperlinkService = hyperService;
server.AddXmlRPCHandler("link_region", LinkRegionRequest, false);
server.AddXmlRPCHandler("expect_hg_user", ExpectHGUser, false);
}
public void AddRegion(GridRegion rinfo)
{
m_RegionsOnSim.Add(rinfo);
}
public void RemoveRegion(GridRegion rinfo)
{
if (m_RegionsOnSim.Contains(rinfo))
m_RegionsOnSim.Remove(rinfo);
}
/// <summary>
@ -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)
/// <summary>
/// Received from other HGrid nodes when a user wants to teleport here. This call allows
/// the region to prepare for direct communication from the client. Sends back an empty
/// xmlrpc response on completion.
/// This is somewhat similar to OGS1's ExpectUser, but with the additional task of
/// registering the user in the local user cache.
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse ExpectHGUser(XmlRpcRequest request, IPEndPoint remoteClient)
{
m_RegionsOnSim.Add(rinfo);
Hashtable requestData = (Hashtable)request.Params[0];
ForeignUserProfileData userData = new ForeignUserProfileData();
userData.FirstName = (string)requestData["firstname"];
userData.SurName = (string)requestData["lastname"];
userData.ID = new UUID((string)requestData["agent_id"]);
UUID sessionID = new UUID((string)requestData["session_id"]);
userData.HomeLocation = new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]),
(float)Convert.ToDecimal((string)requestData["startpos_y"]),
(float)Convert.ToDecimal((string)requestData["startpos_z"]));
userData.UserServerURI = (string)requestData["userserver_id"];
userData.UserAssetURI = (string)requestData["assetserver_id"];
userData.UserInventoryURI = (string)requestData["inventoryserver_id"];
m_log.DebugFormat("[HGrid]: Prepare for connection from {0} {1} (@{2}) UUID={3}",
userData.FirstName, userData.SurName, userData.UserServerURI, userData.ID);
ulong userRegionHandle = 0;
int userhomeinternalport = 0;
if (requestData.ContainsKey("region_uuid"))
{
UUID uuid = UUID.Zero;
UUID.TryParse((string)requestData["region_uuid"], out uuid);
userData.HomeRegionID = uuid;
userRegionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
userData.UserHomeAddress = (string)requestData["home_address"];
userData.UserHomePort = (string)requestData["home_port"];
userhomeinternalport = Convert.ToInt32((string)requestData["internal_port"]);
m_log.Debug("[HGrid]: home_address: " + userData.UserHomeAddress +
"; home_port: " + userData.UserHomePort);
}
else
m_log.WarnFormat("[HGrid]: User has no home region information");
XmlRpcResponse resp = new XmlRpcResponse();
// Let's check if someone is trying to get in with a stolen local identity.
// The need for this test is a consequence of not having truly global names :-/
bool comingHome = false;
if (m_HyperlinkService.CheckUserAtEntry(userData.ID, sessionID, out comingHome) == false)
{
m_log.WarnFormat("[HGrid]: Access denied to foreign user.");
Hashtable respdata = new Hashtable();
respdata["success"] = "FALSE";
respdata["reason"] = "Foreign user has the same ID as a local user, or logins disabled.";
resp.Value = respdata;
return resp;
}
public void RemoveRegion(SimpleRegionInfo rinfo)
// Finally, everything looks ok
//m_log.Debug("XXX---- EVERYTHING OK ---XXX");
if (!comingHome)
{
if (m_RegionsOnSim.Contains(rinfo))
m_RegionsOnSim.Remove(rinfo);
}
// 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;
}
}
}

View File

@ -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;

View File

@ -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);

View File

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

View File

@ -38,6 +38,7 @@ using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using 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);

View File

@ -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);

View File

@ -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;
}
/// <value>
/// 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"];
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -1,4 +1,31 @@
using System;
/*
* 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.Text;
using System.Reflection;
@ -28,7 +55,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);

View File

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

View File

@ -44,6 +44,7 @@ using OpenSim.Region.CoreModules.Agent.Capabilities;
using OpenSim.Region.CoreModules.Avatar.Gods;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
using OpenSim.Services.Interfaces;
using OpenSim.Tests.Common.Mock;
@ -58,6 +59,7 @@ namespace OpenSim.Tests.Common.Setup
// CommunicationsManager.
private static ISharedRegionModule m_assetService = null;
private static ISharedRegionModule m_inventoryService = null;
private static ISharedRegionModule m_gridService = null;
private static TestCommunicationsManager commsManager = null;
/// <summary>
@ -110,6 +112,7 @@ namespace OpenSim.Tests.Common.Setup
return SetupScene(name, id, x, y, cm, "");
}
/// <summary>
/// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions
/// or a different, to get a brand new scene with new shared region modules.
@ -176,6 +179,9 @@ namespace OpenSim.Tests.Common.Setup
StartInventoryService(testScene, true);
else
StartInventoryService(testScene, false);
if (realServices.Contains("grid"))
StartGridService(testScene, true);
}
// If not, make sure the shared module gets references to this new scene
else
@ -241,6 +247,29 @@ namespace OpenSim.Tests.Common.Setup
m_inventoryService = inventoryService;
}
private static void StartGridService(Scene testScene, bool real)
{
IConfigSource config = new IniConfigSource();
config.AddConfig("Modules");
config.AddConfig("GridService");
config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData");
if (real)
config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
if (m_gridService == null)
{
ISharedRegionModule gridService = new LocalGridServicesConnector();
gridService.Initialise(config);
m_gridService = gridService;
}
//else
// config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestGridService");
m_gridService.AddRegion(testScene);
m_gridService.RegionLoaded(testScene);
//testScene.AddRegionModule(m_gridService.Name, m_gridService);
}
/// <summary>
/// Setup modules for a scene using their default settings.
/// </summary>

View File

@ -136,11 +136,7 @@ namespace OpenSim.Tools.LSL.Compiler
string errtext = String.Empty;
foreach (CompilerError CompErr in results.Errors)
{
string severity = "Error";
if ( CompErr.IsWarning )
{
severity = "Warning";
}
string severity = CompErr.IsWarning ? "Warning" : "Error";
KeyValuePair<int, int> lslPos;

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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.

View File

@ -7,13 +7,17 @@
[Includes]
Include-Common = "config-include/GridCommon.ini"
[Startup]
hypergrid = true
[Modules]
AssetServices = "HGAssetBroker"
InventoryServices = "HGInventoryBroker"
NeighbourServices = "RemoteNeighbourServicesConnector"
GridServices = "HGGridServicesConnector"
NeighbourServiceInConnector = true
LandServiceInConnector = true
HypergridServiceInConnector = true
[AssetService]
LocalGridAssetService = "OpenSim.Services.Connectors.dll:AssetServicesConnector"
@ -22,3 +26,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"

View File

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

View File

@ -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=***;"

View File

@ -7,16 +7,21 @@
[Includes]
Include-Common = "config-include/StandaloneCommon.ini"
[Startup]
hypergrid = true
[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 +47,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"
; LocalGridServicesConnector needs this
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
Realm = "regions"

View File

@ -170,7 +170,9 @@
<Reference name="OpenSim.Framework"/>
<Files>
<Match pattern="*.cs" recurse="true"/>
<Match pattern="*.cs" recurse="true">
<Exclude name="Tests" pattern="Tests"/>
</Match>
</Files>
</Project>
@ -955,86 +957,6 @@
</Project>
<Project frameworkVersion="v3_5" name="OpenSim.Grid.UserServer.Modules" path="OpenSim/Grid/UserServer.Modules" type="Library">
<Configuration name="Debug">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="System.Data"/>
<Reference name="System.Xml"/>
<Reference name="System.Web"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Data"/>
<Reference name="OpenSim.Framework.Capabilities"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Framework.Statistics"/>
<Reference name="OpenSim.Grid.Framework"/>
<Reference name="OpenSim.Grid.Communications.OGS1"/>
<Reference name="OpenMetaverse.dll"/>
<Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenMetaverse.StructuredData.dll"/>
<Reference name="XMLRPC.dll"/>
<Reference name="log4net.dll"/>
<Reference name="DotNetOpenId.dll"/>
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
</Project>
<Project frameworkVersion="v3_5" name="OpenSim.Grid.UserServer" path="OpenSim/Grid/UserServer" type="Exe">
<Configuration name="Debug">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="System.Data"/>
<Reference name="System.Xml"/>
<Reference name="System.Web"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Data"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Framework.Statistics"/>
<Reference name="OpenSim.Grid.Communications.OGS1"/>
<Reference name="OpenSim.Grid.Framework"/>
<Reference name="OpenSim.Grid.UserServer.Modules"/>
<Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenMetaverse.StructuredData.dll"/>
<Reference name="OpenMetaverse.dll"/>
<Reference name="XMLRPC.dll"/>
<Reference name="log4net.dll"/>
<Reference name="Nini.dll"/>
<Reference name="DotNetOpenId.dll"/>
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
</Project>
<Project frameworkVersion="v3_5" name="OpenSim.Grid.MessagingServer.Modules" path="OpenSim/Grid/MessagingServer.Modules" type="Library">
<Configuration name="Debug">
<Options>
@ -1225,6 +1147,89 @@
</Project>
<Project frameworkVersion="v3_5" name="OpenSim.Grid.UserServer.Modules" path="OpenSim/Grid/UserServer.Modules" type="Library">
<Configuration name="Debug">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="System.Data"/>
<Reference name="System.Xml"/>
<Reference name="System.Web"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Data"/>
<Reference name="OpenSim.Framework.Capabilities"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Framework.Statistics"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="OpenSim.Services.Connectors"/>
<Reference name="OpenSim.Grid.Framework"/>
<Reference name="OpenSim.Grid.Communications.OGS1"/>
<Reference name="OpenMetaverse.dll"/>
<Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenMetaverse.StructuredData.dll"/>
<Reference name="XMLRPC.dll"/>
<Reference name="log4net.dll"/>
<Reference name="DotNetOpenId.dll"/>
<Reference name="Nini.dll"/>
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
</Project>
<Project frameworkVersion="v3_5" name="OpenSim.Grid.UserServer" path="OpenSim/Grid/UserServer" type="Exe">
<Configuration name="Debug">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="System.Data"/>
<Reference name="System.Xml"/>
<Reference name="System.Web"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Data"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Framework.Statistics"/>
<Reference name="OpenSim.Grid.Communications.OGS1"/>
<Reference name="OpenSim.Grid.Framework"/>
<Reference name="OpenSim.Grid.UserServer.Modules"/>
<Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenMetaverse.StructuredData.dll"/>
<Reference name="OpenMetaverse.dll"/>
<Reference name="XMLRPC.dll"/>
<Reference name="log4net.dll"/>
<Reference name="Nini.dll"/>
<Reference name="DotNetOpenId.dll"/>
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
</Project>
<Project frameworkVersion="v3_5" name="OpenSim.Services.AssetService" path="OpenSim/Services/AssetService" type="Library">
<Configuration name="Debug">
<Options>
@ -3467,6 +3472,38 @@
</Files>
</Project>
<Project frameworkVersion="v3_5" name="OpenSim.Framework.Serialization.Tests" path="OpenSim/Framework/Serialization/Tests" type="Library">
<Configuration name="Debug">
<Options>
<OutputPath>../../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="OpenMetaverse.dll"/>
<Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenMetaverse.StructuredData.dll"/>
<Reference name="OpenSim.Data"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="OpenSim.Tests.Common"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Serialization"/>
<Reference name="OpenSim.Framework.Serialization.External"/>
<Reference name="log4net.dll"/>
<Reference name="nunit.framework.dll" />
<Files>
<Match pattern="*.cs" recurse="true">
</Match>
</Files>
</Project>
<Project frameworkVersion="v3_5" name="OpenSim.Framework.Servers.Tests" path="OpenSim/Framework/Servers/Tests" type="Library">
<Configuration name="Debug">
<Options>
@ -3655,6 +3692,7 @@
<Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.CoreModules"/>
<Reference name="OpenSim.Region.Physics.Manager"/>
<Reference name="OpenSim.Services.Interfaces"/>
<!-- Unit tests -->
<!-- <Reference name="OpenSim.Tests.Common"/> -->
@ -3708,6 +3746,7 @@
<Reference name="OpenSim.Region.ClientStack"/>
<Reference name="OpenSim.Region.ClientStack.LindenUDP"/>
<Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="OpenSim.Tests.Common"/>
<Files>