Implementing a test Communications manager to test some of the interfaces (likely this test version will morph into the sandbox version)

merge
MW 2007-05-31 15:31:31 +00:00
parent a575bc38d6
commit 564a97b508
9 changed files with 60 additions and 19 deletions

View File

@ -11,8 +11,8 @@ namespace OpenGrid.Framework.Communications
{ {
public class TestLocalCommsManager : RegionServerCommsManager public class TestLocalCommsManager : RegionServerCommsManager
{ {
protected Dictionary<uint , RegionInfo> regions = new Dictionary<uint,RegionInfo>(); protected Dictionary<ulong, RegionInfo> regions = new Dictionary<ulong,RegionInfo>();
protected Dictionary<uint, RegionCommsHostBase> regionHosts = new Dictionary<uint, RegionCommsHostBase>(); protected Dictionary<ulong, RegionCommsHostBase> regionHosts = new Dictionary<ulong, RegionCommsHostBase>();
public TestLocalCommsManager() public TestLocalCommsManager()
{ {
@ -28,9 +28,9 @@ namespace OpenGrid.Framework.Communications
{ {
if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle)) if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle))
{ {
this.regions.Add((uint)regionInfo.RegionHandle, regionInfo); this.regions.Add(regionInfo.RegionHandle, regionInfo);
RegionCommsHostBase regionHost = new RegionCommsHostBase(); RegionCommsHostBase regionHost = new RegionCommsHostBase();
this.regionHosts.Add((uint)regionInfo.RegionHandle, regionHost); this.regionHosts.Add(regionInfo.RegionHandle, regionHost);
return regionHost; return regionHost;
} }
@ -59,13 +59,14 @@ namespace OpenGrid.Framework.Communications
} }
/// <summary> /// <summary>
/// /// Is a Sandbox mode method, used by the local Login server to inform a region of a connection user/session
/// </summary> /// </summary>
/// <param name="regionHandle"></param> /// <param name="regionHandle"></param>
/// <param name="loginData"></param> /// <param name="loginData"></param>
/// <returns></returns> /// <returns></returns>
public bool AddNewSession(uint regionHandle, Login loginData) public bool AddNewSession(ulong regionHandle, Login loginData)
{ {
Console.WriteLine(" comms manager been told to expect new user");
AgentCircuitData agent = new AgentCircuitData(); AgentCircuitData agent = new AgentCircuitData();
agent.AgentID = loginData.Agent; agent.AgentID = loginData.Agent;
agent.firstname = loginData.First; agent.firstname = loginData.First;
@ -77,9 +78,9 @@ namespace OpenGrid.Framework.Communications
agent.InventoryFolder = loginData.InventoryFolder; agent.InventoryFolder = loginData.InventoryFolder;
agent.startpos = new LLVector3(128, 128, 70); agent.startpos = new LLVector3(128, 128, 70);
if (this.regionHosts.ContainsKey((uint)regionHandle)) if (this.regionHosts.ContainsKey(regionHandle))
{ {
this.regionHosts[(uint)regionHandle].TriggerExpectUser(agent); this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agent);
return true; return true;
} }

View File

@ -6,7 +6,7 @@ using OpenSim.Framework.Types;
namespace OpenSim.Framework namespace OpenSim.Framework
{ {
public delegate void ExpectUserDelegate(AgentCircuitData agent); public delegate void ExpectUserDelegate(ulong regionHandle, AgentCircuitData agent);
public delegate void UpdateNeighbours(List<RegionInfo> neighbours); public delegate void UpdateNeighbours(List<RegionInfo> neighbours);
public interface IRegionCommsHost public interface IRegionCommsHost

View File

@ -18,11 +18,11 @@ namespace OpenSim.Framework
/// </summary> /// </summary>
/// <param name="agent"></param> /// <param name="agent"></param>
/// <returns></returns> /// <returns></returns>
public virtual bool TriggerExpectUser(AgentCircuitData agent) public virtual bool TriggerExpectUser(ulong regionHandle, AgentCircuitData agent)
{ {
if(OnExpectUser != null) if(OnExpectUser != null)
{ {
OnExpectUser(agent); OnExpectUser(regionHandle, agent);
return true; return true;
} }

View File

@ -116,8 +116,8 @@ namespace OpenSim.UserServer
Console.WriteLine("adding login data to gridserver"); Console.WriteLine("adding login data to gridserver");
((LocalGridBase)this.m_gridServer).AddNewSession(_login); ((LocalGridBase)this.m_gridServer).AddNewSession(_login);
}*/ }*/
ulong reghand = Helpers.UIntsToLong((regionX * 256), (regionY * 256));
this.AddSession(_login); this.AddSession(reghand, _login);
} }
} }
} }

