* Now the OGS1GridServices has a LocalBackEndServices that it forwards intra-instance requests to

* Every Scene has a ClientManager (as every dog it's day) since two scenes can have the same circuit as client.
afrisby
lbsa71 2007-09-25 06:33:18 +00:00
parent 2219ccc5b0
commit eb8640f368
9 changed files with 135 additions and 111 deletions

View File

@ -34,6 +34,6 @@ namespace OpenSim.Framework.Communications
{
bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData);
bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying);
bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentID);
bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId);
}
}

View File

@ -100,5 +100,10 @@ namespace OpenSim.Framework
}
}
}
public bool TryGetClient(uint circuitId, out IClientAPI user)
{
return m_clients.TryGetValue(circuitId, out user);
}
}
}

View File

@ -116,7 +116,6 @@ namespace OpenSim.Framework.Configuration
configurationPlugin.LoadData();
useFile = true;
}
else
{
MainLog.Instance.Notice("XML Configuration Filename is not valid; will not save to the file.");

View File

@ -38,5 +38,10 @@ namespace OpenSim.Framework.Interfaces
RegionInfo RegionInfo { get; }
object SyncRoot { get; }
uint NextLocalId { get; }
ClientManager ClientManager
{
get;
}
}
}

View File

@ -40,12 +40,13 @@ namespace OpenSim.Region.ClientStack
public class PacketServer
{
private ClientStackNetworkHandler m_networkHandler;
private IScene _localScene;
private readonly ClientManager m_clientManager = new ClientManager();
public ClientManager ClientManager
{
get { return m_clientManager; }
}
private IScene m_scene;
//private readonly ClientManager m_clientManager = new ClientManager();
//public ClientManager ClientManager
//{
// get { return m_clientManager; }
//}
public PacketServer(ClientStackNetworkHandler networkHandler)
{
@ -57,7 +58,7 @@ namespace OpenSim.Region.ClientStack
{
set
{
this._localScene = value;
this.m_scene = value;
}
}
@ -68,7 +69,7 @@ namespace OpenSim.Region.ClientStack
/// <param name="packet"></param>
public virtual void InPacket(uint circuitCode, Packet packet)
{
m_clientManager.InPacket(circuitCode, packet);
m_scene.ClientManager.InPacket(circuitCode, packet);
}
protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions)
@ -76,28 +77,27 @@ namespace OpenSim.Region.ClientStack
return new ClientView(remoteEP, initialcirpack, clientManager, scene, assetCache, packServer, authenSessions );
}
/// <summary>
///
/// </summary>
/// <param name="epSender"></param>
/// <param name="useCircuit"></param>
/// <param name="assetCache"></param>
/// <param name="inventoryCache"></param>
/// <param name="authenticateSessionsClass"></param>
/// <returns></returns>
public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, AgentCircuitManager authenticateSessionsClass)
{
IClientAPI newuser =
CreateNewClient(epSender, useCircuit, m_clientManager, _localScene, assetCache, this,
authenticateSessionsClass);
IClientAPI newuser;
this.m_clientManager.Add(useCircuit.CircuitCode.Code, newuser);
if (m_scene.ClientManager.TryGetClient(useCircuit.CircuitCode.Code, out newuser))
{
return false;
}
else
{
newuser = CreateNewClient(epSender, useCircuit, m_scene.ClientManager, m_scene, assetCache, this,
authenticateSessionsClass);
newuser.OnViewerEffect += m_clientManager.ViewerEffectHandler;
newuser.OnLogout += LogoutHandler;
newuser.OnConnectionClosed += CloseClient;
m_scene.ClientManager.Add(useCircuit.CircuitCode.Code, newuser);
return true;
newuser.OnViewerEffect += m_scene.ClientManager.ViewerEffectHandler;
newuser.OnLogout += LogoutHandler;
newuser.OnConnectionClosed += CloseClient;
return true;
}
}
public void LogoutHandler(IClientAPI client)
@ -127,7 +127,7 @@ namespace OpenSim.Region.ClientStack
public virtual void CloseCircuit(uint circuitcode)
{
m_networkHandler.RemoveClientCircuit( circuitcode );
m_clientManager.CloseAllAgents( circuitcode );
m_scene.ClientManager.CloseAllAgents(circuitcode);
}
public virtual void CloseClient( IClientAPI client )

View File

