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