View File

@ -47,7 +47,7 @@ using OpenSim.Framework.Types;
namespace OpenSim.UserServer namespace OpenSim.UserServer
{ {
public delegate void AddNewSessionHandler(Login loginData); public delegate bool AddNewSessionHandler(ulong regionHandle, Login loginData);
/// <summary> /// <summary>
/// When running in local (default) mode , handles client logins. /// When running in local (default) mode , handles client logins.
/// </summary> /// </summary>
@ -196,7 +196,8 @@ namespace OpenSim.UserServer
{ {
((LocalGridBase)m_gridServer).AddNewSession(_login); ((LocalGridBase)m_gridServer).AddNewSession(_login);
}*/ }*/
AddSession(_login); ulong reghand = Helpers.UIntsToLong((regionX * 256), (regionY * 256));
AddSession(reghand,_login);
return response; return response;
} }

View File

@ -87,6 +87,10 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Common\OpenGrid.Framework.Communications\OpenGrid.Framework.Communications.csproj">
<Project>{C9702041-922C-452A-A1B4-7880AF53149A}</Project>
<Name>OpenGrid.Framework.Communications</Name>
</ProjectReference>
<ProjectReference Include="..\OpenSim.Terrain.BasicTerrain\OpenSim.Terrain.BasicTerrain.csproj"> <ProjectReference Include="..\OpenSim.Terrain.BasicTerrain\OpenSim.Terrain.BasicTerrain.csproj">
<Name>OpenSim.Terrain.BasicTerrain</Name> <Name>OpenSim.Terrain.BasicTerrain</Name>
<Project>{2270B8FE-0000-0000-0000-000000000000}</Project> <Project>{2270B8FE-0000-0000-0000-000000000000}</Project>

View File

@ -14,6 +14,7 @@ using OpenSim.Framework.Inventory;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.RegionServer.world.scripting; using OpenSim.RegionServer.world.scripting;
using OpenSim.Terrain; using OpenSim.Terrain;
using OpenGrid.Framework.Communications;
namespace OpenSim.world namespace OpenSim.world
{ {
@ -36,6 +37,8 @@ namespace OpenSim.world
private Mutex updateLock; private Mutex updateLock;
public string m_datastore; public string m_datastore;
protected AuthenticateSessionsBase authenticateHandler; protected AuthenticateSessionsBase authenticateHandler;
protected RegionCommsHostBase regionCommsHost;
protected RegionServerCommsManager commsManager;
#region Properties #region Properties
/// <summary> /// <summary>
@ -61,17 +64,19 @@ namespace OpenSim.world
/// <param name="clientThreads">Dictionary to contain client threads</param> /// <param name="clientThreads">Dictionary to contain client threads</param>
/// <param name="regionHandle">Region Handle for this region</param> /// <param name="regionHandle">Region Handle for this region</param>
/// <param name="regionName">Region Name for this region</param> /// <param name="regionName">Region Name for this region</param>
public World(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regInfo, AuthenticateSessionsBase authen) public World(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regInfo, AuthenticateSessionsBase authen, RegionServerCommsManager commsMan)
{ {
try try
{ {
updateLock = new Mutex(false); updateLock = new Mutex(false);
this.authenticateHandler = authen; this.authenticateHandler = authen;
this.commsManager = commsMan;
m_clientThreads = clientThreads; m_clientThreads = clientThreads;
m_regInfo = regInfo; m_regInfo = regInfo;
m_regionHandle = m_regInfo.RegionHandle; m_regionHandle = m_regInfo.RegionHandle;
m_regionName = m_regInfo.RegionName; m_regionName = m_regInfo.RegionName;
this.m_datastore = m_regInfo.DataStore; this.m_datastore = m_regInfo.DataStore;
this.RegisterRegionWithComms();
m_scriptHandlers = new Dictionary<LLUUID, ScriptHandler>(); m_scriptHandlers = new Dictionary<LLUUID, ScriptHandler>();
m_scripts = new Dictionary<string, ScriptFactory>(); m_scripts = new Dictionary<string, ScriptFactory>();
@ -540,5 +545,27 @@ namespace OpenSim.world
} }
#endregion #endregion
#region RegionCommsHost
public void RegisterRegionWithComms()
{
this.regionCommsHost = this.commsManager.RegisterRegion(this.m_regInfo);
if (this.regionCommsHost != null)
{
this.regionCommsHost.OnExpectUser += new ExpectUserDelegate(this.NewUserConnection);
}
}
public void NewUserConnection(ulong regionHandle,AgentCircuitData agent)
{
Console.WriteLine("World.cs - add new user connection");
//should just check that its meant for this region
if (regionHandle == this.m_regInfo.RegionHandle)
{
this.authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
}
}
#endregion
} }
} }

