mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 10:15:33 +08:00
Bring LindenUDP.Tests back from the dead. No tests are running.
Code drift means that most of this stuff doesn't compile but the structure is still useful.
This commit is contained in:
@@ -29,7 +29,9 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse.Packets;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||
{
|
||||
@@ -39,42 +41,46 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||
/// </summary>
|
||||
public class TestLLUDPServer : LLUDPServer
|
||||
{
|
||||
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)
|
||||
{}
|
||||
|
||||
/// <summary>
|
||||
/// The chunks of data to pass to the LLUDPServer when it calls EndReceive
|
||||
/// </summary>
|
||||
protected Queue<ChunkSenderTuple> m_chunksToLoad = new Queue<ChunkSenderTuple>();
|
||||
|
||||
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 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;
|
||||
}
|
||||
// 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
|
||||
}
|
||||
// public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
|
||||
// {
|
||||
// // Don't do anything just yet
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Signal that this chunk should throw an exception on Socket.BeginReceive()
|
||||
@@ -112,8 +118,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||
/// <param name="result"></param>
|
||||
public void ReceiveData(IAsyncResult result)
|
||||
{
|
||||
while (m_chunksToLoad.Count > 0)
|
||||
OnReceivedData(result);
|
||||
// Doesn't work the same way anymore
|
||||
// while (m_chunksToLoad.Count > 0)
|
||||
// OnReceivedData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -123,10 +130,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||
/// <returns></returns>
|
||||
public bool HasCircuit(uint circuitCode)
|
||||
{
|
||||
lock (clientCircuits_reverse)
|
||||
{
|
||||
return clientCircuits_reverse.ContainsKey(circuitCode);
|
||||
}
|
||||
// lock (clientCircuits_reverse)
|
||||
// {
|
||||
// return clientCircuits_reverse.ContainsKey(circuitCode);
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user