diff options
author | Melanie | 2012-05-19 13:34:44 +0100 |
---|---|---|
committer | Melanie | 2012-05-19 13:34:44 +0100 |
commit | ebd9d2618bc88eafdc0bbf86c9f1755476cc68e4 (patch) | |
tree | 2d63da14ca345487a27f2202b2490eae0d86b60c /OpenSim/Region/ClientStack | |
parent | Merge branch 'avination' into careminster (diff) | |
parent | Remove recent IRegionCombinerModule.IsMegaregion(). In theory, there can be ... (diff) | |
download | opensim-SC_OLD-ebd9d2618bc88eafdc0bbf86c9f1755476cc68e4.zip opensim-SC_OLD-ebd9d2618bc88eafdc0bbf86c9f1755476cc68e4.tar.gz opensim-SC_OLD-ebd9d2618bc88eafdc0bbf86c9f1755476cc68e4.tar.bz2 opensim-SC_OLD-ebd9d2618bc88eafdc0bbf86c9f1755476cc68e4.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/Framework/Scenes/Scene.cs
OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 100 |
1 files changed, 61 insertions, 39 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index a38d231..01ce194 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | |||
@@ -109,10 +109,11 @@ namespace OpenSim.Region.ClientStack.Linden | |||
109 | "Comms", | 109 | "Comms", |
110 | false, | 110 | false, |
111 | "debug eq", | 111 | "debug eq", |
112 | "debug eq [0|1]", | 112 | "debug eq [0|1|2]", |
113 | "Turn on event queue debugging", | 113 | "Turn on event queue debugging" |
114 | "debug eq 1 will turn on event queue debugging. This will log all outgoing event queue messages to clients.\n" | 114 | + "<= 0 - turns off all event queue logging" |
115 | + "debug eq 0 will turn off event queue debugging.", | 115 | + ">= 1 - turns on outgoing event logging" |
116 | + ">= 2 - turns on poll notification", | ||
116 | HandleDebugEq); | 117 | HandleDebugEq); |
117 | } | 118 | } |
118 | else | 119 | else |
@@ -235,19 +236,19 @@ namespace OpenSim.Region.ClientStack.Linden | |||
235 | // ClientClosed(client.AgentId); | 236 | // ClientClosed(client.AgentId); |
236 | // } | 237 | // } |
237 | 238 | ||
238 | private void ClientClosed(UUID AgentID, Scene scene) | 239 | private void ClientClosed(UUID agentID, Scene scene) |
239 | { | 240 | { |
240 | // m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", AgentID, m_scene.RegionInfo.RegionName); | 241 | // m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); |
241 | 242 | ||
242 | int count = 0; | 243 | int count = 0; |
243 | while (queues.ContainsKey(AgentID) && queues[AgentID].Count > 0 && count++ < 5) | 244 | while (queues.ContainsKey(agentID) && queues[agentID].Count > 0 && count++ < 5) |
244 | { | 245 | { |
245 | Thread.Sleep(1000); | 246 | Thread.Sleep(1000); |
246 | } | 247 | } |
247 | 248 | ||
248 | lock (queues) | 249 | lock (queues) |
249 | { | 250 | { |
250 | queues.Remove(AgentID); | 251 | queues.Remove(agentID); |
251 | } | 252 | } |
252 | 253 | ||
253 | List<UUID> removeitems = new List<UUID>(); | 254 | List<UUID> removeitems = new List<UUID>(); |
@@ -256,7 +257,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
256 | foreach (UUID ky in m_AvatarQueueUUIDMapping.Keys) | 257 | foreach (UUID ky in m_AvatarQueueUUIDMapping.Keys) |
257 | { | 258 | { |
258 | // m_log.DebugFormat("[EVENTQUEUE]: Found key {0} in m_AvatarQueueUUIDMapping while looking for {1}", ky, AgentID); | 259 | // m_log.DebugFormat("[EVENTQUEUE]: Found key {0} in m_AvatarQueueUUIDMapping while looking for {1}", ky, AgentID); |
259 | if (ky == AgentID) | 260 | if (ky == agentID) |
260 | { | 261 | { |
261 | removeitems.Add(ky); | 262 | removeitems.Add(ky); |
262 | } | 263 | } |
@@ -267,7 +268,12 @@ namespace OpenSim.Region.ClientStack.Linden | |||
267 | UUID eventQueueGetUuid = m_AvatarQueueUUIDMapping[ky]; | 268 | UUID eventQueueGetUuid = m_AvatarQueueUUIDMapping[ky]; |
268 | m_AvatarQueueUUIDMapping.Remove(ky); | 269 | m_AvatarQueueUUIDMapping.Remove(ky); |
269 | 270 | ||
270 | MainServer.Instance.RemovePollServiceHTTPHandler("","/CAPS/EQG/" + eventQueueGetUuid.ToString() + "/"); | 271 | string eqgPath = GenerateEqgCapPath(eventQueueGetUuid); |
272 | MainServer.Instance.RemovePollServiceHTTPHandler("", eqgPath); | ||
273 | |||
274 | // m_log.DebugFormat( | ||
275 | // "[EVENT QUEUE GET MODULE]: Removed EQG handler {0} for {1} in {2}", | ||
276 | // eqgPath, agentID, m_scene.RegionInfo.RegionName); | ||
271 | } | 277 | } |
272 | } | 278 | } |
273 | 279 | ||
@@ -281,7 +287,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
281 | { | 287 | { |
282 | searchval = m_QueueUUIDAvatarMapping[ky]; | 288 | searchval = m_QueueUUIDAvatarMapping[ky]; |
283 | 289 | ||
284 | if (searchval == AgentID) | 290 | if (searchval == agentID) |
285 | { | 291 | { |
286 | removeitems.Add(ky); | 292 | removeitems.Add(ky); |
287 | } | 293 | } |
@@ -305,6 +311,15 @@ namespace OpenSim.Region.ClientStack.Linden | |||
305 | //} | 311 | //} |
306 | } | 312 | } |
307 | 313 | ||
314 | /// <summary> | ||
315 | /// Generate an Event Queue Get handler path for the given eqg uuid. | ||
316 | /// </summary> | ||
317 | /// <param name='eqgUuid'></param> | ||
318 | private string GenerateEqgCapPath(UUID eqgUuid) | ||
319 | { | ||
320 | return string.Format("/CAPS/EQG/{0}/", eqgUuid); | ||
321 | } | ||
322 | |||
308 | public void OnRegisterCaps(UUID agentID, Caps caps) | 323 | public void OnRegisterCaps(UUID agentID, Caps caps) |
309 | { | 324 | { |
310 | // Register an event queue for the client | 325 | // Register an event queue for the client |
@@ -316,8 +331,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
316 | // Let's instantiate a Queue for this agent right now | 331 | // Let's instantiate a Queue for this agent right now |
317 | TryGetQueue(agentID); | 332 | TryGetQueue(agentID); |
318 | 333 | ||
319 | string capsBase = "/CAPS/EQG/"; | 334 | UUID eventQueueGetUUID; |
320 | UUID EventQueueGetUUID = UUID.Zero; | ||
321 | 335 | ||
322 | lock (m_AvatarQueueUUIDMapping) | 336 | lock (m_AvatarQueueUUIDMapping) |
323 | { | 337 | { |
@@ -325,37 +339,35 @@ namespace OpenSim.Region.ClientStack.Linden | |||
325 | if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) | 339 | if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) |
326 | { | 340 | { |
327 | //m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!"); | 341 | //m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!"); |
328 | EventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; | 342 | eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; |
329 | } | 343 | } |
330 | else | 344 | else |
331 | { | 345 | { |
332 | EventQueueGetUUID = UUID.Random(); | 346 | eventQueueGetUUID = UUID.Random(); |
333 | //m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!"); | 347 | //m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!"); |
334 | } | 348 | } |
335 | } | 349 | } |
336 | 350 | ||
337 | lock (m_QueueUUIDAvatarMapping) | 351 | lock (m_QueueUUIDAvatarMapping) |
338 | { | 352 | { |
339 | if (!m_QueueUUIDAvatarMapping.ContainsKey(EventQueueGetUUID)) | 353 | if (!m_QueueUUIDAvatarMapping.ContainsKey(eventQueueGetUUID)) |
340 | m_QueueUUIDAvatarMapping.Add(EventQueueGetUUID, agentID); | 354 | m_QueueUUIDAvatarMapping.Add(eventQueueGetUUID, agentID); |
341 | } | 355 | } |
342 | 356 | ||
343 | lock (m_AvatarQueueUUIDMapping) | 357 | lock (m_AvatarQueueUUIDMapping) |
344 | { | 358 | { |
345 | if (!m_AvatarQueueUUIDMapping.ContainsKey(agentID)) | 359 | if (!m_AvatarQueueUUIDMapping.ContainsKey(agentID)) |
346 | m_AvatarQueueUUIDMapping.Add(agentID, EventQueueGetUUID); | 360 | m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); |
347 | } | 361 | } |
348 | 362 | ||
363 | string eventQueueGetPath = GenerateEqgCapPath(eventQueueGetUUID); | ||
364 | |||
349 | // Register this as a caps handler | 365 | // Register this as a caps handler |
350 | // FIXME: Confusingly, we need to register separate as a capability so that the client is told about | 366 | // FIXME: Confusingly, we need to register separate as a capability so that the client is told about |
351 | // EventQueueGet when it receive capability information, but then we replace the rest handler immediately | 367 | // EventQueueGet when it receive capability information, but then we replace the rest handler immediately |
352 | // afterwards with the poll service. So for now, we'll pass a null instead to simplify code reading, but | 368 | // afterwards with the poll service. So for now, we'll pass a null instead to simplify code reading, but |
353 | // really it should be possible to directly register the poll handler as a capability. | 369 | // really it should be possible to directly register the poll handler as a capability. |
354 | caps.RegisterHandler( | 370 | caps.RegisterHandler("EventQueueGet", new RestHTTPHandler("POST", eventQueueGetPath, null)); |
355 | "EventQueueGet", | ||
356 | new RestHTTPHandler( | ||
357 | "POST", capsBase + EventQueueGetUUID.ToString() + "/", null)); | ||
358 | |||
359 | // delegate(Hashtable m_dhttpMethod) | 371 | // delegate(Hashtable m_dhttpMethod) |
360 | // { | 372 | // { |
361 | // return ProcessQueue(m_dhttpMethod, agentID, caps); | 373 | // return ProcessQueue(m_dhttpMethod, agentID, caps); |
@@ -364,9 +376,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
364 | // This will persist this beyond the expiry of the caps handlers | 376 | // This will persist this beyond the expiry of the caps handlers |
365 | // TODO: Add EventQueueGet name/description for diagnostics | 377 | // TODO: Add EventQueueGet name/description for diagnostics |
366 | MainServer.Instance.AddPollServiceHTTPHandler( | 378 | MainServer.Instance.AddPollServiceHTTPHandler( |
367 | capsBase + EventQueueGetUUID.ToString() + "/", | 379 | eventQueueGetPath, |
368 | new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); | 380 | new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); |
369 | 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 | |||
370 | Random rnd = new Random(Environment.TickCount); | 386 | Random rnd = new Random(Environment.TickCount); |
371 | lock (m_ids) | 387 | lock (m_ids) |
372 | { | 388 | { |
@@ -388,9 +404,25 @@ namespace OpenSim.Region.ClientStack.Linden | |||
388 | return false; | 404 | return false; |
389 | } | 405 | } |
390 | 406 | ||
407 | /// <summary> | ||
408 | /// Logs a debug line for an outbound event queue message if appropriate. | ||
409 | /// </summary> | ||
410 | /// <param name='element'>Element containing message</param> | ||
411 | private void LogOutboundDebugMessage(OSD element, UUID agentId) | ||
412 | { | ||
413 | if (element is OSDMap) | ||
414 | { | ||
415 | OSDMap ev = (OSDMap)element; | ||
416 | m_log.DebugFormat( | ||
417 | "Eq OUT {0,-30} to {1,-20} {2,-20}", | ||
418 | ev["message"], m_scene.GetScenePresence(agentId).Name, m_scene.RegionInfo.RegionName); | ||
419 | } | ||
420 | } | ||
421 | |||
391 | public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request) | 422 | public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request) |
392 | { | 423 | { |
393 | // m_log.DebugFormat("[EVENT QUEUE GET MODULE]: Invoked GetEvents() for {0}", pAgentId); | 424 | if (DebugLevel >= 2) |
425 | m_log.DebugFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); | ||
394 | 426 | ||
395 | Queue<OSD> queue = TryGetQueue(pAgentId); | 427 | Queue<OSD> queue = TryGetQueue(pAgentId); |
396 | OSD element; | 428 | OSD element; |
@@ -414,13 +446,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
414 | } | 446 | } |
415 | else | 447 | else |
416 | { | 448 | { |
417 | if (DebugLevel > 0 && element is OSDMap) | 449 | if (DebugLevel > 0) |
418 | { | 450 | LogOutboundDebugMessage(element, pAgentId); |
419 | OSDMap ev = (OSDMap)element; | ||
420 | m_log.DebugFormat( | ||
421 | "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", | ||
422 | ev["message"], m_scene.GetScenePresence(pAgentId).Name); | ||
423 | } | ||
424 | 451 | ||
425 | array.Add(element); | 452 | array.Add(element); |
426 | 453 | ||
@@ -430,13 +457,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
430 | { | 457 | { |
431 | element = queue.Dequeue(); | 458 | element = queue.Dequeue(); |
432 | 459 | ||
433 | if (DebugLevel > 0 && element is OSDMap) | 460 | if (DebugLevel > 0) |
434 | { | 461 | LogOutboundDebugMessage(element, pAgentId); |
435 | OSDMap ev = (OSDMap)element; | ||
436 | m_log.DebugFormat( | ||
437 | "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", | ||
438 | ev["message"], m_scene.GetScenePresence(pAgentId).Name); | ||
439 | } | ||
440 | 462 | ||
441 | array.Add(element); | 463 | array.Add(element); |
442 | thisID++; | 464 | thisID++; |