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.cs85
1 files changed, 39 insertions, 46 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
index d6689d4..e98a470 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
@@ -65,6 +65,13 @@ namespace OpenSim.Region.ClientStack.Linden
65 /// </value> 65 /// </value>
66 public int DebugLevel { get; set; } 66 public int DebugLevel { get; set; }
67 67
68 // Viewer post requests timeout in 60 secs
69 // https://bitbucket.org/lindenlab/viewer-release/src/421c20423df93d650cc305dc115922bb30040999/indra/llmessage/llhttpclient.cpp?at=default#cl-44
70 //
71 private const int VIEWER_TIMEOUT = 60 * 1000;
72 // Just to be safe, we work on a 10 sec shorter cycle
73 private const int SERVER_EQ_TIME_NO_EVENTS = VIEWER_TIMEOUT - (10 * 1000);
74
68 protected Scene m_scene; 75 protected Scene m_scene;
69 76
70 private Dictionary<UUID, int> m_ids = new Dictionary<UUID, int>(); 77 private Dictionary<UUID, int> m_ids = new Dictionary<UUID, int>();
@@ -252,29 +259,32 @@ namespace OpenSim.Region.ClientStack.Linden
252 259
253 List<UUID> removeitems = new List<UUID>(); 260 List<UUID> removeitems = new List<UUID>();
254 lock (m_AvatarQueueUUIDMapping) 261 lock (m_AvatarQueueUUIDMapping)
255 { 262 m_AvatarQueueUUIDMapping.Remove(agentID);
256 foreach (UUID ky in m_AvatarQueueUUIDMapping.Keys)
257 {
258// m_log.DebugFormat("[EVENTQUEUE]: Found key {0} in m_AvatarQueueUUIDMapping while looking for {1}", ky, AgentID);
259 if (ky == agentID)
260 {
261 removeitems.Add(ky);
262 }
263 }
264 263
265 foreach (UUID ky in removeitems) 264// lock (m_AvatarQueueUUIDMapping)
266 { 265// {
267 UUID eventQueueGetUuid = m_AvatarQueueUUIDMapping[ky]; 266// foreach (UUID ky in m_AvatarQueueUUIDMapping.Keys)
268 m_AvatarQueueUUIDMapping.Remove(ky); 267// {
269 268//// m_log.DebugFormat("[EVENTQUEUE]: Found key {0} in m_AvatarQueueUUIDMapping while looking for {1}", ky, AgentID);
270 string eqgPath = GenerateEqgCapPath(eventQueueGetUuid); 269// if (ky == agentID)
271 MainServer.Instance.RemovePollServiceHTTPHandler("", eqgPath); 270// {
272 271// removeitems.Add(ky);
273// m_log.DebugFormat( 272// }
274// "[EVENT QUEUE GET MODULE]: Removed EQG handler {0} for {1} in {2}", 273// }
275// eqgPath, agentID, m_scene.RegionInfo.RegionName); 274//
276 } 275// foreach (UUID ky in removeitems)
277 } 276// {
277// UUID eventQueueGetUuid = m_AvatarQueueUUIDMapping[ky];
278// m_AvatarQueueUUIDMapping.Remove(ky);
279//
280// string eqgPath = GenerateEqgCapPath(eventQueueGetUuid);
281// MainServer.Instance.RemovePollServiceHTTPHandler("", eqgPath);
282//
283//// m_log.DebugFormat(
284//// "[EVENT QUEUE GET MODULE]: Removed EQG handler {0} for {1} in {2}",
285//// eqgPath, agentID, m_scene.RegionInfo.RegionName);
286// }
287// }
278 288
279 UUID searchval = UUID.Zero; 289 UUID searchval = UUID.Zero;
280 290
@@ -359,29 +369,9 @@ namespace OpenSim.Region.ClientStack.Linden
359 m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); 369 m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID);
360 } 370 }
361 371
362 string eventQueueGetPath = GenerateEqgCapPath(eventQueueGetUUID); 372 caps.RegisterPollHandler(
363 373 "EventQueueGet",
364 // Register this as a caps handler 374 new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS));
365 // FIXME: Confusingly, we need to register separate as a capability so that the client is told about
366 // EventQueueGet when it receive capability information, but then we replace the rest handler immediately
367 // afterwards with the poll service. So for now, we'll pass a null instead to simplify code reading, but
368 // really it should be possible to directly register the poll handler as a capability.
369 caps.RegisterHandler(
370 "EventQueueGet", new RestHTTPHandler("POST", eventQueueGetPath, null, "EventQueueGet", null));
371// delegate(Hashtable m_dhttpMethod)
372// {
373// return ProcessQueue(m_dhttpMethod, agentID, caps);
374// }));
375
376 // This will persist this beyond the expiry of the caps handlers
377 // TODO: Add EventQueueGet name/description for diagnostics
378 MainServer.Instance.AddPollServiceHTTPHandler(
379 eventQueueGetPath,
380 new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID, 40000));
381
382// m_log.DebugFormat(
383// "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}",
384// eventQueueGetPath, agentID, m_scene.RegionInfo.RegionName);
385 375
386 Random rnd = new Random(Environment.TickCount); 376 Random rnd = new Random(Environment.TickCount);
387 lock (m_ids) 377 lock (m_ids)
@@ -399,7 +389,10 @@ namespace OpenSim.Region.ClientStack.Linden
399 Queue<OSD> queue = GetQueue(agentID); 389 Queue<OSD> queue = GetQueue(agentID);
400 if (queue != null) 390 if (queue != null)
401 lock (queue) 391 lock (queue)
392 {
393 //m_log.WarnFormat("POLLED FOR EVENTS BY {0} in {1} -- {2}", agentID, m_scene.RegionInfo.RegionName, queue.Count);
402 return queue.Count > 0; 394 return queue.Count > 0;
395 }
403 396
404 return false; 397 return false;
405 } 398 }
@@ -422,7 +415,7 @@ namespace OpenSim.Region.ClientStack.Linden
422 public Hashtable GetEvents(UUID requestID, UUID pAgentId) 415 public Hashtable GetEvents(UUID requestID, UUID pAgentId)
423 { 416 {
424 if (DebugLevel >= 2) 417 if (DebugLevel >= 2)
425 m_log.DebugFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); 418 m_log.WarnFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName);
426 419
427 Queue<OSD> queue = TryGetQueue(pAgentId); 420 Queue<OSD> queue = TryGetQueue(pAgentId);
428 OSD element; 421 OSD element;