aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r--OpenSim/Framework/Communications/CommunicationsManager.cs61
1 files changed, 52 insertions, 9 deletions
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs
index 37020f6..cc64e6c 100644
--- a/OpenSim/Framework/Communications/CommunicationsManager.cs
+++ b/OpenSim/Framework/Communications/CommunicationsManager.cs
@@ -41,6 +41,7 @@ namespace OpenSim.Framework.Communications
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 42
43 protected IUserService m_userService; 43 protected IUserService m_userService;
44 protected Dictionary<LLUUID, string[]> m_nameRequestCache = new Dictionary<LLUUID, string[]>();
44 45
45 public IUserService UserService 46 public IUserService UserService
46 { 47 {
@@ -248,27 +249,69 @@ namespace OpenSim.Framework.Communications
248 } 249 }
249 else 250 else
250 { 251 {
252 string[] names = doUUIDNameRequest(uuid);
253 if (names.Length == 2)
254 {
255 remote_client.SendNameReply(uuid, names[0], names[1]);
256 }
257
258 }
259 }
260
261 private string[] doUUIDNameRequest(LLUUID uuid)
262 {
263 string[] returnstring = new string[0];
264 bool doLookup = false;
265
266
267 lock (m_nameRequestCache)
268 {
269 if (m_nameRequestCache.ContainsKey(uuid))
270 {
271 returnstring = m_nameRequestCache[uuid];
272 }
273 else
274 {
275 // we don't want to lock the dictionary while we're doing the lookup
276 doLookup = true;
277 }
278 }
279
280 if (doLookup) {
251 UserProfileData profileData = m_userService.GetUserProfile(uuid); 281 UserProfileData profileData = m_userService.GetUserProfile(uuid);
252 if (profileData != null) 282 if (profileData != null)
253 { 283 {
284 returnstring = new string[2];
254 LLUUID profileId = profileData.ID; 285 LLUUID profileId = profileData.ID;
255 string firstname = profileData.FirstName; 286 returnstring[0] = profileData.FirstName;
256 string lastname = profileData.SurName; 287 returnstring[1] = profileData.SurName;
257 288 lock (m_nameRequestCache)
258 remote_client.SendNameReply(profileId, firstname, lastname); 289 {
290 if (!m_nameRequestCache.ContainsKey(uuid))
291 m_nameRequestCache.Add(uuid, returnstring);
292 }
259 } 293 }
260 } 294 }
295 return returnstring;
296
261 } 297 }
298
299 public bool UUIDNameCachedTest(LLUUID uuid)
300 {
301 lock (m_nameRequestCache)
302 return m_nameRequestCache.ContainsKey(uuid);
303 }
304
262 public string UUIDNameRequestString(LLUUID uuid) 305 public string UUIDNameRequestString(LLUUID uuid)
263 { 306 {
264 UserProfileData profileData = m_userService.GetUserProfile(uuid); 307 string[] names = doUUIDNameRequest(uuid);
265 if (profileData != null) 308 if (names.Length == 2)
266 { 309 {
267 //LLUUID profileId = profileData.ID; 310 string firstname = names[0];
268 string firstname = profileData.FirstName; 311 string lastname = names[1];
269 string lastname = profileData.SurName;
270 312
271 return firstname + " " + lastname; 313 return firstname + " " + lastname;
314
272 } 315 }
273 return "(hippos)"; 316 return "(hippos)";
274 } 317 }