aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs177
1 files changed, 88 insertions, 89 deletions
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;
36namespace OpenSim.Region.ClientStack.LindenUDP.Tests 36namespace OpenSim.Region.ClientStack.LindenUDP.Tests
37{ 37{
38 /// <summary> 38 /// <summary>
39 /// This class enables synchronous testing of the LLUDPServer by allowing us to load our own data into the end 39 /// This class enables regression testing of the LLUDPServer by allowing us to intercept outgoing data.
40 /// receive event
41 /// </summary> 40 /// </summary>
42 public class TestLLUDPServer : LLUDPServer 41 public class TestLLUDPServer : LLUDPServer
43 { 42 {
43 public List<Packet> PacketsSent { get; private set; }
44
44 public TestLLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) 45 public TestLLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager)
45 : base(listenIP, ref port, proxyPortOffsetParm, allow_alternate_port, configSource, circuitManager) 46 : base(listenIP, ref port, proxyPortOffsetParm, allow_alternate_port, configSource, circuitManager)
46 {}
47
48 /// <summary>
49 /// The chunks of data to pass to the LLUDPServer when it calls EndReceive
50 /// </summary>
51 protected Queue<ChunkSenderTuple> m_chunksToLoad = new Queue<ChunkSenderTuple>();
52
53// protected override void BeginReceive()
54// {
55// if (m_chunksToLoad.Count > 0 && m_chunksToLoad.Peek().BeginReceiveException)
56// {
57// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
58// reusedEpSender = tuple.Sender;
59// throw new SocketException();
60// }
61// }
62
63// protected override bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender)
64// {
65// numBytes = 0;
66//
67// //m_log.Debug("Queue size " + m_chunksToLoad.Count);
68//
69// if (m_chunksToLoad.Count <= 0)
70// return false;
71//
72// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
73// RecvBuffer = tuple.Data;
74// numBytes = tuple.Data.Length;
75// epSender = tuple.Sender;
76//
77// return true;
78// }
79
80// public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
81// {
82// // Don't do anything just yet
83// }
84
85 /// <summary>
86 /// Signal that this chunk should throw an exception on Socket.BeginReceive()
87 /// </summary>
88 /// <param name="epSender"></param>
89 public void LoadReceiveWithBeginException(EndPoint epSender)
90 {
91 ChunkSenderTuple tuple = new ChunkSenderTuple(epSender);
92 tuple.BeginReceiveException = true;
93 m_chunksToLoad.Enqueue(tuple);
94 }
95
96 /// <summary>
97 /// Load some data to be received by the LLUDPServer on the next receive call
98 /// </summary>
99 /// <param name="data"></param>
100 /// <param name="epSender"></param>
101 public void LoadReceive(byte[] data, EndPoint epSender)
102 { 47 {
103 m_chunksToLoad.Enqueue(new ChunkSenderTuple(data, epSender)); 48 PacketsSent = new List<Packet>();
104 } 49 }
105 50
106 /// <summary> 51 public override void SendAckImmediate(IPEndPoint remoteEndpoint, PacketAckPacket ack)
107 /// Load a packet to be received by the LLUDPServer on the next receive call
108 /// </summary>
109 /// <param name="packet"></param>
110 public void LoadReceive(Packet packet, EndPoint epSender)
111 { 52 {
112 LoadReceive(packet.ToBytes(), epSender); 53 PacketsSent.Add(ack);
113 } 54 }
114 55
115 /// <summary> 56 public override void SendPacket(
116 /// Calls the protected asynchronous result method. This fires out all data chunks currently queued for send 57 LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method)
117 /// </summary>
118 /// <param name="result"></param>
119 public void ReceiveData(IAsyncResult result)
120 { 58 {
121 // Doesn't work the same way anymore 59 PacketsSent.Add(packet);
122// while (m_chunksToLoad.Count > 0)
123// OnReceivedData(result);
124 } 60 }
125
126 /// <summary>
127 /// Has a circuit with the given code been established?
128 /// </summary>
129 /// <param name="circuitCode"></param>
130 /// <returns></returns>
131 public bool HasCircuit(uint circuitCode)
132 {
133// lock (clientCircuits_reverse)
134// {
135// return clientCircuits_reverse.ContainsKey(circuitCode);
136// }
137 61
138 return true; 62//// /// <summary>
139 } 63//// /// The chunks of data to pass to the LLUDPServer when it calls EndReceive
64//// /// </summary>
65//// protected Queue<ChunkSenderTuple> m_chunksToLoad = new Queue<ChunkSenderTuple>();
66//
67//// protected override void BeginReceive()
68//// {
69//// if (m_chunksToLoad.Count > 0 && m_chunksToLoad.Peek().BeginReceiveException)
70//// {
71//// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
72//// reusedEpSender = tuple.Sender;
73//// throw new SocketException();
74//// }
75//// }
76//
77//// protected override bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender)
78//// {
79//// numBytes = 0;
80////
81//// //m_log.Debug("Queue size " + m_chunksToLoad.Count);
82////
83//// if (m_chunksToLoad.Count <= 0)
84//// return false;
85////
86//// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
87//// RecvBuffer = tuple.Data;
88//// numBytes = tuple.Data.Length;
89//// epSender = tuple.Sender;
90////
91//// return true;
92//// }
93//
94//// public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
95//// {
96//// // Don't do anything just yet
97//// }
98//
99// /// <summary>
100// /// Signal that this chunk should throw an exception on Socket.BeginReceive()
101// /// </summary>
102// /// <param name="epSender"></param>
103// public void LoadReceiveWithBeginException(EndPoint epSender)
104// {
105// ChunkSenderTuple tuple = new ChunkSenderTuple(epSender);
106// tuple.BeginReceiveException = true;
107// m_chunksToLoad.Enqueue(tuple);
108// }
109//
110// /// <summary>
111// /// Load some data to be received by the LLUDPServer on the next receive call
112// /// </summary>
113// /// <param name="data"></param>
114// /// <param name="epSender"></param>
115// public void LoadReceive(byte[] data, EndPoint epSender)
116// {
117// m_chunksToLoad.Enqueue(new ChunkSenderTuple(data, epSender));
118// }
119//
120// /// <summary>
121// /// Load a packet to be received by the LLUDPServer on the next receive call
122// /// </summary>
123// /// <param name="packet"></param>
124// public void LoadReceive(Packet packet, EndPoint epSender)
125// {
126// LoadReceive(packet.ToBytes(), epSender);
127// }
128//
129// /// <summary>
130// /// Calls the protected asynchronous result method. This fires out all data chunks currently queued for send
131// /// </summary>
132// /// <param name="result"></param>
133// public void ReceiveData(IAsyncResult result)
134// {
135// // Doesn't work the same way anymore
136//// while (m_chunksToLoad.Count > 0)
137//// OnReceivedData(result);
138// }
140 } 139 }
141 140
142 /// <summary> 141 /// <summary>