diff options
author | UbitUmarov | 2019-01-28 04:01:09 +0000 |
---|---|---|
committer | UbitUmarov | 2019-01-28 04:01:09 +0000 |
commit | cc27168cc1662918d1762843b1b41d4d94f311bb (patch) | |
tree | 7bd8f174341c31f9ad982ce10958dec645527030 /OpenSim/Region | |
parent | forgotten locks on ubode (diff) | |
download | opensim-SC-cc27168cc1662918d1762843b1b41d4d94f311bb.zip opensim-SC-cc27168cc1662918d1762843b1b41d4d94f311bb.tar.gz opensim-SC-cc27168cc1662918d1762843b1b41d4d94f311bb.tar.bz2 opensim-SC-cc27168cc1662918d1762843b1b41d4d94f311bb.tar.xz |
change encoding of event cap messages
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 288 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs | 246 |
2 files changed, 216 insertions, 318 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 58860b0..f56b212 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | |||
@@ -232,10 +232,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
232 | } | 232 | } |
233 | else | 233 | else |
234 | { | 234 | { |
235 | OSDMap evMap = (OSDMap)ev; | 235 | m_log.WarnFormat( |
236 | m_log.WarnFormat( | 236 | "[EVENTQUEUE]: (Enqueue) No queue found for agent {0} in region {2}", |
237 | "[EVENTQUEUE]: (Enqueue) No queue found for agent {0} when placing message {1} in region {2}", | 237 | avatarID, m_scene.Name); |
238 | avatarID, evMap["message"], m_scene.Name); | ||
239 | } | 238 | } |
240 | } | 239 | } |
241 | catch (NullReferenceException e) | 240 | catch (NullReferenceException e) |
@@ -254,14 +253,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
254 | //m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); | 253 | //m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); |
255 | 254 | ||
256 | lock (queues) | 255 | lock (queues) |
256 | { | ||
257 | queues.Remove(agentID); | 257 | queues.Remove(agentID); |
258 | 258 | ||
259 | lock (m_AvatarQueueUUIDMapping) | 259 | lock (m_AvatarQueueUUIDMapping) |
260 | m_AvatarQueueUUIDMapping.Remove(agentID); | 260 | m_AvatarQueueUUIDMapping.Remove(agentID); |
261 | 261 | ||
262 | lock (m_ids) | 262 | lock (m_ids) |
263 | { | ||
264 | if (!m_ids.ContainsKey(agentID)) | ||
265 | m_ids.Remove(agentID); | 263 | m_ids.Remove(agentID); |
266 | } | 264 | } |
267 | 265 | ||
@@ -288,16 +286,12 @@ namespace OpenSim.Region.ClientStack.Linden | |||
288 | agentID, caps, m_scene.RegionInfo.RegionName); | 286 | agentID, caps, m_scene.RegionInfo.RegionName); |
289 | 287 | ||
290 | UUID eventQueueGetUUID; | 288 | UUID eventQueueGetUUID; |
291 | Queue<OSD> queue; | 289 | Queue<OSD> queue = null; |
292 | Random rnd = new Random(Environment.TickCount); | ||
293 | int nrnd = rnd.Next(30000000); | ||
294 | 290 | ||
295 | lock (queues) | 291 | lock (queues) |
296 | { | 292 | { |
297 | if (queues.ContainsKey(agentID)) | 293 | if (queues.ContainsKey(agentID)) |
298 | queue = queues[agentID]; | 294 | queue = queues[agentID]; |
299 | else | ||
300 | queue = null; | ||
301 | 295 | ||
302 | if (queue == null) | 296 | if (queue == null) |
303 | { | 297 | { |
@@ -307,26 +301,26 @@ namespace OpenSim.Region.ClientStack.Linden | |||
307 | lock (m_AvatarQueueUUIDMapping) | 301 | lock (m_AvatarQueueUUIDMapping) |
308 | { | 302 | { |
309 | eventQueueGetUUID = UUID.Random(); | 303 | eventQueueGetUUID = UUID.Random(); |
310 | while(m_AvatarQueueUUIDMapping.ContainsKey(agentID)) | 304 | m_AvatarQueueUUIDMapping[agentID] = eventQueueGetUUID; |
311 | eventQueueGetUUID = UUID.Random(); | 305 | lock (m_ids) |
312 | m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); | 306 | { |
313 | } | 307 | if (m_ids.ContainsKey(agentID)) |
314 | lock (m_ids) | 308 | m_ids[agentID]++; |
315 | { | 309 | else |
316 | if (!m_ids.ContainsKey(agentID)) | 310 | { |
317 | m_ids.Add(agentID, nrnd); | 311 | Random rnd = new Random(Environment.TickCount); |
318 | else | 312 | m_ids[agentID] = rnd.Next(30000000); |
319 | m_ids[agentID]++; | 313 | } |
314 | } | ||
320 | } | 315 | } |
321 | } | 316 | } |
322 | else | 317 | else |
323 | { | 318 | { |
324 | queue.Enqueue(null); | 319 | queue.Enqueue(null); |
325 | queue.Enqueue(null); // one should be enough | 320 | |
326 | // reuse or not to reuse | 321 | // reuse or not to reuse |
327 | lock (m_AvatarQueueUUIDMapping) | 322 | lock (m_AvatarQueueUUIDMapping) |
328 | { | 323 | { |
329 | // Reuse open queues. The client does! | ||
330 | // Its reuse caps path not queues those are been reused already | 324 | // Its reuse caps path not queues those are been reused already |
331 | if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) | 325 | if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) |
332 | { | 326 | { |
@@ -337,25 +331,29 @@ namespace OpenSim.Region.ClientStack.Linden | |||
337 | // change to negative numbers so they are changed at end of sending first marker | 331 | // change to negative numbers so they are changed at end of sending first marker |
338 | // old data on a queue may be sent on a response for a new caps | 332 | // old data on a queue may be sent on a response for a new caps |
339 | // but at least will be sent with coerent IDs | 333 | // but at least will be sent with coerent IDs |
340 | if (!m_ids.ContainsKey(agentID)) | 334 | if (m_ids.ContainsKey(agentID)) |
341 | m_ids.Add(agentID, -nrnd); // should not happen | ||
342 | else | ||
343 | m_ids[agentID] = -m_ids[agentID]; | 335 | m_ids[agentID] = -m_ids[agentID]; |
336 | else | ||
337 | { | ||
338 | Random rnd = new Random(Environment.TickCount); | ||
339 | m_ids[agentID] = -rnd.Next(30000000); | ||
340 | } | ||
344 | } | 341 | } |
345 | } | 342 | } |
346 | else | 343 | else |
347 | { | 344 | { |
348 | eventQueueGetUUID = UUID.Random(); | 345 | eventQueueGetUUID = UUID.Random(); |
349 | while(m_AvatarQueueUUIDMapping.ContainsKey(agentID)) | 346 | m_AvatarQueueUUIDMapping[agentID] = eventQueueGetUUID; |
350 | eventQueueGetUUID = UUID.Random(); | ||
351 | m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); | ||
352 | m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!"); | 347 | m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!"); |
353 | lock (m_ids) | 348 | lock (m_ids) |
354 | { | 349 | { |
355 | if (!m_ids.ContainsKey(agentID)) | 350 | if (m_ids.ContainsKey(agentID)) |
356 | m_ids.Add(agentID, nrnd); | ||
357 | else | ||
358 | m_ids[agentID]++; | 351 | m_ids[agentID]++; |
352 | else | ||
353 | { | ||
354 | Random rnd = new Random(Environment.TickCount); | ||
355 | m_ids.Add(agentID, rnd.Next(30000000)); | ||
356 | } | ||
359 | } | 357 | } |
360 | } | 358 | } |
361 | } | 359 | } |
@@ -407,9 +405,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
407 | 405 | ||
408 | Queue<OSD> queue = GetQueue(pAgentId); | 406 | Queue<OSD> queue = GetQueue(pAgentId); |
409 | if (queue == null) | 407 | if (queue == null) |
410 | { | ||
411 | return NoEvents(requestID, pAgentId); | 408 | return NoEvents(requestID, pAgentId); |
412 | } | ||
413 | 409 | ||
414 | OSD element = null;; | 410 | OSD element = null;; |
415 | OSDArray array = new OSDArray(); | 411 | OSDArray array = new OSDArray(); |
@@ -437,45 +433,37 @@ namespace OpenSim.Region.ClientStack.Linden | |||
437 | // so they get into a response | 433 | // so they get into a response |
438 | if (element == null) | 434 | if (element == null) |
439 | break; | 435 | break; |
436 | |||
440 | if (DebugLevel > 0) | 437 | if (DebugLevel > 0) |
441 | LogOutboundDebugMessage(element, pAgentId); | 438 | LogOutboundDebugMessage(element, pAgentId); |
442 | array.Add(element); | 439 | array.Add(element); |
443 | } | 440 | } |
444 | } | 441 | } |
445 | 442 | ||
446 | OSDMap events = null; | 443 | lock (m_ids) |
447 | |||
448 | if (array.Count > 0) | ||
449 | { | 444 | { |
450 | events = new OSDMap(); | 445 | if (element == null && negativeID) |
451 | events.Add("events", array); | 446 | { |
452 | events.Add("id", new OSDInteger(thisID)); | 447 | Random rnd = new Random(Environment.TickCount); |
448 | m_ids[pAgentId] = rnd.Next(30000000); | ||
449 | } | ||
450 | else | ||
451 | m_ids[pAgentId] = thisID + 1; | ||
453 | } | 452 | } |
454 | 453 | ||
455 | if (negativeID && element == null) | 454 | if (array.Count == 0) |
456 | { | 455 | return NoEvents(requestID, pAgentId); |
457 | Random rnd = new Random(Environment.TickCount); | ||
458 | thisID = rnd.Next(30000000); | ||
459 | } | ||
460 | 456 | ||
461 | lock (m_ids) | 457 | OSDMap events = new OSDMap(); |
462 | { | 458 | events.Add("events", array); |
463 | m_ids[pAgentId] = thisID + 1; | 459 | events.Add("id", new OSDInteger(thisID)); |
464 | } | 460 | |
461 | Hashtable responsedata = new Hashtable(); | ||
462 | responsedata["int_response_code"] = 200; | ||
463 | responsedata["content_type"] = "application/xml"; | ||
464 | //string tt = OSDParser.SerializeLLSDXmlString(events); | ||
465 | responsedata["bin_response_data"] = Encoding.UTF8.GetBytes(OSDParser.SerializeLLSDXmlString(events)); | ||
465 | 466 | ||
466 | Hashtable responsedata; | ||
467 | // if there where no elements before a marker send a NoEvents | ||
468 | if (events == null) | ||
469 | { | ||
470 | return NoEvents(requestID, pAgentId); | ||
471 | } | ||
472 | else | ||
473 | { | ||
474 | responsedata = new Hashtable(); | ||
475 | responsedata["int_response_code"] = 200; | ||
476 | responsedata["content_type"] = "application/xml"; | ||
477 | responsedata["bin_response_data"] = Encoding.UTF8.GetBytes(OSDParser.SerializeLLSDXmlString(events)); | ||
478 | } | ||
479 | //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", pAgentId, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); | 467 | //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", pAgentId, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); |
480 | return responsedata; | 468 | return responsedata; |
481 | } | 469 | } |
@@ -522,7 +510,17 @@ namespace OpenSim.Region.ClientStack.Linden | |||
522 | m_log.DebugFormat("{0} EnableSimulator. handle={1}, endPoint={2}, avatarID={3}", | 510 | m_log.DebugFormat("{0} EnableSimulator. handle={1}, endPoint={2}, avatarID={3}", |
523 | LogHeader, handle, endPoint, avatarID, regionSizeX, regionSizeY); | 511 | LogHeader, handle, endPoint, avatarID, regionSizeX, regionSizeY); |
524 | 512 | ||
525 | OSD item = EventQueueHelper.EnableSimulator(handle, endPoint, regionSizeX, regionSizeY); | 513 | StringBuilder sb = StartEvent("EnableSimulator"); |
514 | LLSDxmlEncode.AddArrayAndMap("SimulatorInfo", sb); | ||
515 | LLSDxmlEncode.AddElem("Handle", handle, sb); | ||
516 | LLSDxmlEncode.AddElem("IP", endPoint.Address.GetAddressBytes(), sb); | ||
517 | LLSDxmlEncode.AddElem("Port", endPoint.Port, sb); | ||
518 | LLSDxmlEncode.AddElem("RegionSizeX", (uint)regionSizeX, sb); | ||
519 | LLSDxmlEncode.AddElem("RegionSizeY", (uint)regionSizeY, sb); | ||
520 | LLSDxmlEncode.AddEndMapAndArray(sb); | ||
521 | |||
522 | OSD item = new OSDllsdxml(EndEvent(sb)); | ||
523 | |||
526 | Enqueue(item, avatarID); | 524 | Enqueue(item, avatarID); |
527 | } | 525 | } |
528 | 526 | ||
@@ -533,8 +531,18 @@ namespace OpenSim.Region.ClientStack.Linden | |||
533 | m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, endPoint={2}, avatarID={3}", | 531 | m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, endPoint={2}, avatarID={3}", |
534 | LogHeader, regionHandle, endPoint, avatarID, regionSizeX, regionSizeY); | 532 | LogHeader, regionHandle, endPoint, avatarID, regionSizeX, regionSizeY); |
535 | 533 | ||
536 | OSD item = EventQueueHelper.EstablishAgentCommunication(avatarID, endPoint.ToString(), capsPath, regionHandle, regionSizeX, regionSizeY); | 534 | StringBuilder sb = StartEvent("EstablishAgentCommunication"); |
537 | Enqueue(item, avatarID); | 535 | |
536 | LLSDxmlEncode.AddElem("agent-id", avatarID, sb); | ||
537 | LLSDxmlEncode.AddElem("sim-ip-and-port", endPoint.ToString(), sb); | ||
538 | LLSDxmlEncode.AddElem("seed-capability", capsPath, sb); | ||
539 | // current viewers ignore this, also not needed its sent on enablesim | ||
540 | //LLSDxmlEncode.AddElem("region-handle", regionHandle, sb); | ||
541 | //LLSDxmlEncode.AddElem("region-size-x", (uint)regionSizeX, sb); | ||
542 | //LLSDxmlEncode.AddElem("region-size-y", (uint)regionSizeY, sb); | ||
543 | |||
544 | OSD ev = new OSDllsdxml(EndEvent(sb)); | ||
545 | Enqueue(ev, avatarID); | ||
538 | } | 546 | } |
539 | 547 | ||
540 | public virtual void TeleportFinishEvent(ulong regionHandle, byte simAccess, | 548 | public virtual void TeleportFinishEvent(ulong regionHandle, byte simAccess, |
@@ -546,9 +554,29 @@ namespace OpenSim.Region.ClientStack.Linden | |||
546 | m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, endPoint={2}, avatarID={3}", | 554 | m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, endPoint={2}, avatarID={3}", |
547 | LogHeader, regionHandle, regionExternalEndPoint, avatarID, regionSizeX, regionSizeY); | 555 | LogHeader, regionHandle, regionExternalEndPoint, avatarID, regionSizeX, regionSizeY); |
548 | 556 | ||
549 | OSD item = EventQueueHelper.TeleportFinishEvent(regionHandle, simAccess, regionExternalEndPoint, | 557 | // not sure why flags get overwritten here |
550 | locationID, flags, capsURL, avatarID, regionSizeX, regionSizeY); | 558 | if ((flags & (uint)TeleportFlags.IsFlying) != 0) |
551 | Enqueue(item, avatarID); | 559 | flags = (uint)TeleportFlags.ViaLocation | (uint)TeleportFlags.IsFlying; |
560 | else | ||
561 | flags = (uint)TeleportFlags.ViaLocation; | ||
562 | |||
563 | StringBuilder sb = StartEvent("TeleportFinish"); | ||
564 | |||
565 | LLSDxmlEncode.AddArrayAndMap("Info", sb); | ||
566 | LLSDxmlEncode.AddElem("AgentID", avatarID, sb); | ||
567 | LLSDxmlEncode.AddElem("LocationID", (uint)4, sb); // TODO what is this? | ||
568 | LLSDxmlEncode.AddElem("SimIP", regionExternalEndPoint.Address.GetAddressBytes(), sb); | ||
569 | LLSDxmlEncode.AddElem("SimPort", regionExternalEndPoint.Port, sb); | ||
570 | LLSDxmlEncode.AddElem("RegionHandle", regionHandle, sb); | ||
571 | LLSDxmlEncode.AddElem("SeedCapability", capsURL, sb); | ||
572 | LLSDxmlEncode.AddElem("SimAccess",(int)simAccess, sb); | ||
573 | LLSDxmlEncode.AddElem("TeleportFlags", flags, sb); | ||
574 | LLSDxmlEncode.AddElem("RegionSizeX", (uint)regionSizeX, sb); | ||
575 | LLSDxmlEncode.AddElem("RegionSizeY", (uint)regionSizeY, sb); | ||
576 | LLSDxmlEncode.AddEndMapAndArray(sb); | ||
577 | |||
578 | OSD ev = new OSDllsdxml(EndEvent(sb)); | ||
579 | Enqueue(ev, avatarID); | ||
552 | } | 580 | } |
553 | 581 | ||
554 | public virtual void CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, | 582 | public virtual void CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, |
@@ -559,9 +587,29 @@ namespace OpenSim.Region.ClientStack.Linden | |||
559 | m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>", | 587 | m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>", |
560 | LogHeader, handle, avatarID, regionSizeX, regionSizeY); | 588 | LogHeader, handle, avatarID, regionSizeX, regionSizeY); |
561 | 589 | ||
562 | OSD item = EventQueueHelper.CrossRegion(handle, pos, lookAt, newRegionExternalEndPoint, | 590 | StringBuilder sb = StartEvent("CrossedRegion"); |
563 | capsURL, avatarID, sessionID, regionSizeX, regionSizeY); | 591 | |
564 | Enqueue(item, avatarID); | 592 | LLSDxmlEncode.AddArrayAndMap("AgentData", sb); |
593 | LLSDxmlEncode.AddElem("AgentID", avatarID, sb); | ||
594 | LLSDxmlEncode.AddElem("SessionID", sessionID, sb); | ||
595 | LLSDxmlEncode.AddEndMapAndArray(sb); | ||
596 | |||
597 | LLSDxmlEncode.AddArrayAndMap("Info", sb); | ||
598 | LLSDxmlEncode.AddElem("LookAt", lookAt, sb); | ||
599 | LLSDxmlEncode.AddElem("Position", pos, sb); | ||
600 | LLSDxmlEncode.AddEndMapAndArray(sb); | ||
601 | |||
602 | LLSDxmlEncode.AddArrayAndMap("RegionData", sb); | ||
603 | LLSDxmlEncode.AddElem("RegionHandle", handle, sb); | ||
604 | LLSDxmlEncode.AddElem("SeedCapability", capsURL, sb); | ||
605 | LLSDxmlEncode.AddElem("SimIP", newRegionExternalEndPoint.Address.GetAddressBytes(), sb); | ||
606 | LLSDxmlEncode.AddElem("SimPort", newRegionExternalEndPoint.Port, sb); | ||
607 | LLSDxmlEncode.AddElem("RegionSizeX", (uint)regionSizeX, sb); | ||
608 | LLSDxmlEncode.AddElem("RegionSizeY", (uint)regionSizeY, sb); | ||
609 | LLSDxmlEncode.AddEndMapAndArray(sb); | ||
610 | |||
611 | OSD ev = new OSDllsdxml(EndEvent(sb)); | ||
612 | Enqueue(ev, avatarID); | ||
565 | } | 613 | } |
566 | 614 | ||
567 | public void ChatterboxInvitation(UUID sessionID, string sessionName, | 615 | public void ChatterboxInvitation(UUID sessionID, string sessionName, |
@@ -593,16 +641,49 @@ namespace OpenSim.Region.ClientStack.Linden | |||
593 | Enqueue(item, toAgent); | 641 | Enqueue(item, toAgent); |
594 | } | 642 | } |
595 | 643 | ||
596 | public void ParcelProperties(ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID) | 644 | public void GroupMembershipData(UUID AgentID, GroupMembershipData[] data) |
597 | { | 645 | { |
598 | OSD item = EventQueueHelper.ParcelProperties(parcelPropertiesMessage); | 646 | StringBuilder sb = StartEvent("AgentGroupDataUpdate"); |
599 | Enqueue(item, avatarID); | ||
600 | } | ||
601 | 647 | ||
602 | public void GroupMembershipData(UUID receiverAgent, GroupMembershipData[] data) | 648 | LLSDxmlEncode.AddArrayAndMap("AgentData", sb); |
603 | { | 649 | LLSDxmlEncode.AddElem("AgentID", AgentID, sb); |
604 | OSD item = EventQueueHelper.GroupMembershipData(receiverAgent, data); | 650 | LLSDxmlEncode.AddEndMapAndArray(sb); |
605 | Enqueue(item, receiverAgent); | 651 | |
652 | if (data.Length == 0) | ||
653 | { | ||
654 | LLSDxmlEncode.AddEmptyArray("GroupData", sb); | ||
655 | LLSDxmlEncode.AddEmptyArray("NewGroupData", sb); | ||
656 | } | ||
657 | else | ||
658 | { | ||
659 | List<bool> lstInProfiles = new List<bool>(data.Length); | ||
660 | LLSDxmlEncode.AddArray("GroupData", sb); | ||
661 | foreach (GroupMembershipData m in data) | ||
662 | { | ||
663 | LLSDxmlEncode.AddMap(sb); | ||
664 | LLSDxmlEncode.AddElem("GroupID", m.GroupID, sb); | ||
665 | LLSDxmlEncode.AddElem("GroupPowers", m.GroupPowers, sb); | ||
666 | LLSDxmlEncode.AddElem("AcceptNotices", m.AcceptNotices, sb); | ||
667 | LLSDxmlEncode.AddElem("GroupInsigniaID", m.GroupPicture, sb); | ||
668 | LLSDxmlEncode.AddElem("Contribution", m.Contribution, sb); | ||
669 | LLSDxmlEncode.AddElem("GroupName", m.GroupName, sb); | ||
670 | LLSDxmlEncode.AddEndMap(sb); | ||
671 | lstInProfiles.Add(m.ListInProfile); | ||
672 | } | ||
673 | LLSDxmlEncode.AddEndArray(sb); | ||
674 | |||
675 | LLSDxmlEncode.AddArray("NewGroupData", sb); | ||
676 | foreach(bool b in lstInProfiles) | ||
677 | { | ||
678 | LLSDxmlEncode.AddMap(sb); | ||
679 | LLSDxmlEncode.AddElem("ListInProfile", b, sb); | ||
680 | LLSDxmlEncode.AddEndMap(sb); | ||
681 | } | ||
682 | LLSDxmlEncode.AddEndArray(sb); | ||
683 | } | ||
684 | |||
685 | OSD ev = new OSDllsdxml(EndEvent(sb)); | ||
686 | Enqueue(ev, AgentID); | ||
606 | } | 687 | } |
607 | 688 | ||
608 | public void QueryReply(PlacesReplyPacket groupUpdate, UUID avatarID) | 689 | public void QueryReply(PlacesReplyPacket groupUpdate, UUID avatarID) |
@@ -613,33 +694,38 @@ namespace OpenSim.Region.ClientStack.Linden | |||
613 | 694 | ||
614 | public void ScriptRunningEvent(UUID objectID, UUID itemID, bool running, UUID avatarID) | 695 | public void ScriptRunningEvent(UUID objectID, UUID itemID, bool running, UUID avatarID) |
615 | { | 696 | { |
616 | StringBuilder sb = EventQueueHelper.StartEvent("ScriptRunningReply"); | 697 | StringBuilder sb = StartEvent("ScriptRunningReply"); |
617 | LLSDxmlEncode.AddArray("Script", sb); | 698 | LLSDxmlEncode.AddArrayAndMap("Script", sb); |
618 | 699 | LLSDxmlEncode.AddElem("ObjectID", objectID, sb); | |
619 | LLSDxmlEncode.AddMap(sb); | 700 | LLSDxmlEncode.AddElem("ItemID", itemID, sb); |
620 | LLSDxmlEncode.AddElem("ObjectID", objectID, sb); | 701 | LLSDxmlEncode.AddElem("Running", running, sb); |
621 | LLSDxmlEncode.AddElem("ItemID", itemID, sb); | 702 | LLSDxmlEncode.AddElem("Mono", true, sb); |
622 | LLSDxmlEncode.AddElem("Running", running, sb); | 703 | LLSDxmlEncode.AddEndMapAndArray(sb); |
623 | LLSDxmlEncode.AddElem("Mono", true, sb); | ||
624 | LLSDxmlEncode.AddEndMap(sb); | ||
625 | |||
626 | LLSDxmlEncode.AddEndArray(sb); | ||
627 | 704 | ||
628 | OSDllsdxml item = new OSDllsdxml(EventQueueHelper.EndEvent(sb)); | 705 | OSDllsdxml item = new OSDllsdxml(EndEvent(sb)); |
629 | Enqueue(item, avatarID); | 706 | Enqueue(item, avatarID); |
630 | } | 707 | } |
631 | 708 | ||
632 | public OSD BuildEvent(string eventName, OSD eventBody) | ||
633 | { | ||
634 | return EventQueueHelper.BuildEvent(eventName, eventBody); | ||
635 | } | ||
636 | |||
637 | public void partPhysicsProperties(uint localID, byte physhapetype, | 709 | public void partPhysicsProperties(uint localID, byte physhapetype, |
638 | float density, float friction, float bounce, float gravmod,UUID avatarID) | 710 | float density, float friction, float bounce, float gravmod,UUID avatarID) |
639 | { | 711 | { |
640 | OSD item = EventQueueHelper.partPhysicsProperties(localID, physhapetype, | 712 | StringBuilder sb = StartEvent("ObjectPhysicsProperties"); |
641 | density, friction, bounce, gravmod); | 713 | LLSDxmlEncode.AddArrayAndMap("ObjectData", sb); |
714 | LLSDxmlEncode.AddElem("LocalID", (int)localID, sb); | ||
715 | LLSDxmlEncode.AddElem("Density", density, sb); | ||
716 | LLSDxmlEncode.AddElem("Friction", friction, sb); | ||
717 | LLSDxmlEncode.AddElem("GravityMultiplier", gravmod, sb); | ||
718 | LLSDxmlEncode.AddElem("Restitution", bounce, sb); | ||
719 | LLSDxmlEncode.AddElem("PhysicsShapeType", (int)physhapetype, sb); | ||
720 | LLSDxmlEncode.AddEndMapAndArray(sb); | ||
721 | |||
722 | OSDllsdxml item = new OSDllsdxml(EndEvent(sb)); | ||
642 | Enqueue(item, avatarID); | 723 | Enqueue(item, avatarID); |
643 | } | 724 | } |
725 | |||
726 | public OSD BuildEvent(string eventName, OSD eventBody) | ||
727 | { | ||
728 | return EventQueueHelper.BuildEvent(eventName, eventBody); | ||
729 | } | ||
644 | } | 730 | } |
645 | } | 731 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs index 0c4af6e..206c0de 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs | |||
@@ -41,40 +41,23 @@ namespace OpenSim.Region.ClientStack.Linden | |||
41 | { | 41 | { |
42 | private EventQueueHelper() {} // no construction possible, it's an utility class | 42 | private EventQueueHelper() {} // no construction possible, it's an utility class |
43 | 43 | ||
44 | public static byte[] ulongToByteArray(ulong uLongValue) | ||
45 | { | ||
46 | // Reverse endianness of RegionHandle | ||
47 | return new byte[8] | ||
48 | { | ||
49 | (byte)((uLongValue >> 56) & 0xff), | ||
50 | (byte)((uLongValue >> 48) & 0xff), | ||
51 | (byte)((uLongValue >> 40) & 0xff), | ||
52 | (byte)((uLongValue >> 32) & 0xff), | ||
53 | (byte)((uLongValue >> 24) & 0xff), | ||
54 | (byte)((uLongValue >> 16) & 0xff), | ||
55 | (byte)((uLongValue >> 8) & 0xff), | ||
56 | (byte)(uLongValue & 0xff) | ||
57 | }; | ||
58 | } | ||
59 | |||
60 | public static StringBuilder StartEvent(string eventName) | 44 | public static StringBuilder StartEvent(string eventName) |
61 | { | 45 | { |
62 | StringBuilder sb = new StringBuilder(256); | 46 | StringBuilder sb = new StringBuilder(256); |
63 | LLSDxmlEncode.AddMap(sb); | 47 | LLSDxmlEncode.AddMap(sb); |
64 | LLSDxmlEncode.AddElem("message", eventName, sb); | 48 | LLSDxmlEncode.AddElem("message", eventName, sb); |
65 | LLSDxmlEncode.AddMap("body", sb); | 49 | LLSDxmlEncode.AddMap("body", sb); |
66 | 50 | ||
67 | return sb; | 51 | return sb; |
68 | } | 52 | } |
69 | 53 | ||
70 | public static string EndEvent(StringBuilder sb) | 54 | public static string EndEvent(StringBuilder sb) |
71 | { | 55 | { |
72 | LLSDxmlEncode.AddEndMap(sb); // close body | 56 | LLSDxmlEncode.AddEndMap(sb); // close body |
73 | LLSDxmlEncode.AddEndMap(sb); // close event | 57 | LLSDxmlEncode.AddEndMap(sb); // close event |
74 | return sb.ToString(); | 58 | return sb.ToString(); |
75 | } | 59 | } |
76 | 60 | ||
77 | |||
78 | public static OSD BuildEvent(string eventName, OSD eventBody) | 61 | public static OSD BuildEvent(string eventName, OSD eventBody) |
79 | { | 62 | { |
80 | OSDMap llsdEvent = new OSDMap(2); | 63 | OSDMap llsdEvent = new OSDMap(2); |
@@ -84,137 +67,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
84 | return llsdEvent; | 67 | return llsdEvent; |
85 | } | 68 | } |
86 | 69 | ||
87 | public static OSD EnableSimulator(ulong handle, IPEndPoint endPoint, int regionSizeX, int regionSizeY) | ||
88 | { | ||
89 | OSDMap llsdSimInfo = new OSDMap(5); | ||
90 | |||
91 | llsdSimInfo.Add("Handle", new OSDBinary(ulongToByteArray(handle))); | ||
92 | llsdSimInfo.Add("IP", new OSDBinary(endPoint.Address.GetAddressBytes())); | ||
93 | llsdSimInfo.Add("Port", OSD.FromInteger(endPoint.Port)); | ||
94 | llsdSimInfo.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX)); | ||
95 | llsdSimInfo.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY)); | ||
96 | |||
97 | OSDArray arr = new OSDArray(1); | ||
98 | arr.Add(llsdSimInfo); | ||
99 | |||
100 | OSDMap llsdBody = new OSDMap(1); | ||
101 | llsdBody.Add("SimulatorInfo", arr); | ||
102 | |||
103 | return BuildEvent("EnableSimulator", llsdBody); | ||
104 | } | ||
105 | /* | ||
106 | public static OSD DisableSimulator(ulong handle) | ||
107 | { | ||
108 | //OSDMap llsdSimInfo = new OSDMap(1); | ||
109 | |||
110 | //llsdSimInfo.Add("Handle", new OSDBinary(regionHandleToByteArray(handle))); | ||
111 | |||
112 | //OSDArray arr = new OSDArray(1); | ||
113 | //arr.Add(llsdSimInfo); | ||
114 | |||
115 | OSDMap llsdBody = new OSDMap(0); | ||
116 | //llsdBody.Add("SimulatorInfo", arr); | ||
117 | |||
118 | return BuildEvent("DisableSimulator", llsdBody); | ||
119 | } | ||
120 | */ | ||
121 | public static OSD CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, | ||
122 | IPEndPoint newRegionExternalEndPoint, | ||
123 | string capsURL, UUID agentID, UUID sessionID, | ||
124 | int regionSizeX, int regionSizeY) | ||
125 | { | ||
126 | OSDArray lookAtArr = new OSDArray(3); | ||
127 | lookAtArr.Add(OSD.FromReal(lookAt.X)); | ||
128 | lookAtArr.Add(OSD.FromReal(lookAt.Y)); | ||
129 | lookAtArr.Add(OSD.FromReal(lookAt.Z)); | ||
130 | |||
131 | OSDArray positionArr = new OSDArray(3); | ||
132 | positionArr.Add(OSD.FromReal(pos.X)); | ||
133 | positionArr.Add(OSD.FromReal(pos.Y)); | ||
134 | positionArr.Add(OSD.FromReal(pos.Z)); | ||
135 | |||
136 | OSDMap infoMap = new OSDMap(2); | ||
137 | infoMap.Add("LookAt", lookAtArr); | ||
138 | infoMap.Add("Position", positionArr); | ||
139 | |||
140 | OSDArray infoArr = new OSDArray(1); | ||
141 | infoArr.Add(infoMap); | ||
142 | |||
143 | OSDMap agentDataMap = new OSDMap(2); | ||
144 | agentDataMap.Add("AgentID", OSD.FromUUID(agentID)); | ||
145 | agentDataMap.Add("SessionID", OSD.FromUUID(sessionID)); | ||
146 | |||
147 | OSDArray agentDataArr = new OSDArray(1); | ||
148 | agentDataArr.Add(agentDataMap); | ||
149 | |||
150 | OSDMap regionDataMap = new OSDMap(6); | ||
151 | regionDataMap.Add("RegionHandle", OSD.FromBinary(ulongToByteArray(handle))); | ||
152 | regionDataMap.Add("SeedCapability", OSD.FromString(capsURL)); | ||
153 | regionDataMap.Add("SimIP", OSD.FromBinary(newRegionExternalEndPoint.Address.GetAddressBytes())); | ||
154 | regionDataMap.Add("SimPort", OSD.FromInteger(newRegionExternalEndPoint.Port)); | ||
155 | regionDataMap.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX)); | ||
156 | regionDataMap.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY)); | ||
157 | |||
158 | OSDArray regionDataArr = new OSDArray(1); | ||
159 | regionDataArr.Add(regionDataMap); | ||
160 | |||
161 | OSDMap llsdBody = new OSDMap(3); | ||
162 | llsdBody.Add("Info", infoArr); | ||
163 | llsdBody.Add("AgentData", agentDataArr); | ||
164 | llsdBody.Add("RegionData", regionDataArr); | ||
165 | |||
166 | return BuildEvent("CrossedRegion", llsdBody); | ||
167 | } | ||
168 | |||
169 | public static OSD TeleportFinishEvent( | ||
170 | ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, | ||
171 | uint locationID, uint flags, string capsURL, UUID agentID, | ||
172 | int regionSizeX, int regionSizeY) | ||
173 | { | ||
174 | // not sure why flags get overwritten here | ||
175 | if ((flags & (uint)TeleportFlags.IsFlying) != 0) | ||
176 | flags = (uint)TeleportFlags.ViaLocation | (uint)TeleportFlags.IsFlying; | ||
177 | else | ||
178 | flags = (uint)TeleportFlags.ViaLocation; | ||
179 | |||
180 | OSDMap info = new OSDMap(); | ||
181 | info.Add("AgentID", OSD.FromUUID(agentID)); | ||
182 | info.Add("LocationID", OSD.FromInteger(4)); // TODO what is this? | ||
183 | info.Add("RegionHandle", OSD.FromBinary(ulongToByteArray(regionHandle))); | ||
184 | info.Add("SeedCapability", OSD.FromString(capsURL)); | ||
185 | info.Add("SimAccess", OSD.FromInteger(simAccess)); | ||
186 | info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes())); | ||
187 | info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port)); | ||
188 | // info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation | ||
189 | info.Add("TeleportFlags", OSD.FromUInteger(flags)); | ||
190 | info.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX)); | ||
191 | info.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY)); | ||
192 | |||
193 | OSDArray infoArr = new OSDArray(); | ||
194 | infoArr.Add(info); | ||
195 | |||
196 | OSDMap body = new OSDMap(); | ||
197 | body.Add("Info", infoArr); | ||
198 | |||
199 | return BuildEvent("TeleportFinish", body); | ||
200 | } | ||
201 | |||
202 | public static OSD EstablishAgentCommunication(UUID agentID, string simIpAndPort, string seedcap, | ||
203 | ulong regionHandle, int regionSizeX, int regionSizeY) | ||
204 | { | ||
205 | OSDMap body = new OSDMap(6) | ||
206 | { | ||
207 | {"agent-id", new OSDUUID(agentID)}, | ||
208 | {"sim-ip-and-port", new OSDString(simIpAndPort)}, | ||
209 | {"seed-capability", new OSDString(seedcap)}, | ||
210 | {"region-handle", OSD.FromULong(regionHandle)}, | ||
211 | {"region-size-x", OSD.FromUInteger((uint)regionSizeX)}, | ||
212 | {"region-size-y", OSD.FromUInteger((uint)regionSizeY)} | ||
213 | }; | ||
214 | |||
215 | return BuildEvent("EstablishAgentCommunication", body); | ||
216 | } | ||
217 | |||
218 | public static OSD KeepAliveEvent() | 70 | public static OSD KeepAliveEvent() |
219 | { | 71 | { |
220 | return BuildEvent("FAKEEVENT", new OSDMap()); | 72 | return BuildEvent("FAKEEVENT", new OSDMap()); |
@@ -261,7 +113,33 @@ namespace OpenSim.Region.ClientStack.Linden | |||
261 | messageParams.Add("ttl", new OSDInteger((int)ttl)); | 113 | messageParams.Add("ttl", new OSDInteger((int)ttl)); |
262 | messageParams.Add("from_id", new OSDUUID(fromAgent)); | 114 | messageParams.Add("from_id", new OSDUUID(fromAgent)); |
263 | messageParams.Add("from_group", new OSDInteger(fromGroup ? 1 : 0)); | 115 | messageParams.Add("from_group", new OSDInteger(fromGroup ? 1 : 0)); |
264 | 116 | /* | |
117 | StringBuilder sb = new StringBuilder(256); | ||
118 | LLSDxmlEncode.AddMap(sb); //messageParams | ||
119 | |||
120 | LLSDxmlEncode.AddElem("type", dialog, sb); | ||
121 | LLSDxmlEncode.AddElem("position", position, sb); | ||
122 | LLSDxmlEncode.AddElem("region_id", UUID.Zero, sb); | ||
123 | LLSDxmlEncode.AddElem("to_id", toAgent, sb); | ||
124 | LLSDxmlEncode.AddElem("source", 0, sb); | ||
125 | |||
126 | LLSDxmlEncode.AddMap("data", sb); //messageParams data | ||
127 | LLSDxmlEncode.AddElem("binary_bucket", binaryBucket, sb); | ||
128 | LLSDxmlEncode.AddEndMap(sb); //messageParams data | ||
129 | |||
130 | LLSDxmlEncode.AddElem("message", message, sb); | ||
131 | LLSDxmlEncode.AddElem("id", transactionID, sb); | ||
132 | LLSDxmlEncode.AddElem("from_name", fromName, sb); | ||
133 | LLSDxmlEncode.AddElem("timestamp", timeStamp, sb); | ||
134 | LLSDxmlEncode.AddElem("offline", (offline ? 1 : 0), sb); | ||
135 | LLSDxmlEncode.AddElem("parent_estate_id", parentEstateID, sb); | ||
136 | LLSDxmlEncode.AddElem("ttl", (int)ttl, sb); | ||
137 | LLSDxmlEncode.AddElem("from_id", fromAgent, sb); | ||
138 | LLSDxmlEncode.AddElem("from_group",fromGroup, sb); | ||
139 | |||
140 | LLSDxmlEncode.AddEndMap(sb); //messageParams | ||
141 | string tt = sb.ToString(); | ||
142 | */ | ||
265 | return messageParams; | 143 | return messageParams; |
266 | } | 144 | } |
267 | 145 | ||
@@ -349,42 +227,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
349 | return chatterBoxForceClose; | 227 | return chatterBoxForceClose; |
350 | } | 228 | } |
351 | 229 | ||
352 | public static OSD GroupMembershipData(UUID receiverAgent, GroupMembershipData[] data) | ||
353 | { | ||
354 | OSDArray AgentData = new OSDArray(1); | ||
355 | OSDMap AgentDataMap = new OSDMap(1); | ||
356 | AgentDataMap.Add("AgentID", OSD.FromUUID(receiverAgent)); | ||
357 | AgentData.Add(AgentDataMap); | ||
358 | |||
359 | OSDArray GroupData = new OSDArray(data.Length); | ||
360 | OSDArray NewGroupData = new OSDArray(data.Length); | ||
361 | |||
362 | foreach (GroupMembershipData membership in data) | ||
363 | { | ||
364 | OSDMap GroupDataMap = new OSDMap(6); | ||
365 | OSDMap NewGroupDataMap = new OSDMap(1); | ||
366 | |||
367 | GroupDataMap.Add("GroupID", OSD.FromUUID(membership.GroupID)); | ||
368 | GroupDataMap.Add("GroupPowers", OSD.FromULong(membership.GroupPowers)); | ||
369 | GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(membership.AcceptNotices)); | ||
370 | GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(membership.GroupPicture)); | ||
371 | GroupDataMap.Add("Contribution", OSD.FromInteger(membership.Contribution)); | ||
372 | GroupDataMap.Add("GroupName", OSD.FromString(membership.GroupName)); | ||
373 | NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(membership.ListInProfile)); | ||
374 | |||
375 | GroupData.Add(GroupDataMap); | ||
376 | NewGroupData.Add(NewGroupDataMap); | ||
377 | } | ||
378 | |||
379 | OSDMap llDataStruct = new OSDMap(3); | ||
380 | llDataStruct.Add("AgentData", AgentData); | ||
381 | llDataStruct.Add("GroupData", GroupData); | ||
382 | llDataStruct.Add("NewGroupData", NewGroupData); | ||
383 | |||
384 | return BuildEvent("AgentGroupDataUpdate", llDataStruct); | ||
385 | |||
386 | } | ||
387 | |||
388 | public static OSD PlacesQuery(PlacesReplyPacket PlacesReply) | 230 | public static OSD PlacesQuery(PlacesReplyPacket PlacesReply) |
389 | { | 231 | { |
390 | OSDMap placesReply = new OSDMap(); | 232 | OSDMap placesReply = new OSDMap(); |
@@ -426,35 +268,5 @@ namespace OpenSim.Region.ClientStack.Linden | |||
426 | 268 | ||
427 | return placesReply; | 269 | return placesReply; |
428 | } | 270 | } |
429 | |||
430 | public static OSD ParcelProperties(ParcelPropertiesMessage parcelPropertiesMessage) | ||
431 | { | ||
432 | OSDMap message = new OSDMap(); | ||
433 | message.Add("message", OSD.FromString("ParcelProperties")); | ||
434 | OSD message_body = parcelPropertiesMessage.Serialize(); | ||
435 | message.Add("body", message_body); | ||
436 | return message; | ||
437 | } | ||
438 | |||
439 | public static OSD partPhysicsProperties(uint localID, byte physhapetype, | ||
440 | float density, float friction, float bounce, float gravmod) | ||
441 | { | ||
442 | |||
443 | OSDMap physinfo = new OSDMap(6); | ||
444 | physinfo["LocalID"] = localID; | ||
445 | physinfo["Density"] = density; | ||
446 | physinfo["Friction"] = friction; | ||
447 | physinfo["GravityMultiplier"] = gravmod; | ||
448 | physinfo["Restitution"] = bounce; | ||
449 | physinfo["PhysicsShapeType"] = (int)physhapetype; | ||
450 | |||
451 | OSDArray array = new OSDArray(1); | ||
452 | array.Add(physinfo); | ||
453 | |||
454 | OSDMap llsdBody = new OSDMap(1); | ||
455 | llsdBody.Add("ObjectData", array); | ||
456 | |||
457 | return BuildEvent("ObjectPhysicsProperties", llsdBody); | ||
458 | } | ||
459 | } | 271 | } |
460 | } | 272 | } |