Updates to for Halcyon compatibility
- OutgoingPacket moved back to OpenMetaverse scope (separate file) from NetworkManager, and now restores the pool- and refcount-related functionality. - UDPPacketBuffer BufferSize is a constant so now DEFAULT_BUFFER_SIZE. - Added a Halcyon-compatible UDPPacketBuffer constructor that accepts a specific buffer, etc. - Added CopyFrom methods to assign UDPPacketBuffer Data.
This commit is contained in:
@@ -9,7 +9,7 @@ namespace OpenMetaverse
|
||||
public class UDPPacketBuffer
|
||||
{
|
||||
/// <summary>Size of the byte array used to store raw packet data</summary>
|
||||
public const int BufferSize = 4096;
|
||||
public const int DEFAULT_BUFFER_SIZE = 4096;
|
||||
/// <summary>Raw packet data buffer</summary>
|
||||
public readonly byte[] Data;
|
||||
/// <summary>Length of the data to transmit</summary>
|
||||
@@ -26,7 +26,7 @@ namespace OpenMetaverse
|
||||
/// </summary>
|
||||
public UDPPacketBuffer()
|
||||
{
|
||||
Data = new byte[BufferSize];
|
||||
Data = new byte[DEFAULT_BUFFER_SIZE];
|
||||
// Will be modified later by BeginReceiveFrom()
|
||||
RemoteEndPoint = new IPEndPoint(Settings.BIND_ADDR, 0);
|
||||
}
|
||||
@@ -37,7 +37,7 @@ namespace OpenMetaverse
|
||||
/// <param name="endPoint">EndPoint of the remote host</param>
|
||||
public UDPPacketBuffer(IPEndPoint endPoint)
|
||||
{
|
||||
Data = new byte[BufferSize];
|
||||
Data = new byte[DEFAULT_BUFFER_SIZE];
|
||||
RemoteEndPoint = endPoint;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,40 @@ namespace OpenMetaverse
|
||||
RemoteEndPoint = endPoint;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an allocated UDP packet buffer for sending a packet
|
||||
/// </summary>
|
||||
public UDPPacketBuffer(byte[] buffer, int bufferSize, IPEndPoint destination, int category, bool fromBufferPool)
|
||||
{
|
||||
Data = new byte[bufferSize];
|
||||
this.CopyFrom(buffer, bufferSize);
|
||||
DataLength = bufferSize;
|
||||
|
||||
RemoteEndPoint = destination;
|
||||
BytesLeasedFromPool = fromBufferPool;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an allocated UDP packet buffer for sending a packet
|
||||
/// </summary>
|
||||
/// <param name="endPoint">EndPoint of the remote host</param>
|
||||
/// <param name="data">The actual buffer to use for packet data (no allocation).</param>
|
||||
public UDPPacketBuffer(IPEndPoint endPoint, byte[] data)
|
||||
{
|
||||
Data = data;
|
||||
RemoteEndPoint = endPoint;
|
||||
}
|
||||
|
||||
public void CopyFrom(Array src, int length)
|
||||
{
|
||||
Buffer.BlockCopy(src, 0, this.Data, 0, length);
|
||||
}
|
||||
|
||||
public void CopyFrom(Array src)
|
||||
{
|
||||
this.CopyFrom(src, src.Length);
|
||||
}
|
||||
|
||||
public void ResetEndpoint()
|
||||
{
|
||||
RemoteEndPoint = new IPEndPoint(Settings.BIND_ADDR, 0);
|
||||
|
||||
Reference in New Issue
Block a user