Extend TestAddClient() to check that the first packet received is an ack packet
parent
9dc1000c27
commit
7ca688f5c5
|
@ -328,7 +328,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
/// The method to call if the packet is not acked by the client. If null, then a standard
|
/// The method to call if the packet is not acked by the client. If null, then a standard
|
||||||
/// resend of the packet is done.
|
/// resend of the packet is done.
|
||||||
/// </param>
|
/// </param>
|
||||||
public void SendPacket(
|
public virtual void SendPacket(
|
||||||
LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method)
|
LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method)
|
||||||
{
|
{
|
||||||
// CoarseLocationUpdate packets cannot be split in an automated way
|
// CoarseLocationUpdate packets cannot be split in an automated way
|
||||||
|
@ -928,6 +928,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
// buffer.RemoteEndPoint, (DateTime.Now - startTime).Milliseconds);
|
// buffer.RemoteEndPoint, (DateTime.Now - startTime).Milliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send an ack immediately to the given endpoint.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// FIXME: Might be possible to use SendPacketData() like everything else, but this will require refactoring so
|
||||||
|
/// that we can obtain the UDPClient easily at this point.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="remoteEndpoint"></param>
|
||||||
|
/// <param name="sequenceNumber"></param>
|
||||||
private void SendAckImmediate(IPEndPoint remoteEndpoint, uint sequenceNumber)
|
private void SendAckImmediate(IPEndPoint remoteEndpoint, uint sequenceNumber)
|
||||||
{
|
{
|
||||||
PacketAckPacket ack = new PacketAckPacket();
|
PacketAckPacket ack = new PacketAckPacket();
|
||||||
|
@ -936,6 +945,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
ack.Packets[0] = new PacketAckPacket.PacketsBlock();
|
ack.Packets[0] = new PacketAckPacket.PacketsBlock();
|
||||||
ack.Packets[0].ID = sequenceNumber;
|
ack.Packets[0].ID = sequenceNumber;
|
||||||
|
|
||||||
|
SendAckImmediate(remoteEndpoint, ack);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void SendAckImmediate(IPEndPoint remoteEndpoint, PacketAckPacket ack)
|
||||||
|
{
|
||||||
byte[] packetData = ack.ToBytes();
|
byte[] packetData = ack.ToBytes();
|
||||||
int length = packetData.Length;
|
int length = packetData.Length;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ using OpenSim.Region.Framework.Scenes;
|
||||||
using OpenSim.Tests.Common;
|
using OpenSim.Tests.Common;
|
||||||
using OpenSim.Tests.Common.Mock;
|
using OpenSim.Tests.Common.Mock;
|
||||||
|
|
||||||
namespace OpenSim.Region.ClientStack.LindenUDP
|
namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This will contain basic tests for the LindenUDP client stack
|
/// This will contain basic tests for the LindenUDP client stack
|
||||||
|
@ -167,8 +167,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
uint port = 0;
|
uint port = 0;
|
||||||
AgentCircuitManager acm = scene.AuthenticateHandler;
|
AgentCircuitManager acm = scene.AuthenticateHandler;
|
||||||
|
|
||||||
LLUDPServer llUdpServer
|
TestLLUDPServer llUdpServer
|
||||||
= new LLUDPServer(IPAddress.Any, ref port, 0, false, new IniConfigSource(), acm);
|
= new TestLLUDPServer(IPAddress.Any, ref port, 0, false, new IniConfigSource(), acm);
|
||||||
llUdpServer.AddScene(scene);
|
llUdpServer.AddScene(scene);
|
||||||
|
|
||||||
UseCircuitCodePacket uccp = new UseCircuitCodePacket();
|
UseCircuitCodePacket uccp = new UseCircuitCodePacket();
|
||||||
|
@ -201,6 +201,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
// Should succeed now
|
// Should succeed now
|
||||||
ScenePresence sp = scene.GetScenePresence(myAgentUuid);
|
ScenePresence sp = scene.GetScenePresence(myAgentUuid);
|
||||||
Assert.That(sp.UUID, Is.EqualTo(myAgentUuid));
|
Assert.That(sp.UUID, Is.EqualTo(myAgentUuid));
|
||||||
|
|
||||||
|
// FIXME: We're still replying to an ack when the client is not authorized, which is not correct behaviour.
|
||||||
|
Assert.That(llUdpServer.PacketsSent.Count, Is.EqualTo(2));
|
||||||
|
|
||||||
|
Packet packet = llUdpServer.PacketsSent[1];
|
||||||
|
Assert.That(packet, Is.InstanceOf(typeof(PacketAckPacket)));
|
||||||
|
|
||||||
|
PacketAckPacket ackPacket = packet as PacketAckPacket;
|
||||||
|
Assert.That(ackPacket.Packets.Length, Is.EqualTo(1));
|
||||||
|
Assert.That(ackPacket.Packets[0].ID, Is.EqualTo(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// /// <summary>
|
// /// <summary>
|
||||||
|
|
|
@ -36,107 +36,106 @@ using OpenSim.Framework;
|
||||||
namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This class enables synchronous testing of the LLUDPServer by allowing us to load our own data into the end
|
/// This class enables regression testing of the LLUDPServer by allowing us to intercept outgoing data.
|
||||||
/// receive event
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TestLLUDPServer : LLUDPServer
|
public class TestLLUDPServer : LLUDPServer
|
||||||
{
|
{
|
||||||
|
public List<Packet> PacketsSent { get; private set; }
|
||||||
|
|
||||||
public TestLLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager)
|
public TestLLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager)
|
||||||
: base(listenIP, ref port, proxyPortOffsetParm, allow_alternate_port, configSource, circuitManager)
|
: base(listenIP, ref port, proxyPortOffsetParm, allow_alternate_port, configSource, circuitManager)
|
||||||
{}
|
{
|
||||||
|
PacketsSent = new List<Packet>();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
public override void SendAckImmediate(IPEndPoint remoteEndpoint, PacketAckPacket ack)
|
||||||
/// The chunks of data to pass to the LLUDPServer when it calls EndReceive
|
{
|
||||||
/// </summary>
|
PacketsSent.Add(ack);
|
||||||
protected Queue<ChunkSenderTuple> m_chunksToLoad = new Queue<ChunkSenderTuple>();
|
}
|
||||||
|
|
||||||
// protected override void BeginReceive()
|
public override void SendPacket(
|
||||||
// {
|
LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method)
|
||||||
// if (m_chunksToLoad.Count > 0 && m_chunksToLoad.Peek().BeginReceiveException)
|
{
|
||||||
// {
|
PacketsSent.Add(packet);
|
||||||
// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
|
}
|
||||||
// reusedEpSender = tuple.Sender;
|
|
||||||
// throw new SocketException();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// protected override bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender)
|
//// /// <summary>
|
||||||
// {
|
//// /// The chunks of data to pass to the LLUDPServer when it calls EndReceive
|
||||||
// numBytes = 0;
|
//// /// </summary>
|
||||||
|
//// protected Queue<ChunkSenderTuple> m_chunksToLoad = new Queue<ChunkSenderTuple>();
|
||||||
//
|
//
|
||||||
// //m_log.Debug("Queue size " + m_chunksToLoad.Count);
|
//// protected override void BeginReceive()
|
||||||
|
//// {
|
||||||
|
//// if (m_chunksToLoad.Count > 0 && m_chunksToLoad.Peek().BeginReceiveException)
|
||||||
|
//// {
|
||||||
|
//// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
|
||||||
|
//// reusedEpSender = tuple.Sender;
|
||||||
|
//// throw new SocketException();
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
//
|
//
|
||||||
// if (m_chunksToLoad.Count <= 0)
|
//// protected override bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender)
|
||||||
// return false;
|
//// {
|
||||||
|
//// numBytes = 0;
|
||||||
|
////
|
||||||
|
//// //m_log.Debug("Queue size " + m_chunksToLoad.Count);
|
||||||
|
////
|
||||||
|
//// if (m_chunksToLoad.Count <= 0)
|
||||||
|
//// return false;
|
||||||
|
////
|
||||||
|
//// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
|
||||||
|
//// RecvBuffer = tuple.Data;
|
||||||
|
//// numBytes = tuple.Data.Length;
|
||||||
|
//// epSender = tuple.Sender;
|
||||||
|
////
|
||||||
|
//// return true;
|
||||||
|
//// }
|
||||||
//
|
//
|
||||||
// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
|
//// public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
|
||||||
// RecvBuffer = tuple.Data;
|
//// {
|
||||||
// numBytes = tuple.Data.Length;
|
//// // Don't do anything just yet
|
||||||
// epSender = tuple.Sender;
|
//// }
|
||||||
//
|
//
|
||||||
// return true;
|
// /// <summary>
|
||||||
// }
|
// /// Signal that this chunk should throw an exception on Socket.BeginReceive()
|
||||||
|
// /// </summary>
|
||||||
// public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
|
// /// <param name="epSender"></param>
|
||||||
|
// public void LoadReceiveWithBeginException(EndPoint epSender)
|
||||||
// {
|
// {
|
||||||
// // Don't do anything just yet
|
// ChunkSenderTuple tuple = new ChunkSenderTuple(epSender);
|
||||||
|
// tuple.BeginReceiveException = true;
|
||||||
|
// m_chunksToLoad.Enqueue(tuple);
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// Signal that this chunk should throw an exception on Socket.BeginReceive()
|
// /// Load some data to be received by the LLUDPServer on the next receive call
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="epSender"></param>
|
// /// <param name="data"></param>
|
||||||
public void LoadReceiveWithBeginException(EndPoint epSender)
|
// /// <param name="epSender"></param>
|
||||||
{
|
// public void LoadReceive(byte[] data, EndPoint epSender)
|
||||||
ChunkSenderTuple tuple = new ChunkSenderTuple(epSender);
|
|
||||||
tuple.BeginReceiveException = true;
|
|
||||||
m_chunksToLoad.Enqueue(tuple);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Load some data to be received by the LLUDPServer on the next receive call
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="data"></param>
|
|
||||||
/// <param name="epSender"></param>
|
|
||||||
public void LoadReceive(byte[] data, EndPoint epSender)
|
|
||||||
{
|
|
||||||
m_chunksToLoad.Enqueue(new ChunkSenderTuple(data, epSender));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Load a packet to be received by the LLUDPServer on the next receive call
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="packet"></param>
|
|
||||||
public void LoadReceive(Packet packet, EndPoint epSender)
|
|
||||||
{
|
|
||||||
LoadReceive(packet.ToBytes(), epSender);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Calls the protected asynchronous result method. This fires out all data chunks currently queued for send
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="result"></param>
|
|
||||||
public void ReceiveData(IAsyncResult result)
|
|
||||||
{
|
|
||||||
// Doesn't work the same way anymore
|
|
||||||
// while (m_chunksToLoad.Count > 0)
|
|
||||||
// OnReceivedData(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Has a circuit with the given code been established?
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="circuitCode"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool HasCircuit(uint circuitCode)
|
|
||||||
{
|
|
||||||
// lock (clientCircuits_reverse)
|
|
||||||
// {
|
// {
|
||||||
// return clientCircuits_reverse.ContainsKey(circuitCode);
|
// m_chunksToLoad.Enqueue(new ChunkSenderTuple(data, epSender));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /// <summary>
|
||||||
|
// /// Load a packet to be received by the LLUDPServer on the next receive call
|
||||||
|
// /// </summary>
|
||||||
|
// /// <param name="packet"></param>
|
||||||
|
// public void LoadReceive(Packet packet, EndPoint epSender)
|
||||||
|
// {
|
||||||
|
// LoadReceive(packet.ToBytes(), epSender);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /// <summary>
|
||||||
|
// /// Calls the protected asynchronous result method. This fires out all data chunks currently queued for send
|
||||||
|
// /// </summary>
|
||||||
|
// /// <param name="result"></param>
|
||||||
|
// public void ReceiveData(IAsyncResult result)
|
||||||
|
// {
|
||||||
|
// // Doesn't work the same way anymore
|
||||||
|
//// while (m_chunksToLoad.Count > 0)
|
||||||
|
//// OnReceivedData(result);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue