aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2012-10-18 00:06:43 +0100
committerMelanie2012-10-18 00:06:43 +0100
commit3651cc0378168ccd6b53fd804dce0d13c167570d (patch)
tree3be9a34cf89bd263c83cc813dfa842e2997fec57 /OpenSim
parentMerge branch 'master' into careminster (diff)
parentminor: move recent OnAgentUpdate/OnPreAgentUpdate event doc up into IClientAP... (diff)
downloadopensim-SC_OLD-3651cc0378168ccd6b53fd804dce0d13c167570d.zip
opensim-SC_OLD-3651cc0378168ccd6b53fd804dce0d13c167570d.tar.gz
opensim-SC_OLD-3651cc0378168ccd6b53fd804dce0d13c167570d.tar.bz2
opensim-SC_OLD-3651cc0378168ccd6b53fd804dce0d13c167570d.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/IClientAPI.cs15
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs109
2 files changed, 83 insertions, 41 deletions
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 4ae533e..e95149d 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -815,8 +815,23 @@ namespace OpenSim.Framework
815 event Action<IClientAPI> OnRegionHandShakeReply; 815 event Action<IClientAPI> OnRegionHandShakeReply;
816 event GenericCall1 OnRequestWearables; 816 event GenericCall1 OnRequestWearables;
817 event Action<IClientAPI, bool> OnCompleteMovementToRegion; 817 event Action<IClientAPI, bool> OnCompleteMovementToRegion;
818
819 /// <summary>
820 /// Called when an AgentUpdate message is received and before OnAgentUpdate.
821 /// </summary>
822 /// <remarks>
823 /// Listeners must not retain a reference to AgentUpdateArgs since this object may be reused for subsequent AgentUpdates.
824 /// </remarks>
818 event UpdateAgent OnPreAgentUpdate; 825 event UpdateAgent OnPreAgentUpdate;
826
827 /// <summary>
828 /// Called when an AgentUpdate message is received and after OnPreAgentUpdate.
829 /// </summary>
830 /// <remarks>
831 /// Listeners must not retain a reference to AgentUpdateArgs since this object may be reused for subsequent AgentUpdates.
832 /// </remarks>
819 event UpdateAgent OnAgentUpdate; 833 event UpdateAgent OnAgentUpdate;
834
820 event AgentRequestSit OnAgentRequestSit; 835 event AgentRequestSit OnAgentRequestSit;
821 event AgentSit OnAgentSit; 836 event AgentSit OnAgentSit;
822 event AvatarPickerRequest OnAvatarPickerRequest; 837 event AvatarPickerRequest OnAvatarPickerRequest;
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 78f5ac9..f80a00f 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -92,8 +92,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP
92 public event ObjectDeselect OnObjectDetach; 92 public event ObjectDeselect OnObjectDetach;
93 public event ObjectDrop OnObjectDrop; 93 public event ObjectDrop OnObjectDrop;
94 public event Action<IClientAPI, bool> OnCompleteMovementToRegion; 94 public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
95
96 /// <summary>
97 /// Called when an AgentUpdate message is received and before OnAgentUpdate.
98 /// </summary>
99 /// <remarks>
100 /// Listeners must not retain a reference to AgentUpdateArgs since this object is reused for subsequent AgentUpdates.
101 /// </remarks>
95 public event UpdateAgent OnPreAgentUpdate; 102 public event UpdateAgent OnPreAgentUpdate;
103
104 /// <summary>
105 /// Called when an AgentUpdate message is received and after OnPreAgentUpdate.
106 /// </summary>
107 /// <remarks>
108 /// Listeners must not retain a reference to AgentUpdateArgs since this object is reused for subsequent AgentUpdates.
109 /// </remarks>
96 public event UpdateAgent OnAgentUpdate; 110 public event UpdateAgent OnAgentUpdate;
111
97 public event AgentRequestSit OnAgentRequestSit; 112 public event AgentRequestSit OnAgentRequestSit;
98 public event AgentSit OnAgentSit; 113 public event AgentSit OnAgentSit;
99 public event AvatarPickerRequest OnAvatarPickerRequest; 114 public event AvatarPickerRequest OnAvatarPickerRequest;
@@ -355,7 +370,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
355 private bool m_deliverPackets = true; 370 private bool m_deliverPackets = true;
356 private int m_animationSequenceNumber = 1; 371 private int m_animationSequenceNumber = 1;
357 private bool m_SendLogoutPacketWhenClosing = true; 372 private bool m_SendLogoutPacketWhenClosing = true;
358 private AgentUpdateArgs lastarg; 373
374 /// <summary>
375 /// We retain a single AgentUpdateArgs so that we can constantly reuse it rather than construct a new one for
376 /// every single incoming AgentUpdate. Every client sends 10 AgentUpdate UDP messages per second, even if it
377 /// is doing absolutely nothing.
378 /// </summary>
379 /// <remarks>
380 /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods
381 /// cannot retain a reference to it outside of that method.
382 /// </remarks>
383 private AgentUpdateArgs m_lastAgentUpdateArgs;
359 384
360 protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); 385 protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
361 protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers 386 protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
@@ -5293,7 +5318,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5293 protected virtual void RegisterLocalPacketHandlers() 5318 protected virtual void RegisterLocalPacketHandlers()
5294 { 5319 {
5295 AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout); 5320 AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout);
5321
5322 // If AgentUpdate is ever handled asynchronously, then we will also need to construct a new AgentUpdateArgs
5323 // for each AgentUpdate packet.
5296 AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false); 5324 AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false);
5325
5297 AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false); 5326 AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false);
5298 AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false); 5327 AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false);
5299 AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false); 5328 AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false);
@@ -5526,74 +5555,72 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5526 { 5555 {
5527 if (OnAgentUpdate != null) 5556 if (OnAgentUpdate != null)
5528 { 5557 {
5529 bool update = false; 5558 AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
5530 AgentUpdatePacket agenUpdate = (AgentUpdatePacket)packet;
5531 5559
5532 #region Packet Session and User Check 5560 #region Packet Session and User Check
5533 if (agenUpdate.AgentData.SessionID != SessionId || agenUpdate.AgentData.AgentID != AgentId) 5561 if (agentUpdate.AgentData.SessionID != SessionId || agentUpdate.AgentData.AgentID != AgentId)
5534 { 5562 {
5535 PacketPool.Instance.ReturnPacket(packet); 5563 PacketPool.Instance.ReturnPacket(packet);
5536 return false; 5564 return false;
5537 } 5565 }
5538 #endregion 5566 #endregion
5539 5567
5540 AgentUpdatePacket.AgentDataBlock x = agenUpdate.AgentData; 5568 bool update = false;
5541 5569 AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData;
5542 // We can only check when we have something to check
5543 // against.
5544 5570
5545 if (lastarg != null) 5571 if (m_lastAgentUpdateArgs != null)
5546 { 5572 {
5573 // These should be ordered from most-likely to
5574 // least likely to change. I've made an initial
5575 // guess at that.
5547 update = 5576 update =
5548 ( 5577 (
5549 (x.BodyRotation != lastarg.BodyRotation) || 5578 (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) ||
5550 (x.CameraAtAxis != lastarg.CameraAtAxis) || 5579 (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) ||
5551 (x.CameraCenter != lastarg.CameraCenter) || 5580 (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) ||
5552 (x.CameraLeftAxis != lastarg.CameraLeftAxis) || 5581 (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) ||
5553 (x.CameraUpAxis != lastarg.CameraUpAxis) || 5582 (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) ||
5554 (x.ControlFlags != lastarg.ControlFlags) || 5583 (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) ||
5555 (x.ControlFlags != 0) || 5584 (x.ControlFlags != 0) ||
5556 (x.Far != lastarg.Far) || 5585 (x.Far != m_lastAgentUpdateArgs.Far) ||
5557 (x.Flags != lastarg.Flags) || 5586 (x.Flags != m_lastAgentUpdateArgs.Flags) ||
5558 (x.State != lastarg.State) || 5587 (x.State != m_lastAgentUpdateArgs.State) ||
5559 (x.HeadRotation != lastarg.HeadRotation) || 5588 (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) ||
5560 (x.SessionID != lastarg.SessionID) || 5589 (x.SessionID != m_lastAgentUpdateArgs.SessionID) ||
5561 (x.AgentID != lastarg.AgentID) 5590 (x.AgentID != m_lastAgentUpdateArgs.AgentID)
5562 ); 5591 );
5563 } 5592 }
5564 else 5593 else
5565 { 5594 {
5595 m_lastAgentUpdateArgs = new AgentUpdateArgs();
5566 update = true; 5596 update = true;
5567 } 5597 }
5568 5598
5569 // These should be ordered from most-likely to
5570 // least likely to change. I've made an initial
5571 // guess at that.
5572
5573 if (update) 5599 if (update)
5574 { 5600 {
5575// m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name); 5601// m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name);
5576 5602
5577 AgentUpdateArgs arg = new AgentUpdateArgs(); 5603 m_lastAgentUpdateArgs.AgentID = x.AgentID;
5578 arg.AgentID = x.AgentID; 5604 m_lastAgentUpdateArgs.BodyRotation = x.BodyRotation;
5579 arg.BodyRotation = x.BodyRotation; 5605 m_lastAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis;
5580 arg.CameraAtAxis = x.CameraAtAxis; 5606 m_lastAgentUpdateArgs.CameraCenter = x.CameraCenter;
5581 arg.CameraCenter = x.CameraCenter; 5607 m_lastAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
5582 arg.CameraLeftAxis = x.CameraLeftAxis; 5608 m_lastAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
5583 arg.CameraUpAxis = x.CameraUpAxis; 5609 m_lastAgentUpdateArgs.ControlFlags = x.ControlFlags;
5584 arg.ControlFlags = x.ControlFlags; 5610 m_lastAgentUpdateArgs.Far = x.Far;
5585 arg.Far = x.Far; 5611 m_lastAgentUpdateArgs.Flags = x.Flags;
5586 arg.Flags = x.Flags; 5612 m_lastAgentUpdateArgs.HeadRotation = x.HeadRotation;
5587 arg.HeadRotation = x.HeadRotation; 5613 m_lastAgentUpdateArgs.SessionID = x.SessionID;
5588 arg.SessionID = x.SessionID; 5614 m_lastAgentUpdateArgs.State = x.State;
5589 arg.State = x.State; 5615
5590 UpdateAgent handlerAgentUpdate = OnAgentUpdate; 5616 UpdateAgent handlerAgentUpdate = OnAgentUpdate;
5591 UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate; 5617 UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
5592 lastarg = arg; // save this set of arguments for nexttime 5618
5593 if (handlerPreAgentUpdate != null) 5619 if (handlerPreAgentUpdate != null)
5594 OnPreAgentUpdate(this, arg); 5620 OnPreAgentUpdate(this, m_lastAgentUpdateArgs);
5621
5595 if (handlerAgentUpdate != null) 5622 if (handlerAgentUpdate != null)
5596 OnAgentUpdate(this, arg); 5623 OnAgentUpdate(this, m_lastAgentUpdateArgs);
5597 5624
5598 handlerAgentUpdate = null; 5625 handlerAgentUpdate = null;
5599 handlerPreAgentUpdate = null; 5626 handlerPreAgentUpdate = null;