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
|
||||
/// resend of the packet is done.
|
||||
/// </param>
|
||||
public void SendPacket(
|
||||
public virtual void SendPacket(
|
||||
LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method)
|
||||
{
|
||||
// CoarseLocationUpdate packets cannot be split in an automated way
|
||||
|
@ -928,6 +928,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
// 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)
|
||||
{
|
||||
PacketAckPacket ack = new PacketAckPacket();
|
||||
|
@ -936,6 +945,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
ack.Packets[0] = new PacketAckPacket.PacketsBlock();
|
||||
ack.Packets[0].ID = sequenceNumber;
|
||||
|
||||
SendAckImmediate(remoteEndpoint, ack);
|
||||
}
|
||||
|
||||
public virtual void SendAckImmediate(IPEndPoint remoteEndpoint, PacketAckPacket ack)
|
||||
{
|
||||
byte[] packetData = ack.ToBytes();
|
||||
int length = packetData.Length;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ using OpenSim.Region.Framework.Scenes;
|
|||
using OpenSim.Tests.Common;
|
||||
using OpenSim.Tests.Common.Mock;
|
||||
|
||||
namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// This will contain basic tests for the LindenUDP client stack
|
||||
|
@ -167,8 +167,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
uint port = 0;
|
||||
AgentCircuitManager acm = scene.AuthenticateHandler;
|
||||
|
||||
LLUDPServer llUdpServer
|
||||
= new LLUDPServer(IPAddress.Any, ref port, 0, false, new IniConfigSource(), acm);
|
||||
TestLLUDPServer llUdpServer
|
||||
= new TestLLUDPServer(IPAddress.Any, ref port, 0, false, new IniConfigSource(), acm);
|
||||
llUdpServer.AddScene(scene);
|
||||
|
||||
UseCircuitCodePacket uccp = new UseCircuitCodePacket();
|
||||
|
@ -201,6 +201,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
// Should succeed now
|
||||
ScenePresence sp = scene.GetScenePresence(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>
|
||||
|
|
|
@ -36,107 +36,106 @@ using OpenSim.Framework;
|
|||
namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// This class enables synchronous testing of the LLUDPServer by allowing us to load our own data into the end
|
||||
/// receive event
|
||||
/// This class enables regression testing of the LLUDPServer by allowing us to intercept outgoing data.
|
||||
/// </summary>
|
||||
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)
|
||||
: base(listenIP, ref port, proxyPortOffsetParm, allow_alternate_port, configSource, circuitManager)
|
||||
{}
|
||||
{
|
||||
PacketsSent = new List<Packet>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The chunks of data to pass to the LLUDPServer when it calls EndReceive
|
||||
/// </summary>
|
||||
protected Queue<ChunkSenderTuple> m_chunksToLoad = new Queue<ChunkSenderTuple>();
|
||||
public override void SendAckImmediate(IPEndPoint remoteEndpoint, PacketAckPacket ack)
|
||||
{
|
||||
PacketsSent.Add(ack);
|
||||
}
|
||||
|
||||
// protected override void BeginReceive()
|
||||
// {
|
||||
// if (m_chunksToLoad.Count > 0 && m_chunksToLoad.Peek().BeginReceiveException)
|
||||
// {
|
||||
// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
|
||||
// reusedEpSender = tuple.Sender;
|
||||
// throw new SocketException();
|
||||
// }
|
||||
// }
|
||||
public override void SendPacket(
|
||||
LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method)
|
||||
{
|
||||
PacketsSent.Add(packet);
|
||||
}
|
||||
|
||||
// protected override bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender)
|
||||
// {
|
||||
// numBytes = 0;
|
||||
//// /// <summary>
|
||||
//// /// The chunks of data to pass to the LLUDPServer when it calls EndReceive
|
||||
//// /// </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)
|
||||
// return false;
|
||||
//// protected override bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender)
|
||||
//// {
|
||||
//// 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();
|
||||
// RecvBuffer = tuple.Data;
|
||||
// numBytes = tuple.Data.Length;
|
||||
// epSender = tuple.Sender;
|
||||
//// public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
|
||||
//// {
|
||||
//// // Don't do anything just yet
|
||||
//// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
|
||||
// /// <summary>
|
||||
// /// Signal that this chunk should throw an exception on Socket.BeginReceive()
|
||||
// /// </summary>
|
||||
// /// <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>
|
||||
/// Signal that this chunk should throw an exception on Socket.BeginReceive()
|
||||
/// </summary>
|
||||
/// <param name="epSender"></param>
|
||||
public void LoadReceiveWithBeginException(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)
|
||||
//
|
||||
// /// <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)
|
||||
// {
|
||||
// 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>
|
||||
|
|
Loading…
Reference in New Issue