diff options
author | onefang | 2019-05-19 21:24:15 +1000 |
---|---|---|
committer | onefang | 2019-05-19 21:24:15 +1000 |
commit | 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb (patch) | |
tree | a9fbc62df9eb2d1d9ba2698d8552eae71eca20d8 /OpenSim/Region/ClientStack/Linden/Caps/EventQueue | |
parent | Add a build script. (diff) | |
download | opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.zip opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.gz opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.bz2 opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.xz |
Dump OpenSim 0.9.0.1 into it's own branch.
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue')
3 files changed, 239 insertions, 406 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 9b9f6a7..7c9a1c4 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | |||
@@ -74,13 +74,12 @@ namespace OpenSim.Region.ClientStack.Linden | |||
74 | private const int SERVER_EQ_TIME_NO_EVENTS = VIEWER_TIMEOUT - (10 * 1000); | 74 | private const int SERVER_EQ_TIME_NO_EVENTS = VIEWER_TIMEOUT - (10 * 1000); |
75 | 75 | ||
76 | protected Scene m_scene; | 76 | protected Scene m_scene; |
77 | 77 | ||
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 |
85 | public virtual void Initialise(IConfigSource config) | 84 | public virtual void Initialise(IConfigSource config) |
86 | { | 85 | { |
@@ -171,7 +170,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
171 | foreach (KeyValuePair<UUID, Queue<OSD>> kvp in queues) | 170 | foreach (KeyValuePair<UUID, Queue<OSD>> kvp in queues) |
172 | { | 171 | { |
173 | MainConsole.Instance.OutputFormat( | 172 | MainConsole.Instance.OutputFormat( |
174 | "For agent {0} there are {1} messages queued for send.", | 173 | "For agent {0} there are {1} messages queued for send.", |
175 | kvp.Key, kvp.Value.Count); | 174 | kvp.Key, kvp.Value.Count); |
176 | } | 175 | } |
177 | } | 176 | } |
@@ -190,7 +189,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
190 | { | 189 | { |
191 | if (DebugLevel > 0) | 190 | if (DebugLevel > 0) |
192 | m_log.DebugFormat( | 191 | m_log.DebugFormat( |
193 | "[EVENTQUEUE]: Adding new queue for agent {0} in region {1}", | 192 | "[EVENTQUEUE]: Adding new queue for agent {0} in region {1}", |
194 | agentId, m_scene.RegionInfo.RegionName); | 193 | agentId, m_scene.RegionInfo.RegionName); |
195 | 194 | ||
196 | queues[agentId] = new Queue<OSD>(); | 195 | queues[agentId] = new Queue<OSD>(); |
@@ -201,6 +200,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
201 | } | 200 | } |
202 | 201 | ||
203 | /// <summary> | 202 | /// <summary> |
203 | |||
204 | /// May return a null queue | 204 | /// May return a null queue |
205 | /// </summary> | 205 | /// </summary> |
206 | /// <param name="agentId"></param> | 206 | /// <param name="agentId"></param> |
@@ -231,26 +231,20 @@ namespace OpenSim.Region.ClientStack.Linden | |||
231 | lock (queue) | 231 | lock (queue) |
232 | queue.Enqueue(ev); | 232 | queue.Enqueue(ev); |
233 | } | 233 | } |
234 | else if (DebugLevel > 0) | 234 | else |
235 | { | 235 | { |
236 | ScenePresence sp = m_scene.GetScenePresence(avatarID); | ||
237 | |||
238 | // This assumes that an NPC should never have a queue. | ||
239 | if (sp != null && sp.PresenceType != PresenceType.Npc) | ||
240 | { | ||
241 | OSDMap evMap = (OSDMap)ev; | 236 | OSDMap evMap = (OSDMap)ev; |
242 | m_log.WarnFormat( | 237 | m_log.WarnFormat( |
243 | "[EVENTQUEUE]: (Enqueue) No queue found for agent {0} {1} when placing message {2} in region {3}", | 238 | "[EVENTQUEUE]: (Enqueue) No queue found for agent {0} when placing message {1} in region {2}", |
244 | sp.Name, sp.UUID, evMap["message"], m_scene.Name); | 239 | avatarID, evMap["message"], m_scene.Name); |
245 | } | ||
246 | } | 240 | } |
247 | } | 241 | } |
248 | catch (NullReferenceException e) | 242 | catch (NullReferenceException e) |
249 | { | 243 | { |
250 | m_log.Error("[EVENTQUEUE] Caught exception: " + e); | 244 | m_log.Error("[EVENTQUEUE] Caught exception: " + e); |
251 | return false; | 245 | return false; |
252 | } | 246 | } |
253 | 247 | ||
254 | return true; | 248 | return true; |
255 | } | 249 | } |
256 | 250 | ||
@@ -263,28 +257,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
263 | lock (queues) | 257 | lock (queues) |
264 | queues.Remove(agentID); | 258 | queues.Remove(agentID); |
265 | 259 | ||
266 | List<UUID> removeitems = new List<UUID>(); | ||
267 | lock (m_AvatarQueueUUIDMapping) | 260 | lock (m_AvatarQueueUUIDMapping) |
268 | m_AvatarQueueUUIDMapping.Remove(agentID); | 261 | m_AvatarQueueUUIDMapping.Remove(agentID); |
269 | 262 | ||
270 | UUID searchval = UUID.Zero; | 263 | lock (m_ids) |
271 | |||
272 | removeitems.Clear(); | ||
273 | |||
274 | lock (m_QueueUUIDAvatarMapping) | ||
275 | { | 264 | { |
276 | foreach (UUID ky in m_QueueUUIDAvatarMapping.Keys) | 265 | if (!m_ids.ContainsKey(agentID)) |
277 | { | 266 | 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 | } | 267 | } |
289 | 268 | ||
290 | // m_log.DebugFormat("[EVENTQUEUE]: Deleted queues for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); | 269 | // m_log.DebugFormat("[EVENTQUEUE]: Deleted queues for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); |
@@ -309,55 +288,95 @@ namespace OpenSim.Region.ClientStack.Linden | |||
309 | "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}", | 288 | "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}", |
310 | agentID, caps, m_scene.RegionInfo.RegionName); | 289 | agentID, caps, m_scene.RegionInfo.RegionName); |
311 | 290 | ||
312 | // Let's instantiate a Queue for this agent right now | ||
313 | TryGetQueue(agentID); | ||
314 | |||
315 | UUID eventQueueGetUUID; | 291 | UUID eventQueueGetUUID; |
292 | Queue<OSD> queue; | ||
293 | Random rnd = new Random(Environment.TickCount); | ||
294 | int nrnd = rnd.Next(30000000); | ||
295 | if (nrnd < 0) | ||
296 | nrnd = -nrnd; | ||
316 | 297 | ||
317 | lock (m_AvatarQueueUUIDMapping) | 298 | lock (queues) |
318 | { | 299 | { |
319 | // Reuse open queues. The client does! | 300 | if (queues.ContainsKey(agentID)) |
320 | if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) | 301 | queue = queues[agentID]; |
302 | else | ||
303 | queue = null; | ||
304 | |||
305 | if (queue == null) | ||
321 | { | 306 | { |
322 | //m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!"); | 307 | queue = new Queue<OSD>(); |
323 | eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; | 308 | queues[agentID] = queue; |
309 | |||
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) | ||
317 | { | ||
318 | eventQueueGetUUID = UUID.Random(); | ||
319 | if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) | ||
320 | { | ||
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); | ||
326 | } | ||
327 | lock (m_ids) | ||
328 | { | ||
329 | if (!m_ids.ContainsKey(agentID)) | ||
330 | m_ids.Add(agentID, nrnd); | ||
331 | else | ||
332 | m_ids[agentID] = nrnd; | ||
333 | } | ||
324 | } | 334 | } |
325 | else | 335 | else |
326 | { | 336 | { |
327 | eventQueueGetUUID = UUID.Random(); | 337 | // push markers to handle old responses still waiting |
328 | //m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!"); | 338 | // this will cost at most viewer getting two forced noevents |
339 | // even being a new queue better be safe | ||
340 | queue.Enqueue(null); | ||
341 | queue.Enqueue(null); // one should be enough | ||
342 | |||
343 | // reuse or not to reuse TODO FIX | ||
344 | lock (m_AvatarQueueUUIDMapping) | ||
345 | { | ||
346 | // Reuse open queues. The client does! | ||
347 | // Its reuse caps path not queues those are been reused already | ||
348 | if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) | ||
349 | { | ||
350 | m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!"); | ||
351 | eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; | ||
352 | } | ||
353 | else | ||
354 | { | ||
355 | eventQueueGetUUID = UUID.Random(); | ||
356 | m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); | ||
357 | m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!"); | ||
358 | } | ||
359 | } | ||
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 | } | ||
329 | } | 370 | } |
330 | } | 371 | } |
331 | 372 | ||
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( | 373 | caps.RegisterPollHandler( |
345 | "EventQueueGet", | 374 | "EventQueueGet", |
346 | new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS)); | 375 | 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 | } | 376 | } |
355 | 377 | ||
356 | public bool HasEvents(UUID requestID, UUID agentID) | 378 | public bool HasEvents(UUID requestID, UUID agentID) |
357 | { | 379 | { |
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); | 380 | Queue<OSD> queue = GetQueue(agentID); |
362 | if (queue != null) | 381 | if (queue != null) |
363 | lock (queue) | 382 | lock (queue) |
@@ -366,7 +385,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
366 | return queue.Count > 0; | 385 | return queue.Count > 0; |
367 | } | 386 | } |
368 | 387 | ||
369 | return false; | 388 | //m_log.WarnFormat("POLLED FOR EVENTS BY {0} unknown agent", agentID); |
389 | return true; | ||
370 | } | 390 | } |
371 | 391 | ||
372 | /// <summary> | 392 | /// <summary> |
@@ -383,6 +403,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
383 | ev["message"], m_scene.GetScenePresence(agentId).Name, m_scene.Name); | 403 | ev["message"], m_scene.GetScenePresence(agentId).Name, m_scene.Name); |
384 | } | 404 | } |
385 | } | 405 | } |
406 | public void Drop(UUID requestID, UUID pAgentId) | ||
407 | { | ||
408 | // do nothing for now, hope client close will do it | ||
409 | } | ||
386 | 410 | ||
387 | public Hashtable GetEvents(UUID requestID, UUID pAgentId) | 411 | public Hashtable GetEvents(UUID requestID, UUID pAgentId) |
388 | { | 412 | { |
@@ -395,55 +419,65 @@ namespace OpenSim.Region.ClientStack.Linden | |||
395 | return NoEvents(requestID, pAgentId); | 419 | return NoEvents(requestID, pAgentId); |
396 | } | 420 | } |
397 | 421 | ||
398 | OSD element; | 422 | OSD element = null;; |
423 | OSDArray array = new OSDArray(); | ||
424 | int thisID = 0; | ||
425 | bool negativeID = false; | ||
426 | |||
399 | lock (queue) | 427 | lock (queue) |
400 | { | 428 | { |
401 | if (queue.Count == 0) | 429 | if (queue.Count == 0) |
402 | return NoEvents(requestID, pAgentId); | 430 | 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 | 431 | ||
410 | OSDArray array = new OSDArray(); | 432 | lock (m_ids) |
411 | if (element == null) // didn't have an event in 15s | 433 | thisID = m_ids[pAgentId]; |
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 | 434 | ||
422 | array.Add(element); | 435 | if (thisID < 0) |
436 | { | ||
437 | negativeID = true; | ||
438 | thisID = -thisID; | ||
439 | } | ||
423 | 440 | ||
424 | lock (queue) | 441 | while (queue.Count > 0) |
425 | { | 442 | { |
426 | while (queue.Count > 0) | 443 | element = queue.Dequeue(); |
427 | { | 444 | // add elements until a marker is found |
428 | element = queue.Dequeue(); | 445 | // so they get into a response |
446 | if (element == null) | ||
447 | break; | ||
448 | if (DebugLevel > 0) | ||
449 | LogOutboundDebugMessage(element, pAgentId); | ||
450 | array.Add(element); | ||
451 | thisID++; | ||
452 | } | ||
453 | } | ||
429 | 454 | ||
430 | if (DebugLevel > 0) | 455 | OSDMap events = null; |
431 | LogOutboundDebugMessage(element, pAgentId); | ||
432 | 456 | ||
433 | array.Add(element); | 457 | if (array.Count > 0) |
434 | thisID++; | 458 | { |
435 | } | 459 | events = new OSDMap(); |
436 | } | 460 | events.Add("events", array); |
461 | events.Add("id", new OSDInteger(thisID)); | ||
437 | } | 462 | } |
438 | 463 | ||
439 | OSDMap events = new OSDMap(); | 464 | if (negativeID && element == null) |
440 | events.Add("events", array); | 465 | { |
466 | Random rnd = new Random(Environment.TickCount); | ||
467 | thisID = rnd.Next(30000000); | ||
468 | if (thisID < 0) | ||
469 | thisID = -thisID; | ||
470 | } | ||
441 | 471 | ||
442 | events.Add("id", new OSDInteger(thisID)); | ||
443 | lock (m_ids) | 472 | lock (m_ids) |
444 | { | 473 | { |
445 | m_ids[pAgentId] = thisID + 1; | 474 | m_ids[pAgentId] = thisID + 1; |
446 | } | 475 | } |
476 | |||
477 | // if there where no elements before a marker send a NoEvents | ||
478 | if (array.Count == 0) | ||
479 | return NoEvents(requestID, pAgentId); | ||
480 | |||
447 | Hashtable responsedata = new Hashtable(); | 481 | Hashtable responsedata = new Hashtable(); |
448 | responsedata["int_response_code"] = 200; | 482 | responsedata["int_response_code"] = 200; |
449 | responsedata["content_type"] = "application/xml"; | 483 | responsedata["content_type"] = "application/xml"; |
@@ -461,266 +495,18 @@ namespace OpenSim.Region.ClientStack.Linden | |||
461 | responsedata["content_type"] = "text/plain"; | 495 | responsedata["content_type"] = "text/plain"; |
462 | responsedata["keepalive"] = false; | 496 | responsedata["keepalive"] = false; |
463 | responsedata["reusecontext"] = false; | 497 | responsedata["reusecontext"] = false; |
464 | responsedata["str_response_string"] = "Upstream error: "; | 498 | responsedata["str_response_string"] = "<llsd></llsd>"; |
465 | responsedata["error_status_text"] = "Upstream error:"; | 499 | responsedata["error_status_text"] = "<llsd></llsd>"; |
466 | responsedata["http_protocol_version"] = "HTTP/1.0"; | 500 | responsedata["http_protocol_version"] = "HTTP/1.0"; |
467 | return responsedata; | 501 | return responsedata; |
468 | } | 502 | } |
469 | 503 | /* this is not a event message | |
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) | 504 | public void DisableSimulator(ulong handle, UUID avatarID) |
719 | { | 505 | { |
720 | OSD item = EventQueueHelper.DisableSimulator(handle); | 506 | OSD item = EventQueueHelper.DisableSimulator(handle); |
721 | Enqueue(item, avatarID); | 507 | Enqueue(item, avatarID); |
722 | } | 508 | } |
723 | 509 | */ | |
724 | public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY) | 510 | public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY) |
725 | { | 511 | { |
726 | if (DebugLevel > 0) | 512 | if (DebugLevel > 0) |
@@ -732,7 +518,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
732 | } | 518 | } |
733 | 519 | ||
734 | public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath, | 520 | public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath, |
735 | ulong regionHandle, int regionSizeX, int regionSizeY) | 521 | ulong regionHandle, int regionSizeX, int regionSizeY) |
736 | { | 522 | { |
737 | if (DebugLevel > 0) | 523 | if (DebugLevel > 0) |
738 | m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, endPoint={2}, avatarID={3}", | 524 | m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, endPoint={2}, avatarID={3}", |
@@ -742,9 +528,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
742 | Enqueue(item, avatarID); | 528 | Enqueue(item, avatarID); |
743 | } | 529 | } |
744 | 530 | ||
745 | public virtual void TeleportFinishEvent(ulong regionHandle, byte simAccess, | 531 | public virtual void TeleportFinishEvent(ulong regionHandle, byte simAccess, |
746 | IPEndPoint regionExternalEndPoint, | 532 | IPEndPoint regionExternalEndPoint, |
747 | uint locationID, uint flags, string capsURL, | 533 | uint locationID, uint flags, string capsURL, |
748 | UUID avatarID, int regionSizeX, int regionSizeY) | 534 | UUID avatarID, int regionSizeX, int regionSizeY) |
749 | { | 535 | { |
750 | if (DebugLevel > 0) | 536 | if (DebugLevel > 0) |
@@ -774,33 +560,40 @@ namespace OpenSim.Region.ClientStack.Linden | |||
774 | uint timeStamp, bool offline, int parentEstateID, Vector3 position, | 560 | uint timeStamp, bool offline, int parentEstateID, Vector3 position, |
775 | uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket) | 561 | uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket) |
776 | { | 562 | { |
777 | OSD item = EventQueueHelper.ChatterboxInvitation(sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog, | 563 | OSD item = EventQueueHelper.ChatterboxInvitation(sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog, |
778 | timeStamp, offline, parentEstateID, position, ttl, transactionID, | 564 | timeStamp, offline, parentEstateID, position, ttl, transactionID, |
779 | fromGroup, binaryBucket); | 565 | fromGroup, binaryBucket); |
780 | Enqueue(item, toAgent); | 566 | Enqueue(item, toAgent); |
781 | //m_log.InfoFormat("########### eq ChatterboxInvitation #############\n{0}", item); | 567 | //m_log.InfoFormat("########### eq ChatterboxInvitation #############\n{0}", item); |
782 | 568 | ||
783 | } | 569 | } |
784 | 570 | ||
785 | public void ChatterBoxSessionAgentListUpdates(UUID sessionID, UUID fromAgent, UUID anotherAgent, bool canVoiceChat, | 571 | public void ChatterBoxSessionAgentListUpdates(UUID sessionID, UUID fromAgent, UUID toAgent, bool canVoiceChat, |
786 | bool isModerator, bool textMute) | 572 | bool isModerator, bool textMute, bool isEnterorLeave) |
787 | { | 573 | { |
788 | OSD item = EventQueueHelper.ChatterBoxSessionAgentListUpdates(sessionID, fromAgent, canVoiceChat, | 574 | OSD item = EventQueueHelper.ChatterBoxSessionAgentListUpdates(sessionID, fromAgent, canVoiceChat, |
789 | isModerator, textMute); | 575 | isModerator, textMute, isEnterorLeave); |
790 | Enqueue(item, fromAgent); | 576 | Enqueue(item, toAgent); |
791 | //m_log.InfoFormat("########### eq ChatterBoxSessionAgentListUpdates #############\n{0}", item); | 577 | //m_log.InfoFormat("########### eq ChatterBoxSessionAgentListUpdates #############\n{0}", item); |
792 | } | 578 | } |
793 | 579 | ||
580 | public void ChatterBoxForceClose(UUID toAgent, UUID sessionID, string reason) | ||
581 | { | ||
582 | OSD item = EventQueueHelper.ChatterBoxForceClose(sessionID, reason); | ||
583 | |||
584 | Enqueue(item, toAgent); | ||
585 | } | ||
586 | |||
794 | public void ParcelProperties(ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID) | 587 | public void ParcelProperties(ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID) |
795 | { | 588 | { |
796 | OSD item = EventQueueHelper.ParcelProperties(parcelPropertiesMessage); | 589 | OSD item = EventQueueHelper.ParcelProperties(parcelPropertiesMessage); |
797 | Enqueue(item, avatarID); | 590 | Enqueue(item, avatarID); |
798 | } | 591 | } |
799 | 592 | ||
800 | public void GroupMembership(AgentGroupDataUpdatePacket groupUpdate, UUID avatarID) | 593 | public void GroupMembershipData(UUID receiverAgent, GroupMembershipData[] data) |
801 | { | 594 | { |
802 | OSD item = EventQueueHelper.GroupMembership(groupUpdate); | 595 | OSD item = EventQueueHelper.GroupMembershipData(receiverAgent, data); |
803 | Enqueue(item, avatarID); | 596 | Enqueue(item, receiverAgent); |
804 | } | 597 | } |
805 | 598 | ||
806 | public void QueryReply(PlacesReplyPacket groupUpdate, UUID avatarID) | 599 | public void QueryReply(PlacesReplyPacket groupUpdate, UUID avatarID) |
@@ -827,4 +620,4 @@ namespace OpenSim.Region.ClientStack.Linden | |||
827 | Enqueue(item, avatarID); | 620 | Enqueue(item, avatarID); |
828 | } | 621 | } |
829 | } | 622 | } |
830 | } \ No newline at end of file | 623 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs index 384af74..461f776 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs | |||
@@ -32,6 +32,8 @@ using OpenMetaverse.Packets; | |||
32 | using OpenMetaverse.StructuredData; | 32 | using OpenMetaverse.StructuredData; |
33 | using OpenMetaverse.Messages.Linden; | 33 | using OpenMetaverse.Messages.Linden; |
34 | 34 | ||
35 | using OpenSim.Framework; | ||
36 | |||
35 | namespace OpenSim.Region.ClientStack.Linden | 37 | namespace OpenSim.Region.ClientStack.Linden |
36 | { | 38 | { |
37 | public class EventQueueHelper | 39 | public class EventQueueHelper |
@@ -76,9 +78,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
76 | 78 | ||
77 | llsdSimInfo.Add("Handle", new OSDBinary(ulongToByteArray(handle))); | 79 | llsdSimInfo.Add("Handle", new OSDBinary(ulongToByteArray(handle))); |
78 | llsdSimInfo.Add("IP", new OSDBinary(endPoint.Address.GetAddressBytes())); | 80 | llsdSimInfo.Add("IP", new OSDBinary(endPoint.Address.GetAddressBytes())); |
79 | llsdSimInfo.Add("Port", new OSDInteger(endPoint.Port)); | 81 | llsdSimInfo.Add("Port", OSD.FromInteger(endPoint.Port)); |
80 | llsdSimInfo.Add("RegionSizeX", OSD.FromUInteger((uint) regionSizeX)); | 82 | llsdSimInfo.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX)); |
81 | llsdSimInfo.Add("RegionSizeY", OSD.FromUInteger((uint) regionSizeY)); | 83 | llsdSimInfo.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY)); |
82 | 84 | ||
83 | OSDArray arr = new OSDArray(1); | 85 | OSDArray arr = new OSDArray(1); |
84 | arr.Add(llsdSimInfo); | 86 | arr.Add(llsdSimInfo); |
@@ -88,7 +90,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
88 | 90 | ||
89 | return BuildEvent("EnableSimulator", llsdBody); | 91 | return BuildEvent("EnableSimulator", llsdBody); |
90 | } | 92 | } |
91 | 93 | /* | |
92 | public static OSD DisableSimulator(ulong handle) | 94 | public static OSD DisableSimulator(ulong handle) |
93 | { | 95 | { |
94 | //OSDMap llsdSimInfo = new OSDMap(1); | 96 | //OSDMap llsdSimInfo = new OSDMap(1); |
@@ -103,7 +105,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
103 | 105 | ||
104 | return BuildEvent("DisableSimulator", llsdBody); | 106 | return BuildEvent("DisableSimulator", llsdBody); |
105 | } | 107 | } |
106 | 108 | */ | |
107 | public static OSD CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, | 109 | public static OSD CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, |
108 | IPEndPoint newRegionExternalEndPoint, | 110 | IPEndPoint newRegionExternalEndPoint, |
109 | string capsURL, UUID agentID, UUID sessionID, | 111 | string capsURL, UUID agentID, UUID sessionID, |
@@ -157,6 +159,12 @@ namespace OpenSim.Region.ClientStack.Linden | |||
157 | uint locationID, uint flags, string capsURL, UUID agentID, | 159 | uint locationID, uint flags, string capsURL, UUID agentID, |
158 | int regionSizeX, int regionSizeY) | 160 | int regionSizeX, int regionSizeY) |
159 | { | 161 | { |
162 | // not sure why flags get overwritten here | ||
163 | if ((flags & (uint)TeleportFlags.IsFlying) != 0) | ||
164 | flags = (uint)TeleportFlags.ViaLocation | (uint)TeleportFlags.IsFlying; | ||
165 | else | ||
166 | flags = (uint)TeleportFlags.ViaLocation; | ||
167 | |||
160 | OSDMap info = new OSDMap(); | 168 | OSDMap info = new OSDMap(); |
161 | info.Add("AgentID", OSD.FromUUID(agentID)); | 169 | info.Add("AgentID", OSD.FromUUID(agentID)); |
162 | info.Add("LocationID", OSD.FromInteger(4)); // TODO what is this? | 170 | info.Add("LocationID", OSD.FromInteger(4)); // TODO what is this? |
@@ -165,7 +173,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
165 | info.Add("SimAccess", OSD.FromInteger(simAccess)); | 173 | info.Add("SimAccess", OSD.FromInteger(simAccess)); |
166 | info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes())); | 174 | info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes())); |
167 | info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port)); | 175 | info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port)); |
168 | info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation | 176 | // info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation |
177 | info.Add("TeleportFlags", OSD.FromUInteger(flags)); | ||
169 | info.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX)); | 178 | info.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX)); |
170 | info.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY)); | 179 | info.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY)); |
171 | 180 | ||
@@ -185,13 +194,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
185 | script.Add("ItemID", OSD.FromUUID(itemID)); | 194 | script.Add("ItemID", OSD.FromUUID(itemID)); |
186 | script.Add("Running", OSD.FromBoolean(running)); | 195 | script.Add("Running", OSD.FromBoolean(running)); |
187 | script.Add("Mono", OSD.FromBoolean(mono)); | 196 | script.Add("Mono", OSD.FromBoolean(mono)); |
188 | 197 | ||
189 | OSDArray scriptArr = new OSDArray(); | 198 | OSDArray scriptArr = new OSDArray(); |
190 | scriptArr.Add(script); | 199 | scriptArr.Add(script); |
191 | 200 | ||
192 | OSDMap body = new OSDMap(); | 201 | OSDMap body = new OSDMap(); |
193 | body.Add("Script", scriptArr); | 202 | body.Add("Script", scriptArr); |
194 | 203 | ||
195 | return BuildEvent("ScriptRunningReply", body); | 204 | return BuildEvent("ScriptRunningReply", body); |
196 | } | 205 | } |
197 | 206 | ||
@@ -204,8 +213,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
204 | {"sim-ip-and-port", new OSDString(simIpAndPort)}, | 213 | {"sim-ip-and-port", new OSDString(simIpAndPort)}, |
205 | {"seed-capability", new OSDString(seedcap)}, | 214 | {"seed-capability", new OSDString(seedcap)}, |
206 | {"region-handle", OSD.FromULong(regionHandle)}, | 215 | {"region-handle", OSD.FromULong(regionHandle)}, |
207 | {"region-size-x", OSD.FromInteger(regionSizeX)}, | 216 | {"region-size-x", OSD.FromUInteger((uint)regionSizeX)}, |
208 | {"region-size-y", OSD.FromInteger(regionSizeY)} | 217 | {"region-size-y", OSD.FromUInteger((uint)regionSizeY)} |
209 | }; | 218 | }; |
210 | 219 | ||
211 | return BuildEvent("EstablishAgentCommunication", body); | 220 | return BuildEvent("EstablishAgentCommunication", body); |
@@ -234,7 +243,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
234 | { | 243 | { |
235 | OSDMap messageParams = new OSDMap(15); | 244 | OSDMap messageParams = new OSDMap(15); |
236 | messageParams.Add("type", new OSDInteger((int)dialog)); | 245 | messageParams.Add("type", new OSDInteger((int)dialog)); |
237 | 246 | ||
238 | OSDArray positionArray = new OSDArray(3); | 247 | OSDArray positionArray = new OSDArray(3); |
239 | positionArray.Add(OSD.FromReal(position.X)); | 248 | positionArray.Add(OSD.FromReal(position.X)); |
240 | positionArray.Add(OSD.FromReal(position.Y)); | 249 | positionArray.Add(OSD.FromReal(position.Y)); |
@@ -299,20 +308,29 @@ namespace OpenSim.Region.ClientStack.Linden | |||
299 | } | 308 | } |
300 | 309 | ||
301 | public static OSD ChatterBoxSessionAgentListUpdates(UUID sessionID, | 310 | public static OSD ChatterBoxSessionAgentListUpdates(UUID sessionID, |
302 | UUID agentID, bool canVoiceChat, bool isModerator, bool textMute) | 311 | UUID agentID, bool canVoiceChat, bool isModerator, bool textMute, bool isEnterorLeave) |
303 | { | 312 | { |
304 | OSDMap body = new OSDMap(); | 313 | OSDMap body = new OSDMap(); |
305 | OSDMap agentUpdates = new OSDMap(); | 314 | OSDMap agentUpdates = new OSDMap(); |
306 | OSDMap infoDetail = new OSDMap(); | 315 | OSDMap infoDetail = new OSDMap(); |
307 | OSDMap mutes = new OSDMap(); | 316 | OSDMap mutes = new OSDMap(); |
308 | 317 | ||
318 | // this should be a list of agents and parameters | ||
319 | // foreach agent | ||
309 | mutes.Add("text", OSD.FromBoolean(textMute)); | 320 | mutes.Add("text", OSD.FromBoolean(textMute)); |
310 | infoDetail.Add("can_voice_chat", OSD.FromBoolean(canVoiceChat)); | 321 | infoDetail.Add("can_voice_chat", OSD.FromBoolean(canVoiceChat)); |
311 | infoDetail.Add("is_moderator", OSD.FromBoolean(isModerator)); | 322 | infoDetail.Add("is_moderator", OSD.FromBoolean(isModerator)); |
312 | infoDetail.Add("mutes", mutes); | 323 | infoDetail.Add("mutes", mutes); |
313 | OSDMap info = new OSDMap(); | 324 | OSDMap info = new OSDMap(); |
314 | info.Add("info", infoDetail); | 325 | info.Add("info", infoDetail); |
326 | if(isEnterorLeave) | ||
327 | info.Add("transition",OSD.FromString("ENTER")); | ||
328 | else | ||
329 | info.Add("transition",OSD.FromString("LEAVE")); | ||
315 | agentUpdates.Add(agentID.ToString(), info); | 330 | agentUpdates.Add(agentID.ToString(), info); |
331 | |||
332 | // foreach end | ||
333 | |||
316 | body.Add("agent_updates", agentUpdates); | 334 | body.Add("agent_updates", agentUpdates); |
317 | body.Add("session_id", OSD.FromUUID(sessionID)); | 335 | body.Add("session_id", OSD.FromUUID(sessionID)); |
318 | body.Add("updates", new OSD()); | 336 | body.Add("updates", new OSD()); |
@@ -324,40 +342,54 @@ namespace OpenSim.Region.ClientStack.Linden | |||
324 | return chatterBoxSessionAgentListUpdates; | 342 | return chatterBoxSessionAgentListUpdates; |
325 | } | 343 | } |
326 | 344 | ||
327 | public static OSD GroupMembership(AgentGroupDataUpdatePacket groupUpdatePacket) | 345 | public static OSD ChatterBoxForceClose(UUID sessionID, string reason) |
328 | { | 346 | { |
329 | OSDMap groupUpdate = new OSDMap(); | 347 | OSDMap body = new OSDMap(2); |
330 | groupUpdate.Add("message", OSD.FromString("AgentGroupDataUpdate")); | 348 | body.Add("session_id", new OSDUUID(sessionID)); |
349 | body.Add("reason", new OSDString(reason)); | ||
331 | 350 | ||
332 | OSDMap body = new OSDMap(); | 351 | OSDMap chatterBoxForceClose = new OSDMap(2); |
333 | OSDArray agentData = new OSDArray(); | 352 | chatterBoxForceClose.Add("message", new OSDString("ForceCloseChatterBoxSession")); |
334 | OSDMap agentDataMap = new OSDMap(); | 353 | chatterBoxForceClose.Add("body", body); |
335 | agentDataMap.Add("AgentID", OSD.FromUUID(groupUpdatePacket.AgentData.AgentID)); | 354 | return chatterBoxForceClose; |
336 | agentData.Add(agentDataMap); | 355 | } |
337 | body.Add("AgentData", agentData); | ||
338 | 356 | ||
339 | OSDArray groupData = new OSDArray(); | 357 | public static OSD GroupMembershipData(UUID receiverAgent, GroupMembershipData[] data) |
358 | { | ||
359 | OSDArray AgentData = new OSDArray(1); | ||
360 | OSDMap AgentDataMap = new OSDMap(1); | ||
361 | AgentDataMap.Add("AgentID", OSD.FromUUID(receiverAgent)); | ||
362 | AgentData.Add(AgentDataMap); | ||
340 | 363 | ||
341 | foreach (AgentGroupDataUpdatePacket.GroupDataBlock groupDataBlock in groupUpdatePacket.GroupData) | 364 | OSDArray GroupData = new OSDArray(data.Length); |
365 | OSDArray NewGroupData = new OSDArray(data.Length); | ||
366 | |||
367 | foreach (GroupMembershipData membership in data) | ||
342 | { | 368 | { |
343 | OSDMap groupDataMap = new OSDMap(); | 369 | OSDMap GroupDataMap = new OSDMap(6); |
344 | groupDataMap.Add("ListInProfile", OSD.FromBoolean(false)); | 370 | OSDMap NewGroupDataMap = new OSDMap(1); |
345 | groupDataMap.Add("GroupID", OSD.FromUUID(groupDataBlock.GroupID)); | 371 | |
346 | groupDataMap.Add("GroupInsigniaID", OSD.FromUUID(groupDataBlock.GroupInsigniaID)); | 372 | GroupDataMap.Add("GroupID", OSD.FromUUID(membership.GroupID)); |
347 | groupDataMap.Add("Contribution", OSD.FromInteger(groupDataBlock.Contribution)); | 373 | GroupDataMap.Add("GroupPowers", OSD.FromULong(membership.GroupPowers)); |
348 | groupDataMap.Add("GroupPowers", OSD.FromBinary(ulongToByteArray(groupDataBlock.GroupPowers))); | 374 | GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(membership.AcceptNotices)); |
349 | groupDataMap.Add("GroupName", OSD.FromString(Utils.BytesToString(groupDataBlock.GroupName))); | 375 | GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(membership.GroupPicture)); |
350 | groupDataMap.Add("AcceptNotices", OSD.FromBoolean(groupDataBlock.AcceptNotices)); | 376 | GroupDataMap.Add("Contribution", OSD.FromInteger(membership.Contribution)); |
377 | GroupDataMap.Add("GroupName", OSD.FromString(membership.GroupName)); | ||
378 | NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(membership.ListInProfile)); | ||
379 | |||
380 | GroupData.Add(GroupDataMap); | ||
381 | NewGroupData.Add(NewGroupDataMap); | ||
382 | } | ||
351 | 383 | ||
352 | groupData.Add(groupDataMap); | 384 | OSDMap llDataStruct = new OSDMap(3); |
385 | llDataStruct.Add("AgentData", AgentData); | ||
386 | llDataStruct.Add("GroupData", GroupData); | ||
387 | llDataStruct.Add("NewGroupData", NewGroupData); | ||
353 | 388 | ||
354 | } | 389 | return BuildEvent("AgentGroupDataUpdate", llDataStruct); |
355 | body.Add("GroupData", groupData); | ||
356 | groupUpdate.Add("body", body); | ||
357 | 390 | ||
358 | return groupUpdate; | ||
359 | } | 391 | } |
360 | 392 | ||
361 | public static OSD PlacesQuery(PlacesReplyPacket PlacesReply) | 393 | public static OSD PlacesQuery(PlacesReplyPacket PlacesReply) |
362 | { | 394 | { |
363 | OSDMap placesReply = new OSDMap(); | 395 | OSDMap placesReply = new OSDMap(); |
@@ -391,7 +423,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
391 | QueryDataMap.Add("SnapShotID", OSD.FromUUID(groupDataBlock.SnapshotID)); | 423 | QueryDataMap.Add("SnapShotID", OSD.FromUUID(groupDataBlock.SnapshotID)); |
392 | QueryDataMap.Add("ProductSku", OSD.FromInteger(0)); | 424 | QueryDataMap.Add("ProductSku", OSD.FromInteger(0)); |
393 | QueryDataMap.Add("Price", OSD.FromInteger(groupDataBlock.Price)); | 425 | QueryDataMap.Add("Price", OSD.FromInteger(groupDataBlock.Price)); |
394 | 426 | ||
395 | QueryData.Add(QueryDataMap); | 427 | QueryData.Add(QueryDataMap); |
396 | } | 428 | } |
397 | body.Add("QueryData", QueryData); | 429 | body.Add("QueryData", QueryData); |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index 16a902d..ee3f4f1 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs | |||
@@ -71,7 +71,6 @@ namespace OpenSim.Region.ClientStack.Linden.Tests | |||
71 | 71 | ||
72 | IConfigSource config = new IniConfigSource(); | 72 | IConfigSource config = new IniConfigSource(); |
73 | config.AddConfig("Startup"); | 73 | config.AddConfig("Startup"); |
74 | config.Configs["Startup"].Set("EventQueue", "true"); | ||
75 | 74 | ||
76 | CapabilitiesModule capsModule = new CapabilitiesModule(); | 75 | CapabilitiesModule capsModule = new CapabilitiesModule(); |
77 | m_eqgMod = new EventQueueGetModule(); | 76 | m_eqgMod = new EventQueueGetModule(); |
@@ -126,6 +125,15 @@ namespace OpenSim.Region.ClientStack.Linden.Tests | |||
126 | 125 | ||
127 | Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, sp.UUID); | 126 | Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, sp.UUID); |
128 | 127 | ||
128 | // initial queue as null events | ||
129 | eventsResponse = m_eqgMod.GetEvents(UUID.Zero, sp.UUID); | ||
130 | if((int)eventsResponse["int_response_code"] != (int)HttpStatusCode.OK) | ||
131 | { | ||
132 | eventsResponse = m_eqgMod.GetEvents(UUID.Zero, sp.UUID); | ||
133 | if((int)eventsResponse["int_response_code"] != (int)HttpStatusCode.OK) | ||
134 | eventsResponse = m_eqgMod.GetEvents(UUID.Zero, sp.UUID); | ||
135 | } | ||
136 | |||
129 | Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.OK)); | 137 | Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.OK)); |
130 | 138 | ||
131 | // Console.WriteLine("Response [{0}]", (string)eventsResponse["str_response_string"]); | 139 | // Console.WriteLine("Response [{0}]", (string)eventsResponse["str_response_string"]); |
@@ -172,7 +180,7 @@ namespace OpenSim.Region.ClientStack.Linden.Tests | |||
172 | TestHelpers.InMethod(); | 180 | TestHelpers.InMethod(); |
173 | // TestHelpers.EnableLogging(); | 181 | // TestHelpers.EnableLogging(); |
174 | 182 | ||
175 | UUID npcId | 183 | UUID npcId |
176 | = m_npcMod.CreateNPC( | 184 | = m_npcMod.CreateNPC( |
177 | "John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, new AvatarAppearance()); | 185 | "John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, new AvatarAppearance()); |
178 | 186 | ||
@@ -187,4 +195,4 @@ namespace OpenSim.Region.ClientStack.Linden.Tests | |||
187 | Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.BadGateway)); | 195 | Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.BadGateway)); |
188 | } | 196 | } |
189 | } | 197 | } |
190 | } \ No newline at end of file | 198 | } |