diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 490 |
1 files changed, 153 insertions, 337 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 9b9f6a7..5fb028c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | |||
@@ -78,7 +78,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
78 | private Dictionary<UUID, int> m_ids = new Dictionary<UUID, int>(); | 78 | private Dictionary<UUID, int> m_ids = new Dictionary<UUID, int>(); |
79 | 79 | ||
80 | private Dictionary<UUID, Queue<OSD>> queues = new Dictionary<UUID, Queue<OSD>>(); | 80 | private Dictionary<UUID, Queue<OSD>> queues = new Dictionary<UUID, Queue<OSD>>(); |
81 | private Dictionary<UUID, UUID> m_QueueUUIDAvatarMapping = new Dictionary<UUID, UUID>(); | ||
82 | private Dictionary<UUID, UUID> m_AvatarQueueUUIDMapping = new Dictionary<UUID, UUID>(); | 81 | private Dictionary<UUID, UUID> m_AvatarQueueUUIDMapping = new Dictionary<UUID, UUID>(); |
83 | 82 | ||
84 | #region INonSharedRegionModule methods | 83 | #region INonSharedRegionModule methods |
@@ -178,6 +177,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
178 | } | 177 | } |
179 | 178 | ||
180 | /// <summary> | 179 | /// <summary> |
180 | <<<<<<< HEAD | ||
181 | /// Always returns a valid queue | 181 | /// Always returns a valid queue |
182 | /// </summary> | 182 | /// </summary> |
183 | /// <param name="agentId"></param> | 183 | /// <param name="agentId"></param> |
@@ -201,6 +201,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
201 | } | 201 | } |
202 | 202 | ||
203 | /// <summary> | 203 | /// <summary> |
204 | ======= | ||
205 | >>>>>>> avn/ubitvar | ||
204 | /// May return a null queue | 206 | /// May return a null queue |
205 | /// </summary> | 207 | /// </summary> |
206 | /// <param name="agentId"></param> | 208 | /// <param name="agentId"></param> |
@@ -263,28 +265,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
263 | lock (queues) | 265 | lock (queues) |
264 | queues.Remove(agentID); | 266 | queues.Remove(agentID); |
265 | 267 | ||
266 | List<UUID> removeitems = new List<UUID>(); | ||
267 | lock (m_AvatarQueueUUIDMapping) | 268 | lock (m_AvatarQueueUUIDMapping) |
268 | m_AvatarQueueUUIDMapping.Remove(agentID); | 269 | m_AvatarQueueUUIDMapping.Remove(agentID); |
269 | 270 | ||
270 | UUID searchval = UUID.Zero; | 271 | lock (m_ids) |
271 | |||
272 | removeitems.Clear(); | ||
273 | |||
274 | lock (m_QueueUUIDAvatarMapping) | ||
275 | { | 272 | { |
276 | foreach (UUID ky in m_QueueUUIDAvatarMapping.Keys) | 273 | if (!m_ids.ContainsKey(agentID)) |
277 | { | 274 | m_ids.Remove(agentID); |
278 | searchval = m_QueueUUIDAvatarMapping[ky]; | ||
279 | |||
280 | if (searchval == agentID) | ||
281 | { | ||
282 | removeitems.Add(ky); | ||
283 | } | ||
284 | } | ||
285 | |||
286 | foreach (UUID ky in removeitems) | ||
287 | m_QueueUUIDAvatarMapping.Remove(ky); | ||
288 | } | 275 | } |
289 | 276 | ||
290 | // m_log.DebugFormat("[EVENTQUEUE]: Deleted queues for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); | 277 | // m_log.DebugFormat("[EVENTQUEUE]: Deleted queues for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); |
@@ -303,61 +290,107 @@ namespace OpenSim.Region.ClientStack.Linden | |||
303 | public void OnRegisterCaps(UUID agentID, Caps caps) | 290 | public void OnRegisterCaps(UUID agentID, Caps caps) |
304 | { | 291 | { |
305 | // Register an event queue for the client | 292 | // Register an event queue for the client |
293 | <<<<<<< HEAD | ||
306 | 294 | ||
307 | if (DebugLevel > 0) | 295 | if (DebugLevel > 0) |
308 | m_log.DebugFormat( | 296 | m_log.DebugFormat( |
309 | "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}", | 297 | "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}", |
310 | agentID, caps, m_scene.RegionInfo.RegionName); | 298 | agentID, caps, m_scene.RegionInfo.RegionName); |
311 | 299 | ======= | |
312 | // Let's instantiate a Queue for this agent right now | 300 | m_log.DebugFormat( |
313 | TryGetQueue(agentID); | 301 | "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}", |
302 | agentID, caps, m_scene.RegionInfo.RegionName); | ||
303 | >>>>>>> avn/ubitvar | ||
314 | 304 | ||
315 | UUID eventQueueGetUUID; | 305 | UUID eventQueueGetUUID; |
306 | Queue<OSD> queue; | ||
307 | Random rnd = new Random(Environment.TickCount); | ||
308 | int nrnd = rnd.Next(30000000); | ||
309 | if (nrnd < 0) | ||
310 | nrnd = -nrnd; | ||
316 | 311 | ||
317 | lock (m_AvatarQueueUUIDMapping) | 312 | lock (queues) |
318 | { | 313 | { |
319 | // Reuse open queues. The client does! | 314 | if (queues.ContainsKey(agentID)) |
320 | if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) | 315 | queue = queues[agentID]; |
316 | else | ||
317 | queue = null; | ||
318 | |||
319 | if (queue == null) | ||
321 | { | 320 | { |
322 | //m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!"); | 321 | queue = new Queue<OSD>(); |
323 | eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; | 322 | queues[agentID] = queue; |
323 | |||
324 | // push markers to handle old responses still waiting | ||
325 | // this will cost at most viewer getting two forced noevents | ||
326 | // even being a new queue better be safe | ||
327 | queue.Enqueue(null); | ||
328 | queue.Enqueue(null); // one should be enough | ||
329 | |||
330 | lock (m_AvatarQueueUUIDMapping) | ||
331 | { | ||
332 | eventQueueGetUUID = UUID.Random(); | ||
333 | if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) | ||
334 | { | ||
335 | // oops this should not happen ? | ||
336 | m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID without a queue"); | ||
337 | eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; | ||
338 | } | ||
339 | m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); | ||
340 | } | ||
341 | lock (m_ids) | ||
342 | { | ||
343 | if (!m_ids.ContainsKey(agentID)) | ||
344 | m_ids.Add(agentID, nrnd); | ||
345 | else | ||
346 | m_ids[agentID] = nrnd; | ||
347 | } | ||
324 | } | 348 | } |
325 | else | 349 | else |
326 | { | 350 | { |
327 | eventQueueGetUUID = UUID.Random(); | 351 | // push markers to handle old responses still waiting |
328 | //m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!"); | 352 | // this will cost at most viewer getting two forced noevents |
353 | // even being a new queue better be safe | ||
354 | queue.Enqueue(null); | ||
355 | queue.Enqueue(null); // one should be enough | ||
356 | |||
357 | // reuse or not to reuse TODO FIX | ||
358 | lock (m_AvatarQueueUUIDMapping) | ||
359 | { | ||
360 | // Reuse open queues. The client does! | ||
361 | // Its reuse caps path not queues those are been reused already | ||
362 | if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) | ||
363 | { | ||
364 | m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!"); | ||
365 | eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; | ||
366 | } | ||
367 | else | ||
368 | { | ||
369 | eventQueueGetUUID = UUID.Random(); | ||
370 | m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); | ||
371 | m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!"); | ||
372 | } | ||
373 | } | ||
374 | lock (m_ids) | ||
375 | { | ||
376 | // change to negative numbers so they are changed at end of sending first marker | ||
377 | // old data on a queue may be sent on a response for a new caps | ||
378 | // but at least will be sent with coerent IDs | ||
379 | if (!m_ids.ContainsKey(agentID)) | ||
380 | m_ids.Add(agentID, -nrnd); // should not happen | ||
381 | else | ||
382 | m_ids[agentID] = -m_ids[agentID]; | ||
383 | } | ||
329 | } | 384 | } |
330 | } | 385 | } |
331 | 386 | ||
332 | lock (m_QueueUUIDAvatarMapping) | ||
333 | { | ||
334 | if (!m_QueueUUIDAvatarMapping.ContainsKey(eventQueueGetUUID)) | ||
335 | m_QueueUUIDAvatarMapping.Add(eventQueueGetUUID, agentID); | ||
336 | } | ||
337 | |||
338 | lock (m_AvatarQueueUUIDMapping) | ||
339 | { | ||
340 | if (!m_AvatarQueueUUIDMapping.ContainsKey(agentID)) | ||
341 | m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); | ||
342 | } | ||
343 | |||
344 | caps.RegisterPollHandler( | 387 | caps.RegisterPollHandler( |
345 | "EventQueueGet", | 388 | "EventQueueGet", |
346 | new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS)); | 389 | new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS)); |
347 | |||
348 | Random rnd = new Random(Environment.TickCount); | ||
349 | lock (m_ids) | ||
350 | { | ||
351 | if (!m_ids.ContainsKey(agentID)) | ||
352 | m_ids.Add(agentID, rnd.Next(30000000)); | ||
353 | } | ||
354 | } | 390 | } |
355 | 391 | ||
356 | public bool HasEvents(UUID requestID, UUID agentID) | 392 | public bool HasEvents(UUID requestID, UUID agentID) |
357 | { | 393 | { |
358 | // Don't use this, because of race conditions at agent closing time | ||
359 | //Queue<OSD> queue = TryGetQueue(agentID); | ||
360 | |||
361 | Queue<OSD> queue = GetQueue(agentID); | 394 | Queue<OSD> queue = GetQueue(agentID); |
362 | if (queue != null) | 395 | if (queue != null) |
363 | lock (queue) | 396 | lock (queue) |
@@ -366,7 +399,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
366 | return queue.Count > 0; | 399 | return queue.Count > 0; |
367 | } | 400 | } |
368 | 401 | ||
369 | return false; | 402 | //m_log.WarnFormat("POLLED FOR EVENTS BY {0} unknown agent", agentID); |
403 | return true; | ||
370 | } | 404 | } |
371 | 405 | ||
372 | /// <summary> | 406 | /// <summary> |
@@ -395,55 +429,65 @@ namespace OpenSim.Region.ClientStack.Linden | |||
395 | return NoEvents(requestID, pAgentId); | 429 | return NoEvents(requestID, pAgentId); |
396 | } | 430 | } |
397 | 431 | ||
398 | OSD element; | 432 | OSD element = null;; |
433 | OSDArray array = new OSDArray(); | ||
434 | int thisID = 0; | ||
435 | bool negativeID = false; | ||
436 | |||
399 | lock (queue) | 437 | lock (queue) |
400 | { | 438 | { |
401 | if (queue.Count == 0) | 439 | if (queue.Count == 0) |
402 | return NoEvents(requestID, pAgentId); | 440 | return NoEvents(requestID, pAgentId); |
403 | element = queue.Dequeue(); // 15s timeout | ||
404 | } | ||
405 | |||
406 | int thisID = 0; | ||
407 | lock (m_ids) | ||
408 | thisID = m_ids[pAgentId]; | ||
409 | |||
410 | OSDArray array = new OSDArray(); | ||
411 | if (element == null) // didn't have an event in 15s | ||
412 | { | ||
413 | // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say! | ||
414 | array.Add(EventQueueHelper.KeepAliveEvent()); | ||
415 | //m_log.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", pAgentId, m_scene.RegionInfo.RegionName); | ||
416 | } | ||
417 | else | ||
418 | { | ||
419 | if (DebugLevel > 0) | ||
420 | LogOutboundDebugMessage(element, pAgentId); | ||
421 | 441 | ||
422 | array.Add(element); | 442 | lock (m_ids) |
443 | thisID = m_ids[pAgentId]; | ||
423 | 444 | ||
424 | lock (queue) | 445 | if (thisID < 0) |
425 | { | 446 | { |
426 | while (queue.Count > 0) | 447 | negativeID = true; |
427 | { | 448 | thisID = -thisID; |
428 | element = queue.Dequeue(); | 449 | } |
450 | |||
451 | while (queue.Count > 0) | ||
452 | { | ||
453 | element = queue.Dequeue(); | ||
454 | // add elements until a marker is found | ||
455 | // so they get into a response | ||
456 | if (element == null) | ||
457 | break; | ||
458 | if (DebugLevel > 0) | ||
459 | LogOutboundDebugMessage(element, pAgentId); | ||
460 | array.Add(element); | ||
461 | thisID++; | ||
462 | } | ||
463 | } | ||
429 | 464 | ||
430 | if (DebugLevel > 0) | 465 | OSDMap events = null; |
431 | LogOutboundDebugMessage(element, pAgentId); | ||
432 | 466 | ||
433 | array.Add(element); | 467 | if (array.Count > 0) |
434 | thisID++; | 468 | { |
435 | } | 469 | events = new OSDMap(); |
436 | } | 470 | events.Add("events", array); |
471 | events.Add("id", new OSDInteger(thisID)); | ||
437 | } | 472 | } |
438 | 473 | ||
439 | OSDMap events = new OSDMap(); | 474 | if (negativeID && element == null) |
440 | events.Add("events", array); | 475 | { |
476 | Random rnd = new Random(Environment.TickCount); | ||
477 | thisID = rnd.Next(30000000); | ||
478 | if (thisID < 0) | ||
479 | thisID = -thisID; | ||
480 | } | ||
441 | 481 | ||
442 | events.Add("id", new OSDInteger(thisID)); | ||
443 | lock (m_ids) | 482 | lock (m_ids) |
444 | { | 483 | { |
445 | m_ids[pAgentId] = thisID + 1; | 484 | m_ids[pAgentId] = thisID + 1; |
446 | } | 485 | } |
486 | |||
487 | // if there where no elements before a marker send a NoEvents | ||
488 | if (array.Count == 0) | ||
489 | return NoEvents(requestID, pAgentId); | ||
490 | |||
447 | Hashtable responsedata = new Hashtable(); | 491 | Hashtable responsedata = new Hashtable(); |
448 | responsedata["int_response_code"] = 200; | 492 | responsedata["int_response_code"] = 200; |
449 | responsedata["content_type"] = "application/xml"; | 493 | responsedata["content_type"] = "application/xml"; |
@@ -461,260 +505,12 @@ namespace OpenSim.Region.ClientStack.Linden | |||
461 | responsedata["content_type"] = "text/plain"; | 505 | responsedata["content_type"] = "text/plain"; |
462 | responsedata["keepalive"] = false; | 506 | responsedata["keepalive"] = false; |
463 | responsedata["reusecontext"] = false; | 507 | responsedata["reusecontext"] = false; |
464 | responsedata["str_response_string"] = "Upstream error: "; | 508 | responsedata["str_response_string"] = "<llsd></llsd>"; |
465 | responsedata["error_status_text"] = "Upstream error:"; | 509 | responsedata["error_status_text"] = "<llsd></llsd>"; |
466 | responsedata["http_protocol_version"] = "HTTP/1.0"; | 510 | responsedata["http_protocol_version"] = "HTTP/1.0"; |
467 | return responsedata; | 511 | return responsedata; |
468 | } | 512 | } |
469 | 513 | ||
470 | // public Hashtable ProcessQueue(Hashtable request, UUID agentID, Caps caps) | ||
471 | // { | ||
472 | // // TODO: this has to be redone to not busy-wait (and block the thread), | ||
473 | // // TODO: as soon as we have a non-blocking way to handle HTTP-requests. | ||
474 | // | ||
475 | //// if (m_log.IsDebugEnabled) | ||
476 | //// { | ||
477 | //// String debug = "[EVENTQUEUE]: Got request for agent {0} in region {1} from thread {2}: [ "; | ||
478 | //// foreach (object key in request.Keys) | ||
479 | //// { | ||
480 | //// debug += key.ToString() + "=" + request[key].ToString() + " "; | ||
481 | //// } | ||
482 | //// m_log.DebugFormat(debug + " ]", agentID, m_scene.RegionInfo.RegionName, System.Threading.Thread.CurrentThread.Name); | ||
483 | //// } | ||
484 | // | ||
485 | // Queue<OSD> queue = TryGetQueue(agentID); | ||
486 | // OSD element; | ||
487 | // | ||
488 | // lock (queue) | ||
489 | // element = queue.Dequeue(); // 15s timeout | ||
490 | // | ||
491 | // Hashtable responsedata = new Hashtable(); | ||
492 | // | ||
493 | // int thisID = 0; | ||
494 | // lock (m_ids) | ||
495 | // thisID = m_ids[agentID]; | ||
496 | // | ||
497 | // if (element == null) | ||
498 | // { | ||
499 | // //m_log.ErrorFormat("[EVENTQUEUE]: Nothing to process in " + m_scene.RegionInfo.RegionName); | ||
500 | // if (thisID == -1) // close-request | ||
501 | // { | ||
502 | // m_log.ErrorFormat("[EVENTQUEUE]: 404 in " + m_scene.RegionInfo.RegionName); | ||
503 | // responsedata["int_response_code"] = 404; //501; //410; //404; | ||
504 | // responsedata["content_type"] = "text/plain"; | ||
505 | // responsedata["keepalive"] = false; | ||
506 | // responsedata["str_response_string"] = "Closed EQG"; | ||
507 | // return responsedata; | ||
508 | // } | ||
509 | // responsedata["int_response_code"] = 502; | ||
510 | // responsedata["content_type"] = "text/plain"; | ||
511 | // responsedata["keepalive"] = false; | ||
512 | // responsedata["str_response_string"] = "Upstream error: "; | ||
513 | // responsedata["error_status_text"] = "Upstream error:"; | ||
514 | // responsedata["http_protocol_version"] = "HTTP/1.0"; | ||
515 | // return responsedata; | ||
516 | // } | ||
517 | // | ||
518 | // OSDArray array = new OSDArray(); | ||
519 | // if (element == null) // didn't have an event in 15s | ||
520 | // { | ||
521 | // // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say! | ||
522 | // array.Add(EventQueueHelper.KeepAliveEvent()); | ||
523 | // //m_log.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); | ||
524 | // } | ||
525 | // else | ||
526 | // { | ||
527 | // array.Add(element); | ||
528 | // | ||
529 | // if (element is OSDMap) | ||
530 | // { | ||
531 | // OSDMap ev = (OSDMap)element; | ||
532 | // m_log.DebugFormat( | ||
533 | // "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", | ||
534 | // ev["message"], m_scene.GetScenePresence(agentID).Name); | ||
535 | // } | ||
536 | // | ||
537 | // lock (queue) | ||
538 | // { | ||
539 | // while (queue.Count > 0) | ||
540 | // { | ||
541 | // element = queue.Dequeue(); | ||
542 | // | ||
543 | // if (element is OSDMap) | ||
544 | // { | ||
545 | // OSDMap ev = (OSDMap)element; | ||
546 | // m_log.DebugFormat( | ||
547 | // "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", | ||
548 | // ev["message"], m_scene.GetScenePresence(agentID).Name); | ||
549 | // } | ||
550 | // | ||
551 | // array.Add(element); | ||
552 | // thisID++; | ||
553 | // } | ||
554 | // } | ||
555 | // } | ||
556 | // | ||
557 | // OSDMap events = new OSDMap(); | ||
558 | // events.Add("events", array); | ||
559 | // | ||
560 | // events.Add("id", new OSDInteger(thisID)); | ||
561 | // lock (m_ids) | ||
562 | // { | ||
563 | // m_ids[agentID] = thisID + 1; | ||
564 | // } | ||
565 | // | ||
566 | // responsedata["int_response_code"] = 200; | ||
567 | // responsedata["content_type"] = "application/xml"; | ||
568 | // responsedata["keepalive"] = false; | ||
569 | // responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events); | ||
570 | // | ||
571 | // m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); | ||
572 | // | ||
573 | // return responsedata; | ||
574 | // } | ||
575 | |||
576 | // public Hashtable EventQueuePath2(Hashtable request) | ||
577 | // { | ||
578 | // string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/",""); | ||
579 | // // pull off the last "/" in the path. | ||
580 | // Hashtable responsedata = new Hashtable(); | ||
581 | // capuuid = capuuid.Substring(0, capuuid.Length - 1); | ||
582 | // capuuid = capuuid.Replace("/CAPS/EQG/", ""); | ||
583 | // UUID AvatarID = UUID.Zero; | ||
584 | // UUID capUUID = UUID.Zero; | ||
585 | // | ||
586 | // // parse the path and search for the avatar with it registered | ||
587 | // if (UUID.TryParse(capuuid, out capUUID)) | ||
588 | // { | ||
589 | // lock (m_QueueUUIDAvatarMapping) | ||
590 | // { | ||
591 | // if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID)) | ||
592 | // { | ||
593 | // AvatarID = m_QueueUUIDAvatarMapping[capUUID]; | ||
594 | // } | ||
595 | // } | ||
596 | // | ||
597 | // if (AvatarID != UUID.Zero) | ||
598 | // { | ||
599 | // return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsForUser(AvatarID)); | ||
600 | // } | ||
601 | // else | ||
602 | // { | ||
603 | // responsedata["int_response_code"] = 404; | ||
604 | // responsedata["content_type"] = "text/plain"; | ||
605 | // responsedata["keepalive"] = false; | ||
606 | // responsedata["str_response_string"] = "Not Found"; | ||
607 | // responsedata["error_status_text"] = "Not Found"; | ||
608 | // responsedata["http_protocol_version"] = "HTTP/1.0"; | ||
609 | // return responsedata; | ||
610 | // // return 404 | ||
611 | // } | ||
612 | // } | ||
613 | // else | ||
614 | // { | ||
615 | // responsedata["int_response_code"] = 404; | ||
616 | // responsedata["content_type"] = "text/plain"; | ||
617 | // responsedata["keepalive"] = false; | ||
618 | // responsedata["str_response_string"] = "Not Found"; | ||
619 | // responsedata["error_status_text"] = "Not Found"; | ||
620 | // responsedata["http_protocol_version"] = "HTTP/1.0"; | ||
621 | // return responsedata; | ||
622 | // // return 404 | ||
623 | // } | ||
624 | // } | ||
625 | |||
626 | public OSD EventQueueFallBack(string path, OSD request, string endpoint) | ||
627 | { | ||
628 | // This is a fallback element to keep the client from loosing EventQueueGet | ||
629 | // Why does CAPS fail sometimes!? | ||
630 | m_log.Warn("[EVENTQUEUE]: In the Fallback handler! We lost the Queue in the rest handler!"); | ||
631 | string capuuid = path.Replace("/CAPS/EQG/",""); | ||
632 | capuuid = capuuid.Substring(0, capuuid.Length - 1); | ||
633 | |||
634 | // UUID AvatarID = UUID.Zero; | ||
635 | UUID capUUID = UUID.Zero; | ||
636 | if (UUID.TryParse(capuuid, out capUUID)) | ||
637 | { | ||
638 | /* Don't remove this yet code cleaners! | ||
639 | * Still testing this! | ||
640 | * | ||
641 | lock (m_QueueUUIDAvatarMapping) | ||
642 | { | ||
643 | if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID)) | ||
644 | { | ||
645 | AvatarID = m_QueueUUIDAvatarMapping[capUUID]; | ||
646 | } | ||
647 | } | ||
648 | |||
649 | |||
650 | if (AvatarID != UUID.Zero) | ||
651 | { | ||
652 | // Repair the CAP! | ||
653 | //OpenSim.Framework.Capabilities.Caps caps = m_scene.GetCapsHandlerForUser(AvatarID); | ||
654 | //string capsBase = "/CAPS/EQG/"; | ||
655 | //caps.RegisterHandler("EventQueueGet", | ||
656 | //new RestHTTPHandler("POST", capsBase + capUUID.ToString() + "/", | ||
657 | //delegate(Hashtable m_dhttpMethod) | ||
658 | //{ | ||
659 | // return ProcessQueue(m_dhttpMethod, AvatarID, caps); | ||
660 | //})); | ||
661 | // start new ID sequence. | ||
662 | Random rnd = new Random(System.Environment.TickCount); | ||
663 | lock (m_ids) | ||
664 | { | ||
665 | if (!m_ids.ContainsKey(AvatarID)) | ||
666 | m_ids.Add(AvatarID, rnd.Next(30000000)); | ||
667 | } | ||
668 | |||
669 | |||
670 | int thisID = 0; | ||
671 | lock (m_ids) | ||
672 | thisID = m_ids[AvatarID]; | ||
673 | |||
674 | BlockingLLSDQueue queue = GetQueue(AvatarID); | ||
675 | OSDArray array = new OSDArray(); | ||
676 | LLSD element = queue.Dequeue(15000); // 15s timeout | ||
677 | if (element == null) | ||
678 | { | ||
679 | |||
680 | array.Add(EventQueueHelper.KeepAliveEvent()); | ||
681 | } | ||
682 | else | ||
683 | { | ||
684 | array.Add(element); | ||
685 | while (queue.Count() > 0) | ||
686 | { | ||
687 | array.Add(queue.Dequeue(1)); | ||
688 | thisID++; | ||
689 | } | ||
690 | } | ||
691 | OSDMap events = new OSDMap(); | ||
692 | events.Add("events", array); | ||
693 | |||
694 | events.Add("id", new LLSDInteger(thisID)); | ||
695 | |||
696 | lock (m_ids) | ||
697 | { | ||
698 | m_ids[AvatarID] = thisID + 1; | ||
699 | } | ||
700 | |||
701 | return events; | ||
702 | } | ||
703 | else | ||
704 | { | ||
705 | return new LLSD(); | ||
706 | } | ||
707 | * | ||
708 | */ | ||
709 | } | ||
710 | else | ||
711 | { | ||
712 | //return new LLSD(); | ||
713 | } | ||
714 | |||
715 | return new OSDString("shutdown404!"); | ||
716 | } | ||
717 | |||
718 | public void DisableSimulator(ulong handle, UUID avatarID) | 514 | public void DisableSimulator(ulong handle, UUID avatarID) |
719 | { | 515 | { |
720 | OSD item = EventQueueHelper.DisableSimulator(handle); | 516 | OSD item = EventQueueHelper.DisableSimulator(handle); |
@@ -723,9 +519,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
723 | 519 | ||
724 | public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY) | 520 | public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY) |
725 | { | 521 | { |
522 | <<<<<<< HEAD | ||
726 | if (DebugLevel > 0) | 523 | if (DebugLevel > 0) |
727 | m_log.DebugFormat("{0} EnableSimulator. handle={1}, endPoint={2}, avatarID={3}", | 524 | m_log.DebugFormat("{0} EnableSimulator. handle={1}, endPoint={2}, avatarID={3}", |
728 | LogHeader, handle, endPoint, avatarID, regionSizeX, regionSizeY); | 525 | LogHeader, handle, endPoint, avatarID, regionSizeX, regionSizeY); |
526 | ======= | ||
527 | m_log.DebugFormat("{0} EnableSimulator. handle={1}, avatarID={2}, regionSize={3},{4}>", | ||
528 | LogHeader, handle, avatarID, regionSizeX, regionSizeY); | ||
529 | >>>>>>> avn/ubitvar | ||
729 | 530 | ||
730 | OSD item = EventQueueHelper.EnableSimulator(handle, endPoint, regionSizeX, regionSizeY); | 531 | OSD item = EventQueueHelper.EnableSimulator(handle, endPoint, regionSizeX, regionSizeY); |
731 | Enqueue(item, avatarID); | 532 | Enqueue(item, avatarID); |
@@ -734,10 +535,15 @@ namespace OpenSim.Region.ClientStack.Linden | |||
734 | public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath, | 535 | public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath, |
735 | ulong regionHandle, int regionSizeX, int regionSizeY) | 536 | ulong regionHandle, int regionSizeX, int regionSizeY) |
736 | { | 537 | { |
538 | <<<<<<< HEAD | ||
737 | if (DebugLevel > 0) | 539 | if (DebugLevel > 0) |
738 | m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, endPoint={2}, avatarID={3}", | 540 | m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, endPoint={2}, avatarID={3}", |
739 | LogHeader, regionHandle, endPoint, avatarID, regionSizeX, regionSizeY); | 541 | LogHeader, regionHandle, endPoint, avatarID, regionSizeX, regionSizeY); |
740 | 542 | ||
543 | ======= | ||
544 | m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, avatarID={2}, regionSize={3},{4}>", | ||
545 | LogHeader, regionHandle, avatarID, regionSizeX, regionSizeY); | ||
546 | >>>>>>> avn/ubitvar | ||
741 | OSD item = EventQueueHelper.EstablishAgentCommunication(avatarID, endPoint.ToString(), capsPath, regionHandle, regionSizeX, regionSizeY); | 547 | OSD item = EventQueueHelper.EstablishAgentCommunication(avatarID, endPoint.ToString(), capsPath, regionHandle, regionSizeX, regionSizeY); |
742 | Enqueue(item, avatarID); | 548 | Enqueue(item, avatarID); |
743 | } | 549 | } |
@@ -747,9 +553,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
747 | uint locationID, uint flags, string capsURL, | 553 | uint locationID, uint flags, string capsURL, |
748 | UUID avatarID, int regionSizeX, int regionSizeY) | 554 | UUID avatarID, int regionSizeX, int regionSizeY) |
749 | { | 555 | { |
556 | <<<<<<< HEAD | ||
750 | if (DebugLevel > 0) | 557 | if (DebugLevel > 0) |
751 | m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, endPoint={2}, avatarID={3}", | 558 | m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, endPoint={2}, avatarID={3}", |
752 | LogHeader, regionHandle, regionExternalEndPoint, avatarID, regionSizeX, regionSizeY); | 559 | LogHeader, regionHandle, regionExternalEndPoint, avatarID, regionSizeX, regionSizeY); |
560 | ======= | ||
561 | m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, avatarID={2}, regionSize={3},{4}>", | ||
562 | LogHeader, regionHandle, avatarID, regionSizeX, regionSizeY); | ||
563 | >>>>>>> avn/ubitvar | ||
753 | 564 | ||
754 | OSD item = EventQueueHelper.TeleportFinishEvent(regionHandle, simAccess, regionExternalEndPoint, | 565 | OSD item = EventQueueHelper.TeleportFinishEvent(regionHandle, simAccess, regionExternalEndPoint, |
755 | locationID, flags, capsURL, avatarID, regionSizeX, regionSizeY); | 566 | locationID, flags, capsURL, avatarID, regionSizeX, regionSizeY); |
@@ -760,9 +571,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
760 | IPEndPoint newRegionExternalEndPoint, | 571 | IPEndPoint newRegionExternalEndPoint, |
761 | string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY) | 572 | string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY) |
762 | { | 573 | { |
574 | <<<<<<< HEAD | ||
763 | if (DebugLevel > 0) | 575 | if (DebugLevel > 0) |
764 | m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>", | 576 | m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>", |
765 | LogHeader, handle, avatarID, regionSizeX, regionSizeY); | 577 | LogHeader, handle, avatarID, regionSizeX, regionSizeY); |
578 | ======= | ||
579 | m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>", | ||
580 | LogHeader, handle, avatarID, regionSizeX, regionSizeY); | ||
581 | >>>>>>> avn/ubitvar | ||
766 | 582 | ||
767 | OSD item = EventQueueHelper.CrossRegion(handle, pos, lookAt, newRegionExternalEndPoint, | 583 | OSD item = EventQueueHelper.CrossRegion(handle, pos, lookAt, newRegionExternalEndPoint, |
768 | capsURL, avatarID, sessionID, regionSizeX, regionSizeY); | 584 | capsURL, avatarID, sessionID, regionSizeX, regionSizeY); |
@@ -827,4 +643,4 @@ namespace OpenSim.Region.ClientStack.Linden | |||
827 | Enqueue(item, avatarID); | 643 | Enqueue(item, avatarID); |
828 | } | 644 | } |
829 | } | 645 | } |
830 | } \ No newline at end of file | 646 | } |