diff --git a/Documentation/Documentation.chm b/Documentation/Documentation.chm
index 8f39f07..97e855e 100644
Binary files a/Documentation/Documentation.chm and b/Documentation/Documentation.chm differ
diff --git a/Documentation/sandcastle-build-project.shfbproj b/Documentation/sandcastle-build-project.shfbproj
index cf3621e..51bcfcc 100644
--- a/Documentation/sandcastle-build-project.shfbproj
+++ b/Documentation/sandcastle-build-project.shfbproj
@@ -14,11 +14,11 @@
Documentation
Documentation
- .\Help\
+ .\
Documentation
en-US
-
+
Lidgren Network Library documentation
diff --git a/Lidgren.Network/Lidgren.Network.csproj b/Lidgren.Network/Lidgren.Network.csproj
index 548c867..ca95d3a 100644
--- a/Lidgren.Network/Lidgren.Network.csproj
+++ b/Lidgren.Network/Lidgren.Network.csproj
@@ -38,18 +38,13 @@
TRACE
prompt
4
+ bin\Release\Lidgren.Network.XML
3.5
-
- 3.5
-
-
- 3.5
-
diff --git a/Lidgren.Network/NetBitVector.cs b/Lidgren.Network/NetBitVector.cs
index 0d1640a..d615d8c 100644
--- a/Lidgren.Network/NetBitVector.cs
+++ b/Lidgren.Network/NetBitVector.cs
@@ -78,8 +78,6 @@ namespace Lidgren.Network
cur |= firstBit << lastIndex;
m_data[lenMinusOne] = cur;
-
- throw new NetException("TODO: update m_numBitsSet");
}
public int GetFirstSetIndex()
@@ -149,6 +147,7 @@ namespace Lidgren.Network
{
Array.Clear(m_data, 0, m_data.Length);
m_numBitsSet = 0;
+ NetException.Assert(this.IsEmpty());
}
///
diff --git a/Lidgren.Network/NetConnection.Handshake.cs b/Lidgren.Network/NetConnection.Handshake.cs
index 7826218..9ca2c6c 100644
--- a/Lidgren.Network/NetConnection.Handshake.cs
+++ b/Lidgren.Network/NetConnection.Handshake.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Text;
namespace Lidgren.Network
diff --git a/Lidgren.Network/NetConnection.Latency.cs b/Lidgren.Network/NetConnection.Latency.cs
index b934952..389b13d 100644
--- a/Lidgren.Network/NetConnection.Latency.cs
+++ b/Lidgren.Network/NetConnection.Latency.cs
@@ -9,6 +9,9 @@ namespace Lidgren.Network
private float m_averageRoundtripTime;
private float m_timeoutDeadline = float.MaxValue;
+ ///
+ /// Gets the current average roundtrip time in seconds
+ ///
public float AverageRoundtripTime { get { return m_averageRoundtripTime; } }
internal void SendPing()
diff --git a/Lidgren.Network/NetConnection.cs b/Lidgren.Network/NetConnection.cs
index 7abd3c0..810edc6 100644
--- a/Lidgren.Network/NetConnection.cs
+++ b/Lidgren.Network/NetConnection.cs
@@ -266,7 +266,7 @@ namespace Lidgren.Network
private NetSenderChannelBase CreateSenderChannel(NetMessageType tp)
{
NetSenderChannelBase chan;
- NetDeliveryMethod method = tp.GetDeliveryMethod();
+ NetDeliveryMethod method = NetUtility.GetDeliveryMethod(tp);
int sequenceChannel = (int)tp - (int)method;
switch (method)
{
@@ -357,7 +357,7 @@ namespace Lidgren.Network
// create receiver channel
NetReceiverChannelBase chan;
- NetDeliveryMethod method = tp.GetDeliveryMethod();
+ NetDeliveryMethod method = NetUtility.GetDeliveryMethod(tp);
switch (method)
{
case NetDeliveryMethod.Unreliable:
diff --git a/Lidgren.Network/NetConnectionStatus.cs b/Lidgren.Network/NetConnectionStatus.cs
index 00b91a6..88742b5 100644
--- a/Lidgren.Network/NetConnectionStatus.cs
+++ b/Lidgren.Network/NetConnectionStatus.cs
@@ -25,6 +25,9 @@ namespace Lidgren.Network
///
public enum NetConnectionStatus
{
+ ///
+ /// No connection, or attempt, in place
+ ///
None,
///
diff --git a/Lidgren.Network/NetConstants.cs b/Lidgren.Network/NetConstants.cs
index cde24df..a79b328 100644
--- a/Lidgren.Network/NetConstants.cs
+++ b/Lidgren.Network/NetConstants.cs
@@ -23,21 +23,21 @@ namespace Lidgren.Network
///
/// All the constants used when compiling the library
///
- public static class NetConstants
+ internal static class NetConstants
{
- public const int NumTotalChannels = 99;
+ internal const int NumTotalChannels = 99;
- public const int NetChannelsPerDeliveryMethod = 32;
+ internal const int NetChannelsPerDeliveryMethod = 32;
- public const int NumSequenceNumbers = 1024;
+ internal const int NumSequenceNumbers = 1024;
- public const int HeaderByteSize = 5;
+ internal const int HeaderByteSize = 5;
- public const int UnreliableWindowSize = 128;
- public const int ReliableOrderedWindowSize = 64;
- public const int ReliableSequencedWindowSize = 64;
+ internal const int UnreliableWindowSize = 128;
+ internal const int ReliableOrderedWindowSize = 64;
+ internal const int ReliableSequencedWindowSize = 64;
- public const int MaxFragmentationGroups = ushort.MaxValue - 1;
+ internal const int MaxFragmentationGroups = ushort.MaxValue - 1;
///
/// Number of channels which needs a sequence number to work
diff --git a/Lidgren.Network/NetDeliveryMethod.cs b/Lidgren.Network/NetDeliveryMethod.cs
index 527f1ad..46e504f 100644
--- a/Lidgren.Network/NetDeliveryMethod.cs
+++ b/Lidgren.Network/NetDeliveryMethod.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Text;
namespace Lidgren.Network
@@ -13,11 +12,35 @@ namespace Lidgren.Network
//
// Actually a publicly visible subset of NetMessageType
//
+
+ ///
+ /// Indicates an error
+ ///
Unknown = 0,
+
+ ///
+ /// Unreliable, unordered delivery
+ ///
Unreliable = 1,
+
+ ///
+ /// Unreliable delivery, but automatically dropping late messages
+ ///
UnreliableSequenced = 2,
+
+ ///
+ /// Reliable delivery, but unordered
+ ///
ReliableUnordered = 34,
+
+ ///
+ /// Reliable delivery, except for late messages which are dropped
+ ///
ReliableSequenced = 35,
+
+ ///
+ /// Reliable, ordered delivery
+ ///
ReliableOrdered = 67,
}
}
diff --git a/Lidgren.Network/NetIncomingMessage.Peek.cs b/Lidgren.Network/NetIncomingMessage.Peek.cs
index f7b45d6..2dcd251 100644
--- a/Lidgren.Network/NetIncomingMessage.Peek.cs
+++ b/Lidgren.Network/NetIncomingMessage.Peek.cs
@@ -28,6 +28,9 @@ namespace Lidgren.Network
//
// 1 bit
//
+ ///
+ /// Reads a 1-bit Boolean without advancing the read pointer
+ ///
public bool PeekBoolean()
{
NetException.Assert(m_bitLength - m_readPosition >= 1, c_readOverflowError);
@@ -38,6 +41,9 @@ namespace Lidgren.Network
//
// 8 bit
//
+ ///
+ /// Reads a Byte without advancing the read pointer
+ ///
public byte PeekByte()
{
NetException.Assert(m_bitLength - m_readPosition >= 8, c_readOverflowError);
@@ -45,6 +51,9 @@ namespace Lidgren.Network
return retval;
}
+ ///
+ /// Reads an SByte without advancing the read pointer
+ ///
[CLSCompliant(false)]
public sbyte PeekSByte()
{
@@ -53,12 +62,18 @@ namespace Lidgren.Network
return (sbyte)retval;
}
+ ///
+ /// Reads the specified number of bits into a Byte without advancing the read pointer
+ ///
public byte PeekByte(int numberOfBits)
{
byte retval = NetBitWriter.ReadByte(m_data, numberOfBits, m_readPosition);
return retval;
}
+ ///
+ /// Reads the specified number of bytes without advancing the read pointer
+ ///
public byte[] PeekBytes(int numberOfBytes)
{
NetException.Assert(m_bitLength - m_readPosition >= (numberOfBytes * 8), c_readOverflowError);
@@ -68,6 +83,9 @@ namespace Lidgren.Network
return retval;
}
+ ///
+ /// Reads the specified number of bytes without advancing the read pointer
+ ///
public void PeekBytes(byte[] into, int offset, int numberOfBytes)
{
NetException.Assert(m_bitLength - m_readPosition >= (numberOfBytes * 8), c_readOverflowError);
@@ -80,6 +98,9 @@ namespace Lidgren.Network
//
// 16 bit
//
+ ///
+ /// Reads an Int16 without advancing the read pointer
+ ///
public Int16 PeekInt16()
{
NetException.Assert(m_bitLength - m_readPosition >= 16, c_readOverflowError);
@@ -87,6 +108,9 @@ namespace Lidgren.Network
return (short)retval;
}
+ ///
+ /// Reads a UInt16 without advancing the read pointer
+ ///
[CLSCompliant(false)]
public UInt16 PeekUInt16()
{
@@ -98,6 +122,9 @@ namespace Lidgren.Network
//
// 32 bit
//
+ ///
+ /// Reads an Int32 without advancing the read pointer
+ ///
public Int32 PeekInt32()
{
NetException.Assert(m_bitLength - m_readPosition >= 32, c_readOverflowError);
@@ -105,6 +132,9 @@ namespace Lidgren.Network
return (Int32)retval;
}
+ ///
+ /// Reads the specified number of bits into an Int32 without advancing the read pointer
+ ///
public Int32 PeekInt32(int numberOfBits)
{
NetException.Assert((numberOfBits > 0 && numberOfBits <= 32), "ReadInt() can only read between 1 and 32 bits");
@@ -128,6 +158,9 @@ namespace Lidgren.Network
}
}
+ ///
+ /// Reads a UInt32 without advancing the read pointer
+ ///
[CLSCompliant(false)]
public UInt32 PeekUInt32()
{
@@ -136,6 +169,9 @@ namespace Lidgren.Network
return retval;
}
+ ///
+ /// Reads the specified number of bits into a UInt32 without advancing the read pointer
+ ///
[CLSCompliant(false)]
public UInt32 PeekUInt32(int numberOfBits)
{
@@ -149,6 +185,9 @@ namespace Lidgren.Network
//
// 64 bit
//
+ ///
+ /// Reads a UInt64 without advancing the read pointer
+ ///
[CLSCompliant(false)]
public UInt64 PeekUInt64()
{
@@ -162,6 +201,9 @@ namespace Lidgren.Network
return retval;
}
+ ///
+ /// Reads an Int32 without advancing the read pointer
+ ///
public Int64 PeekInt64()
{
NetException.Assert(m_bitLength - m_readPosition >= 64, c_readOverflowError);
@@ -173,6 +215,9 @@ namespace Lidgren.Network
}
}
+ ///
+ /// Reads the specified number of bits into an UInt64 without advancing the read pointer
+ ///
[CLSCompliant(false)]
public UInt64 PeekUInt64(int numberOfBits)
{
@@ -192,6 +237,9 @@ namespace Lidgren.Network
return retval;
}
+ ///
+ /// Reads the specified number of bits into an Int64 without advancing the read pointer
+ ///
public Int64 PeekInt64(int numberOfBits)
{
NetException.Assert(((numberOfBits > 0) && (numberOfBits < 65)), "ReadInt64(bits) can only read between 1 and 64 bits");
@@ -201,11 +249,17 @@ namespace Lidgren.Network
//
// Floating point
//
+ ///
+ /// Reads a 32-bit Single without advancing the read pointer
+ ///
public float PeekFloat()
{
return PeekSingle();
}
+ ///
+ /// Reads a 32-bit Single without advancing the read pointer
+ ///
public float PeekSingle()
{
NetException.Assert(m_bitLength - m_readPosition >= 32, c_readOverflowError);
@@ -221,6 +275,9 @@ namespace Lidgren.Network
return BitConverter.ToSingle(bytes, 0); // endianness is handled inside BitConverter.ToSingle
}
+ ///
+ /// Reads a 64-bit Double without advancing the read pointer
+ ///
public double PeekDouble()
{
NetException.Assert(m_bitLength - m_readPosition >= 64, c_readOverflowError);
@@ -237,7 +294,7 @@ namespace Lidgren.Network
}
///
- /// Reads a string
+ /// Reads a string without advancing the read pointer
///
public string PeekString()
{
diff --git a/Lidgren.Network/NetIncomingMessage.cs b/Lidgren.Network/NetIncomingMessage.cs
index 99f308c..a75f0b3 100644
--- a/Lidgren.Network/NetIncomingMessage.cs
+++ b/Lidgren.Network/NetIncomingMessage.cs
@@ -45,12 +45,12 @@ namespace Lidgren.Network
///
/// Gets the delivery method this message was sent with (if user data)
///
- public NetDeliveryMethod DeliveryMethod { get { return m_receivedMessageType.GetDeliveryMethod(); } }
+ public NetDeliveryMethod DeliveryMethod { get { return NetUtility.GetDeliveryMethod(m_receivedMessageType); } }
///
/// Gets the sequence channel this message was sent with (if user data)
///
- public int SequenceChannel { get { return (int)m_receivedMessageType - (int)m_receivedMessageType.GetDeliveryMethod(); } }
+ public int SequenceChannel { get { return (int)m_receivedMessageType - (int)NetUtility.GetDeliveryMethod(m_receivedMessageType); } }
///
/// IPEndPoint of sender, if any
diff --git a/Lidgren.Network/NetMessageType.cs b/Lidgren.Network/NetMessageType.cs
index b05aecb..c91817d 100644
--- a/Lidgren.Network/NetMessageType.cs
+++ b/Lidgren.Network/NetMessageType.cs
@@ -170,25 +170,4 @@ namespace Lidgren.Network
NatPunchMessage = 138, // send between peers
NatIntroduction = 139, // send to master server
}
-
- internal static class NetMessageTypeExtensions
- {
- internal static bool IsLibrary(this NetMessageType tp)
- {
- return tp >= NetMessageType.LibraryError;
- }
-
- internal static NetDeliveryMethod GetDeliveryMethod(this NetMessageType mtp)
- {
- if (mtp >= NetMessageType.UserReliableOrdered1)
- return NetDeliveryMethod.ReliableOrdered;
- else if (mtp >= NetMessageType.UserReliableSequenced1)
- return NetDeliveryMethod.ReliableSequenced;
- else if (mtp >= NetMessageType.UserReliableUnordered)
- return NetDeliveryMethod.ReliableUnordered;
- else if (mtp >= NetMessageType.UserSequenced1)
- return NetDeliveryMethod.UnreliableSequenced;
- return NetDeliveryMethod.Unreliable;
- }
- }
}
\ No newline at end of file
diff --git a/Lidgren.Network/NetPeer.MessagePools.cs b/Lidgren.Network/NetPeer.MessagePools.cs
index bcc10ee..2201d70 100644
--- a/Lidgren.Network/NetPeer.MessagePools.cs
+++ b/Lidgren.Network/NetPeer.MessagePools.cs
@@ -161,7 +161,7 @@ namespace Lidgren.Network
msg.m_data = null;
// message fragments cannot be recycled
- // TODO: find a way to recycle large message after all fragments has been acknowledged
+ // TODO: find a way to recycle large message after all fragments has been acknowledged; or? possibly better just to garbage collect them
if (msg.m_fragmentGroup == 0)
Recycle(storage);
diff --git a/Lidgren.Network/NetPeer.Send.cs b/Lidgren.Network/NetPeer.Send.cs
index 5de75d6..a768faa 100644
--- a/Lidgren.Network/NetPeer.Send.cs
+++ b/Lidgren.Network/NetPeer.Send.cs
@@ -31,8 +31,15 @@ namespace Lidgren.Network
throw new ArgumentNullException("msg");
if (recipient == null)
throw new ArgumentNullException("recipient");
- if (method == NetDeliveryMethod.Unreliable || method == NetDeliveryMethod.ReliableUnordered)
- NetException.Assert(sequenceChannel == 0, "Delivery method " + method + " cannot use sequence channels other than 0!");
+
+ NetException.Assert(
+ ((method != NetDeliveryMethod.Unreliable && method != NetDeliveryMethod.ReliableUnordered) ||
+ ((method == NetDeliveryMethod.Unreliable || method == NetDeliveryMethod.ReliableUnordered) && sequenceChannel == 0)),
+ "Delivery method " + method + " cannot use sequence channels other than 0!"
+ );
+
+ NetException.Assert(method != NetDeliveryMethod.Unknown, "Bad delivery method!");
+
if (msg.m_isSent)
throw new NetException("This message has already been sent! Use NetPeer.SendMessage() to send to multiple recipients efficiently");
@@ -106,7 +113,7 @@ namespace Lidgren.Network
msg.m_messageType = NetMessageType.Unconnected;
- // TODO: Interlocked.Add(ref msg.m_recyclingCount, recipients.Count); ?
+ Interlocked.Increment(ref msg.m_recyclingCount);
m_unsentUnconnectedMessages.Enqueue(new NetTuple(new IPEndPoint(adr, port), msg));
}
@@ -126,7 +133,7 @@ namespace Lidgren.Network
msg.m_messageType = NetMessageType.Unconnected;
- // TODO: Interlocked.Add(ref msg.m_recyclingCount, recipients.Count); ?
+ Interlocked.Increment(ref msg.m_recyclingCount);
m_unsentUnconnectedMessages.Enqueue(new NetTuple(recipient, msg));
}
diff --git a/Lidgren.Network/NetPeer.cs b/Lidgren.Network/NetPeer.cs
index 24611a1..2f71bb5 100644
--- a/Lidgren.Network/NetPeer.cs
+++ b/Lidgren.Network/NetPeer.cs
@@ -20,7 +20,7 @@ namespace Lidgren.Network
private string m_shutdownReason;
///
- /// Gets the status of the NetPeer
+ /// Gets the NetPeerStatus of the NetPeer
///
public NetPeerStatus Status { get { return m_status; } }
@@ -33,12 +33,12 @@ namespace Lidgren.Network
public AutoResetEvent MessageReceivedEvent { get { return m_messageReceivedEvent; } }
///
- /// Gets a unique identifier for this NetPeer based on Mac address and ip/port. Note! Not available until Start has been called!
+ /// Gets a unique identifier for this NetPeer based on Mac address and ip/port. Note! Not available until Start() has been called!
///
public long UniqueIdentifier { get { return m_uniqueIdentifier; } }
///
- /// Gets the port number this NetPeer is listening and sending on
+ /// Gets the port number this NetPeer is listening and sending on, if Start() has been called
///
public int Port { get { return m_listenPort; } }
@@ -55,7 +55,7 @@ namespace Lidgren.Network
}
///
- /// Returns the number of active connections
+ /// Gets the number of active connections
///
public int ConnectionsCount
{
@@ -71,7 +71,7 @@ namespace Lidgren.Network
}
///
- /// Gets the configuration of the netpeer
+ /// Gets the configuration used to instanciate this NetPeer
///
public NetPeerConfiguration Configuration { get { return m_configuration; } }
@@ -90,7 +90,7 @@ namespace Lidgren.Network
}
///
- /// Binds to socket and spawns networking thread
+ /// Binds to socket and spawns the networking thread
///
public void Start()
{
diff --git a/Lidgren.Network/NetPeerConfiguration.cs b/Lidgren.Network/NetPeerConfiguration.cs
index fbb8061..c16c9b3 100644
--- a/Lidgren.Network/NetPeerConfiguration.cs
+++ b/Lidgren.Network/NetPeerConfiguration.cs
@@ -339,6 +339,9 @@ namespace Lidgren.Network
}
#endif
+ ///
+ /// Creates a memberwise shallow clone of this configuration
+ ///
public NetPeerConfiguration Clone()
{
NetPeerConfiguration retval = this.MemberwiseClone() as NetPeerConfiguration;
diff --git a/Lidgren.Network/NetPeerStatistics.cs b/Lidgren.Network/NetPeerStatistics.cs
index 9702802..1891549 100644
--- a/Lidgren.Network/NetPeerStatistics.cs
+++ b/Lidgren.Network/NetPeerStatistics.cs
@@ -94,7 +94,7 @@ namespace Lidgren.Network
///
/// Gets the number of bytes allocated (and possibly garbage collected) for message storage
///
- public long BytesAllocated { get { return m_bytesAllocated; } }
+ public long StorageBytesAllocated { get { return m_bytesAllocated; } }
///
/// Gets the number of bytes in the recycled pool
@@ -126,7 +126,7 @@ namespace Lidgren.Network
bdr.AppendLine(m_peer.ConnectionsCount.ToString() + " connections");
bdr.AppendLine("Sent " + m_sentBytes + " bytes in " + m_sentMessages + " messages in " + m_sentPackets + " packets");
bdr.AppendLine("Received " + m_receivedBytes + " bytes in " + m_receivedMessages + " messages in " + m_receivedPackets + " packets");
- bdr.AppendLine("Allocated " + m_bytesAllocated + " bytes");
+ bdr.AppendLine("Storage allocated " + m_bytesAllocated + " bytes");
bdr.AppendLine("Recycled pool " + m_peer.m_storagePoolBytes + " bytes");
return bdr.ToString();
}
diff --git a/Lidgren.Network/NetQueue.cs b/Lidgren.Network/NetQueue.cs
index 547c301..d21128e 100644
--- a/Lidgren.Network/NetQueue.cs
+++ b/Lidgren.Network/NetQueue.cs
@@ -52,11 +52,13 @@ namespace Lidgren.Network
///
public int Count { get { return m_size; } }
+ ///
+ /// Gets the current capacity for the queue
+ ///
public int Capacity { get { return m_items.Length; } }
public NetQueue(int initialCapacity)
{
- System.Collections.Generic.Queue a;
m_lock = new object();
m_items = new T[initialCapacity];
}
diff --git a/Lidgren.Network/NetRandom.cs b/Lidgren.Network/NetRandom.cs
index b33c26f..975f4d4 100644
--- a/Lidgren.Network/NetRandom.cs
+++ b/Lidgren.Network/NetRandom.cs
@@ -37,6 +37,9 @@ namespace Lidgren.Network
/// FastRandom are in use or if being used in a multi-threaded environment.
public class NetRandom
{
+ ///
+ /// Gets a global NetRandom instance
+ ///
public static readonly NetRandom Instance = new NetRandom();
// The +1 ensures NextDouble doesn't generate 1.0
diff --git a/Lidgren.Network/NetTuple.cs b/Lidgren.Network/NetTuple.cs
index 70973a8..40ff423 100644
--- a/Lidgren.Network/NetTuple.cs
+++ b/Lidgren.Network/NetTuple.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Text;
namespace Lidgren.Network
diff --git a/Lidgren.Network/NetUtility.cs b/Lidgren.Network/NetUtility.cs
index 386ef67..02eb3c2 100644
--- a/Lidgren.Network/NetUtility.cs
+++ b/Lidgren.Network/NetUtility.cs
@@ -220,8 +220,7 @@ namespace Lidgren.Network
return (numBits + 7) / 8;
}
- [CLSCompliant(false)]
- public static UInt32 SwapByteOrder(UInt32 value)
+ internal static UInt32 SwapByteOrder(UInt32 value)
{
return
((value & 0xff000000) >> 24) |
@@ -230,8 +229,7 @@ namespace Lidgren.Network
((value & 0x000000ff) << 24);
}
- [CLSCompliant(false)]
- public static UInt64 SwapByteOrder(UInt64 value)
+ internal static UInt64 SwapByteOrder(UInt64 value)
{
return
((value & 0xff00000000000000L) >> 56) |
@@ -244,7 +242,7 @@ namespace Lidgren.Network
((value & 0x00000000000000ffL) << 56);
}
- public static bool CompareElements(byte[] one, byte[] two)
+ internal static bool CompareElements(byte[] one, byte[] two)
{
if (one.Length != two.Length)
return false;
@@ -254,6 +252,9 @@ namespace Lidgren.Network
return true;
}
+ ///
+ /// Convert a hexadecimal string to a byte array
+ ///
public static byte[] ToByteArray(String hexString)
{
byte[] retval = new byte[hexString.Length / 2];
@@ -262,6 +263,9 @@ namespace Lidgren.Network
return retval;
}
+ ///
+ /// Converts a number of bytes to a shorter, more readable string representation
+ ///
public static string ToHumanReadable(long bytes)
{
if (bytes < 4000) // 1-4 kb is printed in bytes
@@ -317,5 +321,18 @@ namespace Lidgren.Network
h /= 3;
}
}
+
+ internal static NetDeliveryMethod GetDeliveryMethod(NetMessageType mtp)
+ {
+ if (mtp >= NetMessageType.UserReliableOrdered1)
+ return NetDeliveryMethod.ReliableOrdered;
+ else if (mtp >= NetMessageType.UserReliableSequenced1)
+ return NetDeliveryMethod.ReliableSequenced;
+ else if (mtp >= NetMessageType.UserReliableUnordered)
+ return NetDeliveryMethod.ReliableUnordered;
+ else if (mtp >= NetMessageType.UserSequenced1)
+ return NetDeliveryMethod.UnreliableSequenced;
+ return NetDeliveryMethod.Unreliable;
+ }
}
}
\ No newline at end of file