From 32d0ef89c6fbaf14e669e9dd3a8508bc817fbd52 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 8 Dec 2011 21:45:02 +0000
Subject: Extend TestAddClient() to check that the first packet received is an
ack packet
---
.../Linden/UDP/Tests/TestLLUDPServer.cs | 177 ++++++++++-----------
1 file changed, 88 insertions(+), 89 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs
index dd7999a..0302385 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs
@@ -36,107 +36,106 @@ using OpenSim.Framework;
namespace OpenSim.Region.ClientStack.LindenUDP.Tests
{
///
- /// 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.
///
public class TestLLUDPServer : LLUDPServer
{
+ public List 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)
- {}
-
- ///
- /// The chunks of data to pass to the LLUDPServer when it calls EndReceive
- ///
- protected Queue m_chunksToLoad = new Queue();
-
-// protected override void BeginReceive()
-// {
-// if (m_chunksToLoad.Count > 0 && m_chunksToLoad.Peek().BeginReceiveException)
-// {
-// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
-// reusedEpSender = tuple.Sender;
-// throw new SocketException();
-// }
-// }
-
-// 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;
-// }
-
-// public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
-// {
-// // Don't do anything just yet
-// }
-
- ///
- /// Signal that this chunk should throw an exception on Socket.BeginReceive()
- ///
- ///
- public void LoadReceiveWithBeginException(EndPoint epSender)
- {
- ChunkSenderTuple tuple = new ChunkSenderTuple(epSender);
- tuple.BeginReceiveException = true;
- m_chunksToLoad.Enqueue(tuple);
- }
-
- ///
- /// Load some data to be received by the LLUDPServer on the next receive call
- ///
- ///
- ///
- public void LoadReceive(byte[] data, EndPoint epSender)
{
- m_chunksToLoad.Enqueue(new ChunkSenderTuple(data, epSender));
+ PacketsSent = new List();
}
-
- ///
- /// Load a packet to be received by the LLUDPServer on the next receive call
- ///
- ///
- public void LoadReceive(Packet packet, EndPoint epSender)
+
+ public override void SendAckImmediate(IPEndPoint remoteEndpoint, PacketAckPacket ack)
{
- LoadReceive(packet.ToBytes(), epSender);
+ PacketsSent.Add(ack);
}
-
- ///
- /// Calls the protected asynchronous result method. This fires out all data chunks currently queued for send
- ///
- ///
- public void ReceiveData(IAsyncResult result)
+
+ public override void SendPacket(
+ LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method)
{
- // Doesn't work the same way anymore
-// while (m_chunksToLoad.Count > 0)
-// OnReceivedData(result);
+ PacketsSent.Add(packet);
}
-
- ///
- /// Has a circuit with the given code been established?
- ///
- ///
- ///
- public bool HasCircuit(uint circuitCode)
- {
-// lock (clientCircuits_reverse)
-// {
-// return clientCircuits_reverse.ContainsKey(circuitCode);
-// }
- return true;
- }
+//// ///
+//// /// The chunks of data to pass to the LLUDPServer when it calls EndReceive
+//// ///
+//// protected Queue m_chunksToLoad = new Queue();
+//
+//// protected override void BeginReceive()
+//// {
+//// if (m_chunksToLoad.Count > 0 && m_chunksToLoad.Peek().BeginReceiveException)
+//// {
+//// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
+//// reusedEpSender = tuple.Sender;
+//// throw new SocketException();
+//// }
+//// }
+//
+//// 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;
+//// }
+//
+//// public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
+//// {
+//// // Don't do anything just yet
+//// }
+//
+// ///
+// /// Signal that this chunk should throw an exception on Socket.BeginReceive()
+// ///
+// ///
+// public void LoadReceiveWithBeginException(EndPoint epSender)
+// {
+// ChunkSenderTuple tuple = new ChunkSenderTuple(epSender);
+// tuple.BeginReceiveException = true;
+// m_chunksToLoad.Enqueue(tuple);
+// }
+//
+// ///
+// /// Load some data to be received by the LLUDPServer on the next receive call
+// ///
+// ///
+// ///
+// public void LoadReceive(byte[] data, EndPoint epSender)
+// {
+// m_chunksToLoad.Enqueue(new ChunkSenderTuple(data, epSender));
+// }
+//
+// ///
+// /// Load a packet to be received by the LLUDPServer on the next receive call
+// ///
+// ///
+// public void LoadReceive(Packet packet, EndPoint epSender)
+// {
+// LoadReceive(packet.ToBytes(), epSender);
+// }
+//
+// ///
+// /// Calls the protected asynchronous result method. This fires out all data chunks currently queued for send
+// ///
+// ///
+// public void ReceiveData(IAsyncResult result)
+// {
+// // Doesn't work the same way anymore
+//// while (m_chunksToLoad.Count > 0)
+//// OnReceivedData(result);
+// }
}
///
--
cgit v1.1