mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 03:45:35 +08:00
* refactor: factor out test packet send method in client stack unit tests
This commit is contained in:
@@ -48,7 +48,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||
|
||||
protected override void BeginReceive()
|
||||
{
|
||||
// Do nothing
|
||||
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)
|
||||
@@ -71,6 +76,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||
// Don't do anything just yet
|
||||
}
|
||||
|
||||
/// <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>
|
||||
@@ -118,14 +134,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||
/// Record the data and sender tuple
|
||||
/// </summary>
|
||||
public class ChunkSenderTuple
|
||||
{
|
||||
{
|
||||
public byte[] Data;
|
||||
public EndPoint Sender;
|
||||
public bool BeginReceiveException;
|
||||
|
||||
public ChunkSenderTuple(byte[] data, EndPoint sender)
|
||||
{
|
||||
Data = data;
|
||||
Sender = sender;
|
||||
}
|
||||
|
||||
public ChunkSenderTuple(EndPoint sender)
|
||||
{
|
||||
Sender = sender;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user