@ -30,14 +30,15 @@ using libsecondlife;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Types;
using System.Collections;
namespace OpenSim.Region.Communications.Local
{
public class LocalBackEndServices : IGridServices, IInterRegionCommunications
{
protected Dictionary<ulong, RegionInfo> regions = new Dictionary<ulong, RegionInfo>();
protected Dictionary<ulong, RegionCommsListener> regionHosts = new Dictionary<ulong, RegionCommsListener>();
protected Dictionary<ulong, RegionInfo> m_regions = new Dictionary<ulong, RegionInfo>();
protected Dictionary<ulong, RegionCommsListener> m_regionListeners = new Dictionary<ulong, RegionCommsListener>();
public LocalBackEndServices()
{
@ -52,12 +53,13 @@ namespace OpenSim.Region.Communications.Local
public RegionCommsListener RegisterRegion(RegionInfo regionInfo)
{
//Console.WriteLine("CommsManager - Region " + regionInfo.RegionHandle + " , " + regionInfo.RegionLocX + " , "+ regionInfo.RegionLocY +" is registering");
if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle))
if (!this.m_regions.ContainsKey((uint)regionInfo.RegionHandle))
{
//Console.WriteLine("CommsManager - Adding Region " + regionInfo.RegionHandle );
this.regions.Add(regionInfo.RegionHandle, regionInfo);
this.m_regions.Add(regionInfo.RegionHandle, regionInfo);
RegionCommsListener regionHost = new RegionCommsListener();
this.regionHosts.Add(regionInfo.RegionHandle, regionHost);
this.m_regionListeners.Add(regionInfo.RegionHandle, regionHost);
return regionHost;
}
@ -75,7 +77,7 @@ namespace OpenSim.Region.Communications.Local
// Console.WriteLine("Finding Neighbours to " + regionInfo.RegionHandle);
List<RegionInfo> neighbours = new List<RegionInfo>();
foreach (RegionInfo reg in this.regions.Values)
foreach (RegionInfo reg in this.m_regions.Values)
{
// Console.WriteLine("CommsManager- RequestNeighbours() checking region " + reg.RegionLocX + " , "+ reg.RegionLocY);
if (reg.RegionHandle != regionInfo.RegionHandle)
@ -100,9 +102,9 @@ namespace OpenSim.Region.Communications.Local
/// <returns></returns>
public RegionInfo RequestNeighbourInfo(ulong regionHandle)
{
if (this.regions.ContainsKey(regionHandle))
if (this.m_regions.ContainsKey(regionHandle))
{
return this.regions[regionHandle];
return this.m_regions[regionHandle];
}
return null;
}
@ -118,7 +120,7 @@ namespace OpenSim.Region.Communications.Local
public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
{
List<MapBlockData> mapBlocks = new List<MapBlockData>();
foreach(RegionInfo regInfo in this.regions.Values)
foreach(RegionInfo regInfo in this.m_regions.Values)
{
if (((regInfo.RegionLocX >= minX) && (regInfo.RegionLocX <= maxX)) && ((regInfo.RegionLocY >= minY) && (regInfo.RegionLocY <= maxY)))
{
@ -145,10 +147,10 @@ namespace OpenSim.Region.Communications.Local
public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) //should change from agentCircuitData
{
//Console.WriteLine("CommsManager- Trying to Inform a region to expect child agent");
if (this.regionHosts.ContainsKey(regionHandle))
if (this.m_regionListeners.ContainsKey(regionHandle))
{
// Console.WriteLine("CommsManager- Informing a region to expect child agent");
this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agentData);
this.m_regionListeners[regionHandle].TriggerExpectUser(regionHandle, agentData);
return true;
}
return false;
@ -163,18 +165,18 @@ namespace OpenSim.Region.Communications.Local
/// <returns></returns>
public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying)
{
if (this.regionHosts.ContainsKey(regionHandle))
if (this.m_regionListeners.ContainsKey(regionHandle))
{
// Console.WriteLine("CommsManager- Informing a region to expect avatar crossing");
this.regionHosts[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying);
this.m_regionListeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying);
return true;
}
return false;
}
public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentID)
public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId)
{
if (this.regionHosts.ContainsKey(regionHandle))
if (this.m_regionListeners.ContainsKey(regionHandle))
{
return true;
}
@ -201,11 +203,54 @@ namespace OpenSim.Region.Communications.Local
agent.startpos = new LLVector3(128, 128, 70);
agent.CapsPath = loginData.CapsPath;
if (this.regionHosts.ContainsKey(regionHandle))
TriggerExpectUser(regionHandle, agent);
}
public void TriggerExpectUser(ulong regionHandle, AgentCircuitData agent)
{
if (this.m_regionListeners.ContainsKey(regionHandle))
{
this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agent);
this.m_regionListeners[regionHandle].TriggerExpectUser(regionHandle, agent);
}
}
public void PingCheckReply(Hashtable respData)
{
foreach (ulong region in this.m_regions.Keys )
{
Hashtable regData = new Hashtable();
RegionInfo reg = m_regions[region];
regData["status"] = "active";
regData["handle"] = region.ToString();
respData[reg.SimUUID.ToStringHyphenated()] = regData;
}
}
public bool TriggerExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying)
{
if ( m_regionListeners.ContainsKey(regionHandle))
{
return m_regionListeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position,
isFlying);
}
return false;
}
public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData)
{
if (m_regionListeners.ContainsKey(regionHandle))
{
TriggerExpectUser(regionHandle, agentData);
return true;
}
return false;
}
}
}

