aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-11-24 21:27:35 +0000
committerJustin Clark-Casey (justincc)2011-11-24 21:27:35 +0000
commit63c137820b44e9d1e248ba32ccd6df5110a2bdb9 (patch)
tree9d2a11321d2416390c9fa195d156bb0b154371fd /OpenSim/Region/ClientStack
parentAdd a "debug eq" console command for debugging. (diff)
downloadopensim-SC_OLD-63c137820b44e9d1e248ba32ccd6df5110a2bdb9.zip
opensim-SC_OLD-63c137820b44e9d1e248ba32ccd6df5110a2bdb9.tar.gz
opensim-SC_OLD-63c137820b44e9d1e248ba32ccd6df5110a2bdb9.tar.bz2
opensim-SC_OLD-63c137820b44e9d1e248ba32ccd6df5110a2bdb9.tar.xz
Stop passing a request handler to the initial caps.RegisterHandler in EventQueueGetModule since this is immediatley replaced by a poll server handler.
This allows us to comment out a bunch of code and simplify the codebase and readability.
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs319
1 files changed, 162 insertions, 157 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
index f5feb71..24f76d69 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
@@ -346,12 +346,16 @@ namespace OpenSim.Region.ClientStack.Linden
346 } 346 }
347 347
348 // Register this as a caps handler 348 // Register this as a caps handler
349 // FIXME: Confusingly, we need to register separate as a capability so that the client is told about
350 // EventQueueGet when it receive capability information, but then we replace the rest handler immediately
351 // afterwards with the poll service. So for now, we'll pass a null instead to simplify code reading, but
352 // really it should be possible to directly register the poll handler as a capability.
349 caps.RegisterHandler("EventQueueGet", 353 caps.RegisterHandler("EventQueueGet",
350 new RestHTTPHandler("POST", capsBase + EventQueueGetUUID.ToString() + "/", 354 new RestHTTPHandler("POST", capsBase + EventQueueGetUUID.ToString() + "/", null));
351 delegate(Hashtable m_dhttpMethod) 355// delegate(Hashtable m_dhttpMethod)
352 { 356// {
353 return ProcessQueue(m_dhttpMethod, agentID, caps); 357// return ProcessQueue(m_dhttpMethod, agentID, caps);
354 })); 358// }));
355 359
356 // This will persist this beyond the expiry of the caps handlers 360 // This will persist this beyond the expiry of the caps handlers
357 MainServer.Instance.AddPollServiceHTTPHandler( 361 MainServer.Instance.AddPollServiceHTTPHandler(
@@ -382,6 +386,8 @@ namespace OpenSim.Region.ClientStack.Linden
382 386
383 public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request) 387 public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request)
384 { 388 {
389 m_log.DebugFormat("[EVENT QUEUE GET MODULE]: Invoked GetEvents() for {0}", pAgentId);
390
385 Queue<OSD> queue = TryGetQueue(pAgentId); 391 Queue<OSD> queue = TryGetQueue(pAgentId);
386 OSD element; 392 OSD element;
387 lock (queue) 393 lock (queue)
@@ -465,167 +471,166 @@ namespace OpenSim.Region.ClientStack.Linden
465 return responsedata; 471 return responsedata;
466 } 472 }
467 473
468 public Hashtable ProcessQueue(Hashtable request, UUID agentID, Caps caps) 474// public Hashtable ProcessQueue(Hashtable request, UUID agentID, Caps caps)
469 { 475// {
470 // TODO: this has to be redone to not busy-wait (and block the thread), 476// // TODO: this has to be redone to not busy-wait (and block the thread),
471 // TODO: as soon as we have a non-blocking way to handle HTTP-requests. 477// // TODO: as soon as we have a non-blocking way to handle HTTP-requests.
472 478//
473// if (m_log.IsDebugEnabled) 479//// if (m_log.IsDebugEnabled)
474// { 480//// {
475// String debug = "[EVENTQUEUE]: Got request for agent {0} in region {1} from thread {2}: [ "; 481//// String debug = "[EVENTQUEUE]: Got request for agent {0} in region {1} from thread {2}: [ ";
476// foreach (object key in request.Keys) 482//// foreach (object key in request.Keys)
483//// {
484//// debug += key.ToString() + "=" + request[key].ToString() + " ";
485//// }
486//// m_log.DebugFormat(debug + " ]", agentID, m_scene.RegionInfo.RegionName, System.Threading.Thread.CurrentThread.Name);
487//// }
488//
489// Queue<OSD> queue = TryGetQueue(agentID);
490// OSD element;
491//
492// lock (queue)
493// element = queue.Dequeue(); // 15s timeout
494//
495// Hashtable responsedata = new Hashtable();
496//
497// int thisID = 0;
498// lock (m_ids)
499// thisID = m_ids[agentID];
500//
501// if (element == null)
502// {
503// //m_log.ErrorFormat("[EVENTQUEUE]: Nothing to process in " + m_scene.RegionInfo.RegionName);
504// if (thisID == -1) // close-request
477// { 505// {
478// debug += key.ToString() + "=" + request[key].ToString() + " "; 506// m_log.ErrorFormat("[EVENTQUEUE]: 404 in " + m_scene.RegionInfo.RegionName);
507// responsedata["int_response_code"] = 404; //501; //410; //404;
508// responsedata["content_type"] = "text/plain";
509// responsedata["keepalive"] = false;
510// responsedata["str_response_string"] = "Closed EQG";
511// return responsedata;
479// } 512// }
480// m_log.DebugFormat(debug + " ]", agentID, m_scene.RegionInfo.RegionName, System.Threading.Thread.CurrentThread.Name); 513// responsedata["int_response_code"] = 502;
514// responsedata["content_type"] = "text/plain";
515// responsedata["keepalive"] = false;
516// responsedata["str_response_string"] = "Upstream error: ";
517// responsedata["error_status_text"] = "Upstream error:";
518// responsedata["http_protocol_version"] = "HTTP/1.0";
519// return responsedata;
481// } 520// }
482 521//
483 Queue<OSD> queue = TryGetQueue(agentID); 522// OSDArray array = new OSDArray();
484 OSD element; 523// if (element == null) // didn't have an event in 15s
485 524// {
486 lock (queue) 525// // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say!
487 element = queue.Dequeue(); // 15s timeout 526// array.Add(EventQueueHelper.KeepAliveEvent());
488 527// //m_log.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName);
489 Hashtable responsedata = new Hashtable(); 528// }
490 529// else
491 int thisID = 0; 530// {
492 lock (m_ids) 531// array.Add(element);
493 thisID = m_ids[agentID]; 532//
494 533// if (element is OSDMap)
495 if (element == null) 534// {
496 { 535// OSDMap ev = (OSDMap)element;
497 //m_log.ErrorFormat("[EVENTQUEUE]: Nothing to process in " + m_scene.RegionInfo.RegionName); 536// m_log.DebugFormat(
498 if (thisID == -1) // close-request 537// "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}",
499 { 538// ev["message"], m_scene.GetScenePresence(agentID).Name);
500 m_log.ErrorFormat("[EVENTQUEUE]: 404 in " + m_scene.RegionInfo.RegionName); 539// }
501 responsedata["int_response_code"] = 404; //501; //410; //404; 540//
502 responsedata["content_type"] = "text/plain"; 541// lock (queue)
503 responsedata["keepalive"] = false; 542// {
504 responsedata["str_response_string"] = "Closed EQG"; 543// while (queue.Count > 0)
505 return responsedata; 544// {
506 } 545// element = queue.Dequeue();
507 responsedata["int_response_code"] = 502; 546//
508 responsedata["content_type"] = "text/plain"; 547// if (element is OSDMap)
509 responsedata["keepalive"] = false; 548// {
510 responsedata["str_response_string"] = "Upstream error: "; 549// OSDMap ev = (OSDMap)element;
511 responsedata["error_status_text"] = "Upstream error:"; 550// m_log.DebugFormat(
512 responsedata["http_protocol_version"] = "HTTP/1.0"; 551// "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}",
513 return responsedata; 552// ev["message"], m_scene.GetScenePresence(agentID).Name);
514 } 553// }
515 554//
516 OSDArray array = new OSDArray(); 555// array.Add(element);
517 if (element == null) // didn't have an event in 15s 556// thisID++;
518 { 557// }
519 // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say! 558// }
520 array.Add(EventQueueHelper.KeepAliveEvent()); 559// }
521 //m_log.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); 560//
522 } 561// OSDMap events = new OSDMap();
523 else 562// events.Add("events", array);
524 { 563//
525 array.Add(element); 564// events.Add("id", new OSDInteger(thisID));
526 565// lock (m_ids)
527 if (element is OSDMap) 566// {
528 { 567// m_ids[agentID] = thisID + 1;
529 OSDMap ev = (OSDMap)element; 568// }
530 m_log.DebugFormat( 569//
531 "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", 570// responsedata["int_response_code"] = 200;
532 ev["message"], m_scene.GetScenePresence(agentID).Name); 571// responsedata["content_type"] = "application/xml";
533 } 572// responsedata["keepalive"] = false;
534 573// responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events);
535 lock (queue) 574//
536 { 575// m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
537 while (queue.Count > 0) 576//
538 { 577// return responsedata;
539 element = queue.Dequeue(); 578// }
540
541 if (element is OSDMap)
542 {
543 OSDMap ev = (OSDMap)element;
544 m_log.DebugFormat(
545 "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}",
546 ev["message"], m_scene.GetScenePresence(agentID).Name);
547 }
548
549 array.Add(element);
550 thisID++;
551 }
552 }
553 }
554
555 OSDMap events = new OSDMap();
556 events.Add("events", array);
557
558 events.Add("id", new OSDInteger(thisID));
559 lock (m_ids)
560 {
561 m_ids[agentID] = thisID + 1;
562 }
563
564 responsedata["int_response_code"] = 200;
565 responsedata["content_type"] = "application/xml";
566 responsedata["keepalive"] = false;
567 responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events);
568
569 m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
570
571 return responsedata;
572 }
573 579
574 public Hashtable EventQueuePoll(Hashtable request) 580 public Hashtable EventQueuePoll(Hashtable request)
575 { 581 {
576 return new Hashtable(); 582 return new Hashtable();
577 } 583 }
578 584
579 public Hashtable EventQueuePath2(Hashtable request) 585// public Hashtable EventQueuePath2(Hashtable request)
580 { 586// {
581 string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/",""); 587// string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/","");
582 // pull off the last "/" in the path. 588// // pull off the last "/" in the path.
583 Hashtable responsedata = new Hashtable(); 589// Hashtable responsedata = new Hashtable();
584 capuuid = capuuid.Substring(0, capuuid.Length - 1); 590// capuuid = capuuid.Substring(0, capuuid.Length - 1);
585 capuuid = capuuid.Replace("/CAPS/EQG/", ""); 591// capuuid = capuuid.Replace("/CAPS/EQG/", "");
586 UUID AvatarID = UUID.Zero; 592// UUID AvatarID = UUID.Zero;
587 UUID capUUID = UUID.Zero; 593// UUID capUUID = UUID.Zero;
588 594//
589 // parse the path and search for the avatar with it registered 595// // parse the path and search for the avatar with it registered
590 if (UUID.TryParse(capuuid, out capUUID)) 596// if (UUID.TryParse(capuuid, out capUUID))
591 { 597// {
592 lock (m_QueueUUIDAvatarMapping) 598// lock (m_QueueUUIDAvatarMapping)
593 { 599// {
594 if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID)) 600// if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID))
595 { 601// {
596 AvatarID = m_QueueUUIDAvatarMapping[capUUID]; 602// AvatarID = m_QueueUUIDAvatarMapping[capUUID];
597 } 603// }
598 } 604// }
599 605//
600 if (AvatarID != UUID.Zero) 606// if (AvatarID != UUID.Zero)
601 { 607// {
602 return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsForUser(AvatarID)); 608// return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsForUser(AvatarID));
603 } 609// }
604 else 610// else
605 { 611// {
606 responsedata["int_response_code"] = 404; 612// responsedata["int_response_code"] = 404;
607 responsedata["content_type"] = "text/plain"; 613// responsedata["content_type"] = "text/plain";
608 responsedata["keepalive"] = false; 614// responsedata["keepalive"] = false;
609 responsedata["str_response_string"] = "Not Found"; 615// responsedata["str_response_string"] = "Not Found";
610 responsedata["error_status_text"] = "Not Found"; 616// responsedata["error_status_text"] = "Not Found";
611 responsedata["http_protocol_version"] = "HTTP/1.0"; 617// responsedata["http_protocol_version"] = "HTTP/1.0";
612 return responsedata; 618// return responsedata;
613 // return 404 619// // return 404
614 } 620// }
615 } 621// }
616 else 622// else
617 { 623// {
618 responsedata["int_response_code"] = 404; 624// responsedata["int_response_code"] = 404;
619 responsedata["content_type"] = "text/plain"; 625// responsedata["content_type"] = "text/plain";
620 responsedata["keepalive"] = false; 626// responsedata["keepalive"] = false;
621 responsedata["str_response_string"] = "Not Found"; 627// responsedata["str_response_string"] = "Not Found";
622 responsedata["error_status_text"] = "Not Found"; 628// responsedata["error_status_text"] = "Not Found";
623 responsedata["http_protocol_version"] = "HTTP/1.0"; 629// responsedata["http_protocol_version"] = "HTTP/1.0";
624 return responsedata; 630// return responsedata;
625 // return 404 631// // return 404
626 } 632// }
627 633// }
628 }
629 634
630 public OSD EventQueueFallBack(string path, OSD request, string endpoint) 635 public OSD EventQueueFallBack(string path, OSD request, string endpoint)
631 { 636 {