* Extend PacketHandlerTest to fire in a packet.

* Can't test result yet since the Client thread handles it with unpredictable timing
0.6.2-post-fixes
Justin Clarke Casey 2009-01-12 18:45:03 +00:00
parent fb8faa8336
commit d4d2c19594
6 changed files with 46 additions and 19 deletions

View File

@ -36,6 +36,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public delegate void PacketDrop(Packet pack, Object id); public delegate void PacketDrop(Packet pack, Object id);
public delegate bool SynchronizeClientHandler(IScene scene, Packet packet, UUID agentID, ThrottleOutPacketType throttlePacketType); public delegate bool SynchronizeClientHandler(IScene scene, Packet packet, UUID agentID, ThrottleOutPacketType throttlePacketType);
/// <summary>
/// Interface to a class that handles all the activity involved with maintaining the client circuit (handling acks,
/// resends, pings, etc.)
/// </summary>
public interface ILLPacketHandler public interface ILLPacketHandler
{ {
event PacketStats OnPacketStats; event PacketStats OnPacketStats;
@ -48,8 +52,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
bool ReliableIsImportant { get; set; } bool ReliableIsImportant { get; set; }
int MaxReliableResends { get; set; } int MaxReliableResends { get; set; }
/// <summary>
/// Initial handling of a received packet. It will be processed later in ProcessInPacket()
/// </summary>
/// <param name="packet"></param>
void InPacket(Packet packet); void InPacket(Packet packet);
/// <summary>
/// Take action depending on the type and contents of an received packet.
/// </summary>
/// <param name="item"></param>
void ProcessInPacket(LLQueItem item); void ProcessInPacket(LLQueItem item);
void ProcessOutPacket(LLQueItem item); void ProcessOutPacket(LLQueItem item);
void OutPacket(Packet NewPack, void OutPacket(Packet NewPack,
ThrottleOutPacketType throttlePacketType); ThrottleOutPacketType throttlePacketType);

View File

@ -4109,7 +4109,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_PacketHandler.InPacket((Packet) NewPack); m_PacketHandler.InPacket((Packet) NewPack);
} }
/// <summary> /// <summary>
/// This is the starting point for sending a simulator packet out to the client. /// This is the starting point for sending a simulator packet out to the client.
/// ///
@ -4185,8 +4184,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
/// <summary> /// <summary>
/// Entryway from the client to the simulator /// Entryway from the client to the simulator. All UDP packets from the client will end up here
/// all UDP packets from the client will end up here
/// </summary> /// </summary>
/// <param name="Pack">OpenMetaverse.packet</param> /// <param name="Pack">OpenMetaverse.packet</param>
public void ProcessInPacket(Packet Pack) public void ProcessInPacket(Packet Pack)
@ -4483,6 +4481,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
} }
break; break;
case PacketType.RezSingleAttachmentFromInv: case PacketType.RezSingleAttachmentFromInv:
handlerRezSingleAttachment = OnRezSingleAttachmentFromInv; handlerRezSingleAttachment = OnRezSingleAttachmentFromInv;
if (handlerRezSingleAttachment != null) if (handlerRezSingleAttachment != null)
@ -4493,6 +4492,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
break; break;
case PacketType.DetachAttachmentIntoInv: case PacketType.DetachAttachmentIntoInv:
handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv; handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv;
if (handlerDetachAttachmentIntoInv != null) if (handlerDetachAttachmentIntoInv != null)
@ -4505,6 +4505,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
handlerDetachAttachmentIntoInv(itemID, this); handlerDetachAttachmentIntoInv(itemID, this);
} }
break; break;
case PacketType.ObjectAttach: case PacketType.ObjectAttach:
if (OnObjectAttach != null) if (OnObjectAttach != null)
{ {
@ -4520,10 +4521,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
} }
} }
break; break;
case PacketType.ObjectDetach: case PacketType.ObjectDetach:
ObjectDetachPacket dett = (ObjectDetachPacket)Pack; ObjectDetachPacket dett = (ObjectDetachPacket)Pack;
for (int j = 0; j < dett.ObjectData.Length; j++) for (int j = 0; j < dett.ObjectData.Length; j++)
{ {
@ -4535,8 +4535,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
} }
break; break;
case PacketType.ObjectDrop: case PacketType.ObjectDrop:
ObjectDropPacket dropp = (ObjectDropPacket)Pack; ObjectDropPacket dropp = (ObjectDropPacket)Pack;
for (int j = 0; j < dropp.ObjectData.Length; j++) for (int j = 0; j < dropp.ObjectData.Length; j++)
@ -4549,6 +4549,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
} }
break; break;
case PacketType.SetAlwaysRun: case PacketType.SetAlwaysRun:
SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack; SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack;
@ -4557,6 +4558,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
handlerSetAlwaysRun(this, run.AgentData.AlwaysRun); handlerSetAlwaysRun(this, run.AgentData.AlwaysRun);
break; break;
case PacketType.CompleteAgentMovement: case PacketType.CompleteAgentMovement:
handlerCompleteMovementToRegion = OnCompleteMovementToRegion; handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
if (handlerCompleteMovementToRegion != null) if (handlerCompleteMovementToRegion != null)
@ -4566,6 +4568,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
handlerCompleteMovementToRegion = null; handlerCompleteMovementToRegion = null;
break; break;
case PacketType.AgentUpdate: case PacketType.AgentUpdate:
if (OnAgentUpdate != null) if (OnAgentUpdate != null)
{ {
@ -4594,6 +4597,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
//agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotationa); //agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotationa);
} }
break; break;
case PacketType.AgentAnimation: case PacketType.AgentAnimation:
AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
@ -4620,6 +4624,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
} }
break; break;
case PacketType.AgentRequestSit: case PacketType.AgentRequestSit:
if (OnAgentRequestSit != null) if (OnAgentRequestSit != null)
{ {

View File

@ -524,7 +524,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
else if (packet.Type == PacketType.StartPingCheck) else if (packet.Type == PacketType.StartPingCheck)
{ {
StartPingCheckPacket startPing = (StartPingCheckPacket)packet; StartPingCheckPacket startPing = (StartPingCheckPacket)packet;
CompletePingCheckPacket endPing = (CompletePingCheckPacket)PacketPool.Instance.GetPacket(PacketType.CompletePingCheck); CompletePingCheckPacket endPing
= (CompletePingCheckPacket)PacketPool.Instance.GetPacket(PacketType.CompletePingCheck);
endPing.PingID.PingID = startPing.PingID.PingID; endPing.PingID.PingID = startPing.PingID.PingID;
OutPacket(endPing, ThrottleOutPacketType.Task); OutPacket(endPing, ThrottleOutPacketType.Task);

View File

@ -36,6 +36,10 @@ using OpenSim.Framework.Communications.Cache;
namespace OpenSim.Region.ClientStack.LindenUDP namespace OpenSim.Region.ClientStack.LindenUDP
{ {
/// <summary>
/// This class sets up new client stacks. It also handles the immediate distribution of incoming packets to
/// client stacks
/// </summary>
public class LLPacketServer public class LLPacketServer
{ {
// private static readonly log4net.ILog m_log // private static readonly log4net.ILog m_log
@ -185,9 +189,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public virtual void CloseCircuit(uint circuitcode) public virtual void CloseCircuit(uint circuitcode)
{ {
m_networkHandler.RemoveClientCircuit(circuitcode); m_networkHandler.RemoveClientCircuit(circuitcode);
// XXX: Why is this commented out? Possibly because close mechanisms are so tangled right now
//m_scene.ClientManager.CloseAllAgents(circuitcode);
} }
/// <summary> /// <summary>

View File

@ -27,7 +27,9 @@
using Nini.Config; using Nini.Config;
using NUnit.Framework; using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.Packets;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.ClientStack.LindenUDP; using OpenSim.Region.ClientStack.LindenUDP;
using OpenSim.Tests.Common.Mock; using OpenSim.Tests.Common.Mock;
@ -63,7 +65,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
AgentCircuitManager acm; AgentCircuitManager acm;
SetupStack(new MockScene(), out testLLUDPServer, out testLLPacketServer, out acm); SetupStack(new MockScene(), out testLLUDPServer, out testLLPacketServer, out acm);
new LLPacketHandler(new TestClient(agent), testLLPacketServer, new ClientStackUserSettings()); ILLPacketHandler packetHandler
= new LLPacketHandler(new TestClient(agent), testLLPacketServer, new ClientStackUserSettings());
packetHandler.InPacket(new AgentAnimationPacket());
//Assert.That(Is.Not.Null(packetHandler.PacketQueue.Dequeue()));
} }
/// <summary> /// <summary>

View File

@ -343,6 +343,14 @@ namespace OpenSim.Tests.Common.Mock
set { } set { }
} }
private uint m_circuitCode;
public uint CircuitCode
{
get { return m_circuitCode; }
set { m_circuitCode = value; }
}
/// <summary> /// <summary>
/// Constructor /// Constructor
/// </summary> /// </summary>
@ -753,14 +761,6 @@ namespace OpenSim.Tests.Common.Mock
{ {
} }
private uint m_circuitCode;
public uint CircuitCode
{
get { return m_circuitCode; }
set { m_circuitCode = value; }
}
public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message) public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
{ {