Removing the ClientManager reference from IScene and hiding it entirely inside Scene as an implementation detail. This will reduce programming error and make it easier to refactor the avatar vs client vs presence mess later on

0.6.8-post-fixes
John Hurliman 2009-10-26 16:48:43 -07:00
parent 4847e62e9f
commit 0b1726b524
5 changed files with 30 additions and 21 deletions

View File

@ -62,7 +62,6 @@ namespace OpenSim.Framework
RegionInfo RegionInfo { get; } RegionInfo RegionInfo { get; }
RegionStatus RegionStatus { get; set; } RegionStatus RegionStatus { get; set; }
ClientManager ClientManager { get; }
IConfigSource Config { get; } IConfigSource Config { get; }
float TimeDilation { get; } float TimeDilation { get; }

View File

@ -970,12 +970,12 @@ namespace OpenSim
m_sceneManager.ForEachScene( m_sceneManager.ForEachScene(
delegate(Scene scene) delegate(Scene scene)
{ {
scene.ClientManager.ForEachSync( scene.ForEachClient(
delegate(IClientAPI client) delegate(IClientAPI client)
{ {
connections.AppendFormat("{0}: {1} ({2}) from {3} on circuit {4}\n", connections.AppendFormat("{0}: {1} ({2}) from {3} on circuit {4}\n",
scene.RegionInfo.RegionName, client.Name, client.AgentId, client.RemoteEndPoint, client.CircuitCode); scene.RegionInfo.RegionName, client.Name, client.AgentId, client.RemoteEndPoint, client.CircuitCode);
} }, false
); );
} }
); );

View File

@ -583,10 +583,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Determine which agent this packet came from // Determine which agent this packet came from
IClientAPI client; IClientAPI client;
if (!m_scene.ClientManager.TryGetValue(address, out client) || !(client is LLClientView)) if (!m_scene.TryGetClient(address, out client) || !(client is LLClientView))
{ {
m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName);
" in " + m_scene.RegionInfo.RegionName + ", currently tracking " + m_scene.ClientManager.Count + " clients");
return; return;
} }
@ -764,8 +763,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
// Create the LLUDPClient // Create the LLUDPClient
LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint); LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint);
IClientAPI existingClient;
if (!m_scene.ClientManager.ContainsKey(agentID)) if (!m_scene.TryGetClient(agentID, out existingClient))
{ {
// Create the LLClientView // Create the LLClientView
LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode); LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
@ -785,7 +785,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
// Remove this client from the scene // Remove this client from the scene
IClientAPI client; IClientAPI client;
if (m_scene.ClientManager.TryGetValue(udpClient.AgentID, out client)) if (m_scene.TryGetClient(udpClient.AgentID, out client))
client.Close(); client.Close();
} }
@ -877,7 +877,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Handle outgoing packets, resends, acknowledgements, and pings for each // Handle outgoing packets, resends, acknowledgements, and pings for each
// client. m_packetSent will be set to true if a packet is sent // client. m_packetSent will be set to true if a packet is sent
m_scene.ClientManager.ForEachSync(clientPacketHandler); m_scene.ForEachClient(clientPacketHandler, false);
// If nothing was sent, sleep for the minimum amount of time before a // If nothing was sent, sleep for the minimum amount of time before a
// token bucket could get more tokens // token bucket could get more tokens
@ -942,7 +942,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
// Make sure this client is still alive // Make sure this client is still alive
if (m_scene.ClientManager.TryGetValue(udpClient.AgentID, out client)) if (m_scene.TryGetClient(udpClient.AgentID, out client))
{ {
try try
{ {

View File

@ -2482,7 +2482,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="client"></param> /// <param name="client"></param>
public override void AddNewClient(IClientAPI client) public override void AddNewClient(IClientAPI client)
{ {
ClientManager.Add(client); m_clientManager.Add(client);
CheckHeartbeat(); CheckHeartbeat();
SubscribeToClientEvents(client); SubscribeToClientEvents(client);
@ -3121,7 +3121,7 @@ namespace OpenSim.Region.Framework.Scenes
// Remove the avatar from the scene // Remove the avatar from the scene
m_sceneGraph.RemoveScenePresence(agentID); m_sceneGraph.RemoveScenePresence(agentID);
ClientManager.Remove(agentID); m_clientManager.Remove(agentID);
try try
{ {
@ -4256,10 +4256,25 @@ namespace OpenSim.Region.Framework.Scenes
public void ForEachClient(Action<IClientAPI> action) public void ForEachClient(Action<IClientAPI> action)
{ {
if (m_useAsyncWhenPossible) ForEachClient(action, m_useAsyncWhenPossible);
ClientManager.ForEach(action); }
public void ForEachClient(Action<IClientAPI> action, bool doAsynchronous)
{
if (doAsynchronous)
m_clientManager.ForEach(action);
else else
ClientManager.ForEachSync(action); m_clientManager.ForEachSync(action);
}
public bool TryGetClient(UUID avatarID, out IClientAPI client)
{
return m_clientManager.TryGetValue(avatarID, out client);
}
public bool TryGetClient(System.Net.IPEndPoint remoteEndPoint, out IClientAPI client)
{
return m_clientManager.TryGetValue(remoteEndPoint, out client);
} }
public void ForEachSOG(Action<SceneObjectGroup> action) public void ForEachSOG(Action<SceneObjectGroup> action)

View File

@ -102,12 +102,7 @@ namespace OpenSim.Region.Framework.Scenes
private readonly Mutex _primAllocateMutex = new Mutex(false); private readonly Mutex _primAllocateMutex = new Mutex(false);
private readonly ClientManager m_clientManager = new ClientManager(); protected readonly ClientManager m_clientManager = new ClientManager();
public ClientManager ClientManager
{
get { return m_clientManager; }
}
public float TimeDilation public float TimeDilation
{ {