aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs89
1 files changed, 41 insertions, 48 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
index 7c9a1c4..9ccfd5d 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
@@ -30,7 +30,7 @@ using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Net; 31using System.Net;
32using System.Reflection; 32using System.Reflection;
33using System.Threading; 33using System.Text;
34using log4net; 34using log4net;
35using Nini.Config; 35using Nini.Config;
36using Mono.Addins; 36using Mono.Addins;
@@ -292,8 +292,6 @@ namespace OpenSim.Region.ClientStack.Linden
292 Queue<OSD> queue; 292 Queue<OSD> queue;
293 Random rnd = new Random(Environment.TickCount); 293 Random rnd = new Random(Environment.TickCount);
294 int nrnd = rnd.Next(30000000); 294 int nrnd = rnd.Next(30000000);
295 if (nrnd < 0)
296 nrnd = -nrnd;
297 295
298 lock (queues) 296 lock (queues)
299 { 297 {
@@ -307,21 +305,11 @@ namespace OpenSim.Region.ClientStack.Linden
307 queue = new Queue<OSD>(); 305 queue = new Queue<OSD>();
308 queues[agentID] = queue; 306 queues[agentID] = queue;
309 307
310 // push markers to handle old responses still waiting
311 // this will cost at most viewer getting two forced noevents
312 // even being a new queue better be safe
313 queue.Enqueue(null);
314 queue.Enqueue(null); // one should be enough
315
316 lock (m_AvatarQueueUUIDMapping) 308 lock (m_AvatarQueueUUIDMapping)
317 { 309 {
318 eventQueueGetUUID = UUID.Random(); 310 eventQueueGetUUID = UUID.Random();
319 if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) 311 while(m_AvatarQueueUUIDMapping.ContainsKey(agentID))
320 { 312 eventQueueGetUUID = UUID.Random();
321 // oops this should not happen ?
322 m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID without a queue");
323 eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID];
324 }
325 m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); 313 m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID);
326 } 314 }
327 lock (m_ids) 315 lock (m_ids)
@@ -329,18 +317,14 @@ namespace OpenSim.Region.ClientStack.Linden
329 if (!m_ids.ContainsKey(agentID)) 317 if (!m_ids.ContainsKey(agentID))
330 m_ids.Add(agentID, nrnd); 318 m_ids.Add(agentID, nrnd);
331 else 319 else
332 m_ids[agentID] = nrnd; 320 m_ids[agentID]++;
333 } 321 }
334 } 322 }
335 else 323 else
336 { 324 {
337 // push markers to handle old responses still waiting
338 // this will cost at most viewer getting two forced noevents
339 // even being a new queue better be safe
340 queue.Enqueue(null); 325 queue.Enqueue(null);
341 queue.Enqueue(null); // one should be enough 326 queue.Enqueue(null); // one should be enough
342 327 // reuse or not to reuse
343 // reuse or not to reuse TODO FIX
344 lock (m_AvatarQueueUUIDMapping) 328 lock (m_AvatarQueueUUIDMapping)
345 { 329 {
346 // Reuse open queues. The client does! 330 // Reuse open queues. The client does!
@@ -349,30 +333,39 @@ namespace OpenSim.Region.ClientStack.Linden
349 { 333 {
350 m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!"); 334 m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!");
351 eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; 335 eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID];
336 lock (m_ids)
337 {
338 // change to negative numbers so they are changed at end of sending first marker
339 // old data on a queue may be sent on a response for a new caps
340 // but at least will be sent with coerent IDs
341 if (!m_ids.ContainsKey(agentID))
342 m_ids.Add(agentID, -nrnd); // should not happen
343 else
344 m_ids[agentID] = -m_ids[agentID];
345 }
352 } 346 }
353 else 347 else
354 { 348 {
355 eventQueueGetUUID = UUID.Random(); 349 eventQueueGetUUID = UUID.Random();
350 while(m_AvatarQueueUUIDMapping.ContainsKey(agentID))
351 eventQueueGetUUID = UUID.Random();
356 m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); 352 m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID);
357 m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!"); 353 m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!");
354 lock (m_ids)
355 {
356 if (!m_ids.ContainsKey(agentID))
357 m_ids.Add(agentID, nrnd);
358 else
359 m_ids[agentID]++;
360 }
358 } 361 }
359 } 362 }
360 lock (m_ids)
361 {
362 // change to negative numbers so they are changed at end of sending first marker
363 // old data on a queue may be sent on a response for a new caps
364 // but at least will be sent with coerent IDs
365 if (!m_ids.ContainsKey(agentID))
366 m_ids.Add(agentID, -nrnd); // should not happen
367 else
368 m_ids[agentID] = -m_ids[agentID];
369 }
370 } 363 }
371 } 364 }
372 365
373 caps.RegisterPollHandler( 366 caps.RegisterPollHandler(
374 "EventQueueGet", 367 "EventQueueGet",
375 new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS)); 368 new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, Drop, agentID, SERVER_EQ_TIME_NO_EVENTS));
376 } 369 }
377 370
378 public bool HasEvents(UUID requestID, UUID agentID) 371 public bool HasEvents(UUID requestID, UUID agentID)
@@ -448,7 +441,6 @@ namespace OpenSim.Region.ClientStack.Linden
448 if (DebugLevel > 0) 441 if (DebugLevel > 0)
449 LogOutboundDebugMessage(element, pAgentId); 442 LogOutboundDebugMessage(element, pAgentId);
450 array.Add(element); 443 array.Add(element);
451 thisID++;
452 } 444 }
453 } 445 }
454 446
@@ -465,8 +457,6 @@ namespace OpenSim.Region.ClientStack.Linden
465 { 457 {
466 Random rnd = new Random(Environment.TickCount); 458 Random rnd = new Random(Environment.TickCount);
467 thisID = rnd.Next(30000000); 459 thisID = rnd.Next(30000000);
468 if (thisID < 0)
469 thisID = -thisID;
470 } 460 }
471 461
472 lock (m_ids) 462 lock (m_ids)
@@ -474,16 +464,19 @@ namespace OpenSim.Region.ClientStack.Linden
474 m_ids[pAgentId] = thisID + 1; 464 m_ids[pAgentId] = thisID + 1;
475 } 465 }
476 466
467 Hashtable responsedata;
477 // if there where no elements before a marker send a NoEvents 468 // if there where no elements before a marker send a NoEvents
478 if (array.Count == 0) 469 if (events == null)
479 return NoEvents(requestID, pAgentId); 470 {
480 471 return NoEvents(requestID, pAgentId);
481 Hashtable responsedata = new Hashtable(); 472 }
482 responsedata["int_response_code"] = 200; 473 else
483 responsedata["content_type"] = "application/xml"; 474 {
484 responsedata["keepalive"] = false; 475 responsedata = new Hashtable();
485 responsedata["reusecontext"] = false; 476 responsedata["int_response_code"] = 200;
486 responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events); 477 responsedata["content_type"] = "application/xml";
478 responsedata["bin_response_data"] = Encoding.UTF8.GetBytes(OSDParser.SerializeLLSDXmlString(events));
479 }
487 //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", pAgentId, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); 480 //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", pAgentId, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
488 return responsedata; 481 return responsedata;
489 } 482 }
@@ -493,13 +486,13 @@ namespace OpenSim.Region.ClientStack.Linden
493 Hashtable responsedata = new Hashtable(); 486 Hashtable responsedata = new Hashtable();
494 responsedata["int_response_code"] = 502; 487 responsedata["int_response_code"] = 502;
495 responsedata["content_type"] = "text/plain"; 488 responsedata["content_type"] = "text/plain";
496 responsedata["keepalive"] = false;
497 responsedata["reusecontext"] = false;
498 responsedata["str_response_string"] = "<llsd></llsd>"; 489 responsedata["str_response_string"] = "<llsd></llsd>";
499 responsedata["error_status_text"] = "<llsd></llsd>"; 490 responsedata["error_status_text"] = "<llsd></llsd>";
500 responsedata["http_protocol_version"] = "HTTP/1.0"; 491 responsedata["http_protocol_version"] = "HTTP/1.0";
492 responsedata["keepalive"] = false;
501 return responsedata; 493 return responsedata;
502 } 494 }
495
503/* this is not a event message 496/* this is not a event message
504 public void DisableSimulator(ulong handle, UUID avatarID) 497 public void DisableSimulator(ulong handle, UUID avatarID)
505 { 498 {