29 using System.Collections.Generic;
30 using System.Reflection;
33 using OpenMetaverse.Packets;
35 namespace OpenSim.Framework
45 private Dictionary<UUID, IClientAPI> m_dict1;
48 private Dictionary<IPEndPoint, IClientAPI> m_dict2;
53 private object m_syncRoot =
new object();
56 public int Count {
get {
return m_dict1.Count; } }
63 m_dict1 =
new Dictionary<UUID, IClientAPI>();
64 m_dict2 =
new Dictionary<IPEndPoint, IClientAPI>();
79 if (m_dict1.ContainsKey(value.
AgentId) || m_dict2.ContainsKey(value.RemoteEndPoint))
82 m_dict1[value.AgentId] = value;
83 m_dict2[value.RemoteEndPoint] = value;
86 int oldLength = oldArray.Length;
89 for (
int i = 0; i < oldLength; i++)
90 newArray[i] = oldArray[i];
91 newArray[oldLength] = value;
110 if (m_dict1.TryGetValue(key, out value))
113 m_dict2.Remove(value.RemoteEndPoint);
116 int oldLength = oldArray.Length;
120 for (
int i = 0; i < oldLength; i++)
122 if (oldArray[i] != value)
123 newArray[j++] = oldArray[i];
154 return m_dict1.ContainsKey(
key);
164 return m_dict2.ContainsKey(
key);
175 try {
return m_dict1.TryGetValue(
key, out value); }
191 try {
return m_dict2.TryGetValue(
key, out value); }
204 public void ForEach(Action<IClientAPI> action)
207 Parallel.For(0, localArray.Length,
209 { action(localArray[i]); }
221 for (
int i = 0; i < localArray.Length; i++)
222 action(localArray[i]);
bool ContainsKey(UUID key)
Checks if a UUID is in the collection
bool Add(IClientAPI value)
Add a client reference to the collection if it does not already exist
void ForEach(Action< IClientAPI > action)
Performs a given task in parallel for each of the elements in the collection
bool Remove(UUID key)
Remove a client from the collection
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString key
bool TryGetValue(IPEndPoint key, out IClientAPI value)
Attempts to fetch a value out of the collection
bool ContainsKey(IPEndPoint key)
Checks if an endpoint is in the collection
ClientManager()
Default constructor
Maps from client AgentID and RemoteEndPoint values to IClientAPI references for all of the connected ...
void ForEachSync(Action< IClientAPI > action)
Performs a given task synchronously for each of the elements in the collection
void Clear()
Resets the client collection
bool TryGetValue(UUID key, out IClientAPI value)
Attempts to fetch a value out of the collection