From 395a8680c3633ca131e7481f765517311ef51710 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Tue, 13 Oct 2009 16:53:19 -0700 Subject: * Fixed a bug where clients were being added to ClientManager twice * Changed the ClientManager interface to reduce potential errors with duplicate or mismatched keys * Added IClientAPI.RemoteEndPoint, which can (hopefully) eventually replace IClientAPI.CircuitCode * Changed the order of operations during client shutdown --- OpenSim/Framework/ClientManager.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/ClientManager.cs') diff --git a/OpenSim/Framework/ClientManager.cs b/OpenSim/Framework/ClientManager.cs index 4edfabe..aefe425 100644 --- a/OpenSim/Framework/ClientManager.cs +++ b/OpenSim/Framework/ClientManager.cs @@ -97,19 +97,17 @@ namespace OpenSim.Framework /// Add a client reference to the collection if it does not already /// exist /// - /// UUID of the client - /// Remote endpoint of the client /// Reference to the client object /// True if the client reference was successfully added, /// otherwise false if the given key already existed in the collection - public bool Add(UUID key, IPEndPoint key2, IClientAPI value) + public bool Add(IClientAPI value) { lock (m_writeLock) { - if (!m_dict.ContainsKey(key) && !m_dict2.ContainsKey(key2)) + if (!m_dict.ContainsKey(value.AgentId) && !m_dict2.ContainsKey(value.RemoteEndPoint)) { - m_dict = m_dict.Add(key, value); - m_dict2 = m_dict2.Add(key2, value); + m_dict = m_dict.Add(value.AgentId, value); + m_dict2 = m_dict2.Add(value.RemoteEndPoint, value); return true; } @@ -123,14 +121,16 @@ namespace OpenSim.Framework /// /// Remove a client from the collection /// - /// UUID of the client - /// Remote endpoint of the client - public void Remove(UUID key, IPEndPoint key2) + /// Reference to the client object + public void Remove(IClientAPI value) { lock (m_writeLock) { - m_dict = m_dict.Delete(key); - m_dict2 = m_dict2.Delete(key2); + if (m_dict.ContainsKey(value.AgentId)) + m_dict = m_dict.Delete(value.AgentId); + + if (m_dict2.ContainsKey(value.RemoteEndPoint)) + m_dict2 = m_dict2.Delete(value.RemoteEndPoint); } } -- cgit v1.1