View File

@ -87,6 +87,10 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Common\OpenGrid.Framework.Communications\OpenGrid.Framework.Communications.csproj">
<Project>{C9702041-922C-452A-A1B4-7880AF53149A}</Project>
<Name>OpenGrid.Framework.Communications</Name>
</ProjectReference>
<ProjectReference Include="..\OpenSim.Terrain.BasicTerrain\OpenSim.Terrain.BasicTerrain.csproj"> <ProjectReference Include="..\OpenSim.Terrain.BasicTerrain\OpenSim.Terrain.BasicTerrain.csproj">
<Name>OpenSim.Terrain.BasicTerrain</Name> <Name>OpenSim.Terrain.BasicTerrain</Name>
<Project>{2270B8FE-0000-0000-0000-000000000000}</Project> <Project>{2270B8FE-0000-0000-0000-000000000000}</Project>

View File

@ -51,6 +51,7 @@ using OpenSim.Physics.Manager;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenSim.Servers; using OpenSim.Servers;
using OpenSim.GenericConfig; using OpenSim.GenericConfig;
using OpenGrid.Framework.Communications;
namespace OpenSim namespace OpenSim
{ {
@ -58,6 +59,7 @@ namespace OpenSim
public class OpenSimMain : RegionServerBase, conscmd_callback public class OpenSimMain : RegionServerBase, conscmd_callback
{ {
private CheckSumServer checkServer; private CheckSumServer checkServer;
protected RegionServerCommsManager commsManager;
public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile) public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile)
{ {
@ -101,10 +103,12 @@ namespace OpenSim
this.SetupLocalGridServers(); this.SetupLocalGridServers();
this.checkServer = new CheckSumServer(12036); this.checkServer = new CheckSumServer(12036);
this.checkServer.ServerListener(); this.checkServer.ServerListener();
this.commsManager = new TestLocalCommsManager();
} }
else else
{ {
this.SetupRemoteGridServers(); this.SetupRemoteGridServers();
this.commsManager = new TestLocalCommsManager(); //should be a remote comms manager class
} }
startuptime = DateTime.Now; startuptime = DateTime.Now;
@ -126,8 +130,8 @@ namespace OpenSim
{ {
loginServer = new LoginServer(regionData[0].IPListenAddr, regionData[0].IPListenPort, regionData[0].RegionLocX, regionData[0].RegionLocY, false); loginServer = new LoginServer(regionData[0].IPListenAddr, regionData[0].IPListenPort, regionData[0].RegionLocX, regionData[0].RegionLocY, false);
loginServer.Startup(); loginServer.Startup();
loginServer.SetSessionHandler(((AuthenticateSessionsLocal)this.AuthenticateSessionsHandler[0]).AddNewSession); //loginServer.SetSessionHandler(((AuthenticateSessionsLocal)this.AuthenticateSessionsHandler[0]).AddNewSession);
loginServer.SetSessionHandler(((TestLocalCommsManager)this.commsManager).AddNewSession);
//sandbox mode with loginserver not using accounts //sandbox mode with loginserver not using accounts
httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod); httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod);
} }
@ -234,7 +238,7 @@ namespace OpenSim
m_console.componentname = "Region " + regionData.RegionName; m_console.componentname = "Region " + regionData.RegionName;
*/ */
LocalWorld = new World(udpServer.PacketServer.ClientAPIs, regionDat, authenBase); LocalWorld = new World(udpServer.PacketServer.ClientAPIs, regionDat, authenBase, commsManager);
this.m_localWorld.Add(LocalWorld); this.m_localWorld.Add(LocalWorld);
//LocalWorld.InventoryCache = InventoryCache; //LocalWorld.InventoryCache = InventoryCache;
//LocalWorld.AssetCache = AssetCache; //LocalWorld.AssetCache = AssetCache;