aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/AgentCircuitManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/AgentCircuitManager.cs')
-rw-r--r--OpenSim/Framework/AgentCircuitManager.cs127
1 files changed, 80 insertions, 47 deletions
diff --git a/OpenSim/Framework/AgentCircuitManager.cs b/OpenSim/Framework/AgentCircuitManager.cs
index 1ce8c34..b6e48b4 100644
--- a/OpenSim/Framework/AgentCircuitManager.cs
+++ b/OpenSim/Framework/AgentCircuitManager.cs
@@ -35,22 +35,36 @@ namespace OpenSim.Framework
35 /// </summary> 35 /// </summary>
36 public class AgentCircuitManager 36 public class AgentCircuitManager
37 { 37 {
38 public Dictionary<uint, AgentCircuitData> AgentCircuits = new Dictionary<uint, AgentCircuitData>(); 38 /// <summary>
39 public Dictionary<UUID, AgentCircuitData> AgentCircuitsByUUID = new Dictionary<UUID, AgentCircuitData>(); 39 /// Agent circuits indexed by circuit code.
40 /// </summary>
41 /// <remarks>
42 /// We lock this for operations both on this dictionary and on m_agentCircuitsByUUID
43 /// </remarks>
44 private Dictionary<uint, AgentCircuitData> m_agentCircuits = new Dictionary<uint, AgentCircuitData>();
45
46 /// <summary>
47 /// Agent circuits indexed by agent UUID.
48 /// </summary>
49 private Dictionary<UUID, AgentCircuitData> m_agentCircuitsByUUID = new Dictionary<UUID, AgentCircuitData>();
40 50
41 public virtual AuthenticateResponse AuthenticateSession(UUID sessionID, UUID agentID, uint circuitcode) 51 public virtual AuthenticateResponse AuthenticateSession(UUID sessionID, UUID agentID, uint circuitcode)
42 { 52 {
43 AgentCircuitData validcircuit = null; 53 AgentCircuitData validcircuit = null;
44 if (AgentCircuits.ContainsKey(circuitcode)) 54
55 lock (m_agentCircuits)
45 { 56 {
46 validcircuit = AgentCircuits[circuitcode]; 57 if (m_agentCircuits.ContainsKey(circuitcode))
58 validcircuit = m_agentCircuits[circuitcode];
47 } 59 }
60
48 AuthenticateResponse user = new AuthenticateResponse(); 61 AuthenticateResponse user = new AuthenticateResponse();
62
49 if (validcircuit == null) 63 if (validcircuit == null)
50 { 64 {
51 //don't have this circuit code in our list 65 //don't have this circuit code in our list
52 user.Authorised = false; 66 user.Authorised = false;
53 return (user); 67 return user;
54 } 68 }
55 69
56 if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID)) 70 if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID))
@@ -72,7 +86,7 @@ namespace OpenSim.Framework
72 user.Authorised = false; 86 user.Authorised = false;
73 } 87 }
74 88
75 return (user); 89 return user;
76 } 90 }
77 91
78 /// <summary> 92 /// <summary>
@@ -82,73 +96,93 @@ namespace OpenSim.Framework
82 /// <param name="agentData"></param> 96 /// <param name="agentData"></param>
83 public virtual void AddNewCircuit(uint circuitCode, AgentCircuitData agentData) 97 public virtual void AddNewCircuit(uint circuitCode, AgentCircuitData agentData)
84 { 98 {
85 lock (AgentCircuits) 99 lock (m_agentCircuits)
86 { 100 {
87 if (AgentCircuits.ContainsKey(circuitCode)) 101 if (m_agentCircuits.ContainsKey(circuitCode))
88 { 102 {
89 AgentCircuits[circuitCode] = agentData; 103 m_agentCircuits[circuitCode] = agentData;
90 AgentCircuitsByUUID[agentData.AgentID] = agentData; 104 m_agentCircuitsByUUID[agentData.AgentID] = agentData;
91 } 105 }
92 else 106 else
93 { 107 {
94 AgentCircuits.Add(circuitCode, agentData); 108 m_agentCircuits.Add(circuitCode, agentData);
95 AgentCircuitsByUUID[agentData.AgentID] = agentData; 109 m_agentCircuitsByUUID[agentData.AgentID] = agentData;
96 } 110 }
97 } 111 }
98 } 112 }
99 113
100 public virtual void RemoveCircuit(uint circuitCode) 114 public virtual void RemoveCircuit(uint circuitCode)
101 { 115 {
102 lock (AgentCircuits) 116 lock (m_agentCircuits)
103 { 117 {
104 if (AgentCircuits.ContainsKey(circuitCode)) 118 if (m_agentCircuits.ContainsKey(circuitCode))
105 { 119 {
106 UUID agentID = AgentCircuits[circuitCode].AgentID; 120 UUID agentID = m_agentCircuits[circuitCode].AgentID;
107 AgentCircuits.Remove(circuitCode); 121 m_agentCircuits.Remove(circuitCode);
108 AgentCircuitsByUUID.Remove(agentID); 122 m_agentCircuitsByUUID.Remove(agentID);
109 } 123 }
110 } 124 }
111 } 125 }
112 126
113 public virtual void RemoveCircuit(UUID agentID) 127 public virtual void RemoveCircuit(UUID agentID)
114 { 128 {
115 lock (AgentCircuits) 129 lock (m_agentCircuits)
116 { 130 {
117 if (AgentCircuitsByUUID.ContainsKey(agentID)) 131 if (m_agentCircuitsByUUID.ContainsKey(agentID))
118 { 132 {
119 uint circuitCode = AgentCircuitsByUUID[agentID].circuitcode; 133 uint circuitCode = m_agentCircuitsByUUID[agentID].circuitcode;
120 AgentCircuits.Remove(circuitCode); 134 m_agentCircuits.Remove(circuitCode);
121 AgentCircuitsByUUID.Remove(agentID); 135 m_agentCircuitsByUUID.Remove(agentID);
122 } 136 }
123 } 137 }
124 } 138 }
139
125 public AgentCircuitData GetAgentCircuitData(uint circuitCode) 140 public AgentCircuitData GetAgentCircuitData(uint circuitCode)
126 { 141 {
127 AgentCircuitData agentCircuit = null; 142 AgentCircuitData agentCircuit = null;
128 AgentCircuits.TryGetValue(circuitCode, out agentCircuit); 143
144 lock (m_agentCircuits)
145 m_agentCircuits.TryGetValue(circuitCode, out agentCircuit);
146
129 return agentCircuit; 147 return agentCircuit;
130 } 148 }
131 149
132 public AgentCircuitData GetAgentCircuitData(UUID agentID) 150 public AgentCircuitData GetAgentCircuitData(UUID agentID)
133 { 151 {
134 AgentCircuitData agentCircuit = null; 152 AgentCircuitData agentCircuit = null;
135 AgentCircuitsByUUID.TryGetValue(agentID, out agentCircuit); 153
154 lock (m_agentCircuits)
155 m_agentCircuitsByUUID.TryGetValue(agentID, out agentCircuit);
156
136 return agentCircuit; 157 return agentCircuit;
137 } 158 }
138 159
160 /// <summary>
161 /// Get all current agent circuits indexed by agent UUID.
162 /// </summary>
163 /// <returns></returns>
164 public Dictionary<UUID, AgentCircuitData> GetAgentCircuits()
165 {
166 lock (m_agentCircuits)
167 return new Dictionary<UUID, AgentCircuitData>(m_agentCircuitsByUUID);
168 }
169
139 public void UpdateAgentData(AgentCircuitData agentData) 170 public void UpdateAgentData(AgentCircuitData agentData)
140 { 171 {
141 if (AgentCircuits.ContainsKey((uint) agentData.circuitcode)) 172 lock (m_agentCircuits)
142 { 173 {
143 AgentCircuits[(uint) agentData.circuitcode].firstname = agentData.firstname; 174 if (m_agentCircuits.ContainsKey((uint) agentData.circuitcode))
144 AgentCircuits[(uint) agentData.circuitcode].lastname = agentData.lastname; 175 {
145 AgentCircuits[(uint) agentData.circuitcode].startpos = agentData.startpos; 176 m_agentCircuits[(uint) agentData.circuitcode].firstname = agentData.firstname;
177 m_agentCircuits[(uint) agentData.circuitcode].lastname = agentData.lastname;
178 m_agentCircuits[(uint) agentData.circuitcode].startpos = agentData.startpos;
146 179
147 // Updated for when we don't know them before calling Scene.NewUserConnection 180 // Updated for when we don't know them before calling Scene.NewUserConnection
148 AgentCircuits[(uint) agentData.circuitcode].SecureSessionID = agentData.SecureSessionID; 181 m_agentCircuits[(uint) agentData.circuitcode].SecureSessionID = agentData.SecureSessionID;
149 AgentCircuits[(uint) agentData.circuitcode].SessionID = agentData.SessionID; 182 m_agentCircuits[(uint) agentData.circuitcode].SessionID = agentData.SessionID;
150 183
151 // m_log.Debug("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z); 184 // m_log.Debug("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z);
185 }
152 } 186 }
153 } 187 }
154 188
@@ -159,38 +193,37 @@ namespace OpenSim.Framework
159 /// <param name="newcircuitcode"></param> 193 /// <param name="newcircuitcode"></param>
160 public bool TryChangeCiruitCode(uint circuitcode, uint newcircuitcode) 194 public bool TryChangeCiruitCode(uint circuitcode, uint newcircuitcode)
161 { 195 {
162 lock (AgentCircuits) 196 lock (m_agentCircuits)
163 { 197 {
164 if (AgentCircuits.ContainsKey((uint)circuitcode) && !AgentCircuits.ContainsKey((uint)newcircuitcode)) 198 if (m_agentCircuits.ContainsKey((uint)circuitcode) && !m_agentCircuits.ContainsKey((uint)newcircuitcode))
165 { 199 {
166 AgentCircuitData agentData = AgentCircuits[(uint)circuitcode]; 200 AgentCircuitData agentData = m_agentCircuits[(uint)circuitcode];
167 201
168 agentData.circuitcode = newcircuitcode; 202 agentData.circuitcode = newcircuitcode;
169 203
170 AgentCircuits.Remove((uint)circuitcode); 204 m_agentCircuits.Remove((uint)circuitcode);
171 AgentCircuits.Add(newcircuitcode, agentData); 205 m_agentCircuits.Add(newcircuitcode, agentData);
172 return true; 206 return true;
173 } 207 }
174 } 208 }
175 return false;
176 209
210 return false;
177 } 211 }
178 212
179 public void UpdateAgentChildStatus(uint circuitcode, bool childstatus) 213 public void UpdateAgentChildStatus(uint circuitcode, bool childstatus)
180 { 214 {
181 if (AgentCircuits.ContainsKey(circuitcode)) 215 lock (m_agentCircuits)
182 { 216 if (m_agentCircuits.ContainsKey(circuitcode))
183 AgentCircuits[circuitcode].child = childstatus; 217 m_agentCircuits[circuitcode].child = childstatus;
184 }
185 } 218 }
186 219
187 public bool GetAgentChildStatus(uint circuitcode) 220 public bool GetAgentChildStatus(uint circuitcode)
188 { 221 {
189 if (AgentCircuits.ContainsKey(circuitcode)) 222 lock (m_agentCircuits)
190 { 223 if (m_agentCircuits.ContainsKey(circuitcode))
191 return AgentCircuits[circuitcode].child; 224 return m_agentCircuits[circuitcode].child;
192 } 225
193 return false; 226 return false;
194 } 227 }
195 } 228 }
196} 229} \ No newline at end of file