View File

@ -12,13 +12,13 @@ using OpenSim.Framework.Communications;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Types;
using OpenSim.Region.Communications.Local;
namespace OpenSim.Region.Communications.OGS1
{
public class OGS1GridServices : IGridServices, IInterRegionCommunications
{
public Dictionary<ulong, RegionCommsListener> listeners = new Dictionary<ulong, RegionCommsListener>();
protected Dictionary<ulong, RegionInfo> regions = new Dictionary<ulong, RegionInfo>();
private LocalBackEndServices m_localBackend = new LocalBackEndServices();
public BaseHttpServer httpListener;
public NetworkServersInfo serversInfo;
@ -35,6 +35,7 @@ namespace OpenSim.Region.Communications.OGS1
httpServer = httpServe;
httpServer.AddXmlRPCHandler("expect_user", this.ExpectUser);
httpServer.AddXmlRPCHandler("check", this.PingCheckReply);
this.StartRemoting();
}
@ -45,11 +46,6 @@ namespace OpenSim.Region.Communications.OGS1
/// <returns></returns>
public RegionCommsListener RegisterRegion(RegionInfo regionInfo)
{
if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle))
{
this.regions.Add(regionInfo.RegionHandle, regionInfo);
}
Hashtable GridParams = new Hashtable();
// Login / Authentication
@ -83,18 +79,7 @@ namespace OpenSim.Region.Communications.OGS1
return null;
}
// Initialise the background listeners
RegionCommsListener regListener = new RegionCommsListener();
if (!this.listeners.ContainsKey(regionInfo.RegionHandle))
{
this.listeners.Add(regionInfo.RegionHandle, regListener);
}
else
{
listeners[regionInfo.RegionHandle] = regListener;
}
return regListener;
return m_localBackend.RegisterRegion(regionInfo);
}
/// <summary>
@ -133,7 +118,7 @@ namespace OpenSim.Region.Communications.OGS1
neighbour.RegionName = (string)neighbourData["name"];
//OGS1+
neighbour.SimUUID = new LLUUID((string) neighbourData["uuid"]);
neighbour.SimUUID = new LLUUID((string)neighbourData["uuid"]);
neighbours.Add(neighbour);
}
@ -150,9 +135,11 @@ namespace OpenSim.Region.Communications.OGS1
/// <returns></returns>
public RegionInfo RequestNeighbourInfo(ulong regionHandle)
{
if (this.regions.ContainsKey(regionHandle))
RegionInfo regionInfo = m_localBackend.RequestNeighbourInfo(regionHandle);
if (regionInfo != null)
{
return this.regions[regionHandle];
return regionInfo;
}
Hashtable requestData = new Hashtable();
@ -179,7 +166,7 @@ namespace OpenSim.Region.Communications.OGS1
IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port);
string neighbourExternalUri = externalUri;
RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr);
regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr);
regionInfo.RemotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
regionInfo.RemotingAddress = internalIpStr;
@ -245,7 +232,7 @@ namespace OpenSim.Region.Communications.OGS1
IList parameters = new ArrayList();
parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest("map_block", parameters);
XmlRpcResponse resp = req.Send(serversInfo.GridURL, 3000);
XmlRpcResponse resp = req.Send(serversInfo.GridURL, 10000);
Hashtable respData = (Hashtable)resp.Value;
return respData;
}
@ -262,15 +249,7 @@ namespace OpenSim.Region.Communications.OGS1
Hashtable respData = new Hashtable();
respData["online"] = "true";
foreach (ulong region in this.listeners.Keys)
{
Hashtable regData = new Hashtable();
RegionInfo reg = regions[region];
regData["status"] = "active";
regData["handle"] = region.ToString();
respData[reg.SimUUID.ToStringHyphenated()] = regData;
}
m_localBackend.PingCheckReply(respData);
response.Value = respData;
@ -308,14 +287,9 @@ namespace OpenSim.Region.Communications.OGS1
}
if (listeners.ContainsKey(Convert.ToUInt64((string)requestData["regionhandle"])))
{
this.listeners[Convert.ToUInt64((string)requestData["regionhandle"])].TriggerExpectUser(Convert.ToUInt64((string)requestData["regionhandle"]), agentData);
}
else
{
MainLog.Instance.Error("ExpectUser() - Unknown region " + (Convert.ToUInt64(requestData["regionhandle"])).ToString());
}
ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
m_localBackend.TriggerExpectUser(regionHandle, agentData);
MainLog.Instance.Verbose("ExpectUser() - Welcoming new user...");
@ -333,7 +307,7 @@ namespace OpenSim.Region.Communications.OGS1
WellKnownServiceTypeEntry wellType = new WellKnownServiceTypeEntry(typeof(OGS1InterRegionRemoting), "InterRegions", WellKnownObjectMode.Singleton);
RemotingConfiguration.RegisterWellKnownServiceType(wellType);
InterRegionSingleton.Instance.OnArrival += this.IncomingArrival;
InterRegionSingleton.Instance.OnArrival += this.TriggerExpectAvatarCrossing;
InterRegionSingleton.Instance.OnChildAgent += this.IncomingChildAgent;
}
@ -348,11 +322,11 @@ namespace OpenSim.Region.Communications.OGS1
{
try
{
if (this.listeners.ContainsKey(regionHandle))
if (m_localBackend.InformRegionOfChildAgent(regionHandle, agentData))
{
this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData);
return true;
}
RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle);
if (regInfo != null)
{
@ -401,11 +375,11 @@ namespace OpenSim.Region.Communications.OGS1
{
try
{
if (this.listeners.ContainsKey(regionHandle))
if (m_localBackend.TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying))
{
this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying);
return true;
}
RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle);
if (regInfo != null)
{
@ -440,14 +414,11 @@ namespace OpenSim.Region.Communications.OGS1
}
}
public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentID)
public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId)
{
if (this.listeners.ContainsKey(regionHandle))
{
return true;
}
return false;
return m_localBackend.AcknowledgeAgentCrossed(regionHandle, agentId);
}
#endregion
#region Methods triggered by calls from external instances
@ -461,17 +432,13 @@ namespace OpenSim.Region.Communications.OGS1
{
try
{
if (this.listeners.ContainsKey(regionHandle))
{
this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData);
return true;
}
return m_localBackend.IncomingChildAgent(regionHandle, agentData);
}
catch (System.Runtime.Remoting.RemotingException e)
{
MainLog.Instance.Error("Remoting Error: Unable to connect to remote region.\n" + e.ToString());
return false;
}
return false;
}
/// <summary>
@ -481,21 +448,18 @@ namespace OpenSim.Region.Communications.OGS1
/// <param name="agentID"></param>
/// <param name="position"></param>
/// <returns></returns>
public bool IncomingArrival(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying)
public bool TriggerExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying)
{
try
{
if (this.listeners.ContainsKey(regionHandle))
{
this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying);
return true;
}
return m_localBackend.TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying);
}
catch (System.Runtime.Remoting.RemotingException e)
{
MainLog.Instance.Error("Remoting Error: Unable to connect to remote region.\n" + e.ToString());
return false;
}
return false;
}
#endregion
#endregion

View File

@ -54,7 +54,6 @@ namespace OpenSim.Region.Environment.Scenes
{
public partial class Scene : SceneBase
{
public delegate bool FilterAvatarList(ScenePresence avatar);
protected Timer m_heartbeatTimer = new Timer();

View File

@ -33,11 +33,18 @@ using OpenSim.Framework.Console;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Types;
using OpenSim.Region.Terrain;
using OpenSim.Framework;
namespace OpenSim.Region.Environment.Scenes
{
public abstract class SceneBase : IScene
{
private readonly ClientManager m_clientManager = new ClientManager();
public ClientManager ClientManager
{
get { return m_clientManager; }
}
public Dictionary<LLUUID, EntityBase> Entities;
protected ulong m_regionHandle;
protected string m_regionName;