diff --git a/Documentation/Documentation.chm b/Documentation/Documentation.chm index e49b6de..d09e0c7 100644 Binary files a/Documentation/Documentation.chm and b/Documentation/Documentation.chm differ diff --git a/Lidgren.Network/Encryption/INetEncryption.cs b/Lidgren.Network/Encryption/INetEncryption.cs index 099cde0..15e923c 100644 --- a/Lidgren.Network/Encryption/INetEncryption.cs +++ b/Lidgren.Network/Encryption/INetEncryption.cs @@ -3,12 +3,19 @@ using System.Collections.Generic; namespace Lidgren.Network { + /// + /// Interface for an encryption algorithm + /// public interface INetEncryption { + /// + /// Encrypt an outgoing message in place + /// bool Encrypt(NetOutgoingMessage msg); + + /// + /// Decrypt an incoming message in place + /// bool Decrypt(NetIncomingMessage msg); } - - - } diff --git a/Lidgren.Network/Encryption/NetBlockEncryptionBase.cs b/Lidgren.Network/Encryption/NetBlockEncryptionBase.cs index 625f73c..0506fb1 100644 --- a/Lidgren.Network/Encryption/NetBlockEncryptionBase.cs +++ b/Lidgren.Network/Encryption/NetBlockEncryptionBase.cs @@ -16,6 +16,9 @@ namespace Lidgren.Network /// public abstract int BlockSize { get; } + /// + /// NetBlockEncryptionBase constructor + /// public NetBlockEncryptionBase() { m_tmp = new byte[BlockSize]; @@ -72,7 +75,14 @@ namespace Lidgren.Network return true; } + /// + /// Encrypt a block of bytes + /// protected abstract void EncryptBlock(byte[] source, int sourceOffset, byte[] destination); + + /// + /// Decrypt a block of bytes + /// protected abstract void DecryptBlock(byte[] source, int sourceOffset, byte[] destination); } } diff --git a/Lidgren.Network/Encryption/NetXorEncryption.cs b/Lidgren.Network/Encryption/NetXorEncryption.cs index 77d02b0..aab1f29 100644 --- a/Lidgren.Network/Encryption/NetXorEncryption.cs +++ b/Lidgren.Network/Encryption/NetXorEncryption.cs @@ -11,16 +11,25 @@ namespace Lidgren.Network { private byte[] m_key; + /// + /// NetXorEncryption constructor + /// public NetXorEncryption(byte[] key) { m_key = key; } + /// + /// NetXorEncryption constructor + /// public NetXorEncryption(string key) { m_key = Encoding.ASCII.GetBytes(key); } + /// + /// Encrypt an outgoing message + /// public bool Encrypt(NetOutgoingMessage msg) { int numBytes = msg.LengthBytes; @@ -32,6 +41,9 @@ namespace Lidgren.Network return true; } + /// + /// Decrypt an incoming message + /// public bool Decrypt(NetIncomingMessage msg) { int numBytes = msg.LengthBytes; diff --git a/Lidgren.Network/Encryption/NetXteaEncryption.cs b/Lidgren.Network/Encryption/NetXteaEncryption.cs index 8133202..8e9d62b 100644 --- a/Lidgren.Network/Encryption/NetXteaEncryption.cs +++ b/Lidgren.Network/Encryption/NetXteaEncryption.cs @@ -36,6 +36,9 @@ namespace Lidgren.Network private readonly uint[] m_sum0; private readonly uint[] m_sum1; + /// + /// Gets the block size for this cipher + /// public override int BlockSize { get { return c_blockSize; } } /// @@ -83,6 +86,9 @@ namespace Lidgren.Network { } + /// + /// Encrypts a block of bytes + /// protected override void EncryptBlock(byte[] source, int sourceOffset, byte[] destination) { uint v0 = BytesToUInt(source, sourceOffset); @@ -100,6 +106,9 @@ namespace Lidgren.Network return; } + /// + /// Decrypts a block of bytes + /// protected override void DecryptBlock(byte[] source, int sourceOffset, byte[] destination) { // Pack bytes into integers diff --git a/Lidgren.Network/NetBitVector.cs b/Lidgren.Network/NetBitVector.cs index d615d8c..ec166af 100644 --- a/Lidgren.Network/NetBitVector.cs +++ b/Lidgren.Network/NetBitVector.cs @@ -36,6 +36,9 @@ namespace Lidgren.Network /// public int Capacity { get { return m_capacity; } } + /// + /// NetBitVector constructor + /// public NetBitVector(int bitsCapacity) { m_capacity = bitsCapacity; @@ -80,6 +83,9 @@ namespace Lidgren.Network m_data[lenMinusOne] = cur; } + /// + /// Gets the first (lowest) index set to true + /// public int GetFirstSetIndex() { int idx = 0; diff --git a/Lidgren.Network/NetBitWriter.cs b/Lidgren.Network/NetBitWriter.cs index e51aaf5..ac9d0de 100644 --- a/Lidgren.Network/NetBitWriter.cs +++ b/Lidgren.Network/NetBitWriter.cs @@ -169,6 +169,9 @@ namespace Lidgren.Network return; } + /// + /// Reads the specified number of bits into an UInt32 + /// [CLSCompliant(false)] #if UNSAFE public static unsafe uint ReadUInt32(byte[] fromBuffer, int numberOfBits, int readBitOffset) @@ -183,6 +186,7 @@ namespace Lidgren.Network } } #else + public static uint ReadUInt32(byte[] fromBuffer, int numberOfBits, int readBitOffset) { NetException.Assert(((numberOfBits > 0) && (numberOfBits <= 32)), "ReadUInt32() can only read between 1 and 32 bits"); @@ -234,6 +238,9 @@ namespace Lidgren.Network //[CLSCompliant(false)] //public static ulong ReadUInt64(byte[] fromBuffer, int numberOfBits, int readBitOffset) + /// + /// Writes the specified number of bits into a byte array + /// [CLSCompliant(false)] public static int WriteUInt32(uint source, int numberOfBits, byte[] destination, int destinationBitOffset) { @@ -277,6 +284,9 @@ namespace Lidgren.Network return returnValue; } + /// + /// Writes the specified number of bits into a byte array + /// [CLSCompliant(false)] public static int WriteUInt64(ulong source, int numberOfBits, byte[] destination, int destinationBitOffset) { diff --git a/Lidgren.Network/NetClient.cs b/Lidgren.Network/NetClient.cs index 61a8bdb..1d1cd8f 100644 --- a/Lidgren.Network/NetClient.cs +++ b/Lidgren.Network/NetClient.cs @@ -50,6 +50,9 @@ namespace Lidgren.Network } } + /// + /// Gets the connection status of the server connection (or NetConnectionStatus.Disconnected if no connection) + /// public NetConnectionStatus ConnectionStatus { get @@ -61,12 +64,22 @@ namespace Lidgren.Network } } + /// + /// NetClient constructor + /// + /// public NetClient(NetPeerConfiguration config) : base(config) { config.AcceptIncomingConnections = false; } + /// + /// Connect to a remote server + /// + /// The remote endpoint to connect to + /// The hail message to pass + /// server connection, or null if already connected public override NetConnection Connect(IPEndPoint remoteEndpoint, NetOutgoingMessage hailMessage) { lock (m_connections) diff --git a/Lidgren.Network/NetConnection.Latency.cs b/Lidgren.Network/NetConnection.Latency.cs index 368b5ef..df677f9 100644 --- a/Lidgren.Network/NetConnection.Latency.cs +++ b/Lidgren.Network/NetConnection.Latency.cs @@ -17,6 +17,9 @@ namespace Lidgren.Network /// public float AverageRoundtripTime { get { return m_averageRoundtripTime; } } + /// + /// Time offset between this peer and the remote peer + /// public float RemoteTimeOffset { get { return (float)m_remoteTimeOffset; } } // this might happen more than once diff --git a/Lidgren.Network/NetException.cs b/Lidgren.Network/NetException.cs index bb89261..8a390ce 100644 --- a/Lidgren.Network/NetException.cs +++ b/Lidgren.Network/NetException.cs @@ -28,21 +28,33 @@ namespace Lidgren.Network [Serializable] public sealed class NetException : Exception { + /// + /// NetException constructor + /// public NetException() : base() { } + /// + /// NetException constructor + /// public NetException(string message) : base(message) { } + /// + /// NetException constructor + /// public NetException(string message, Exception inner) : base(message, inner) { } + /// + /// NetException constructor + /// private NetException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/Lidgren.Network/NetIncomingMessage.Read.cs b/Lidgren.Network/NetIncomingMessage.Read.cs index a2e2d87..1c1ca88 100644 --- a/Lidgren.Network/NetIncomingMessage.Read.cs +++ b/Lidgren.Network/NetIncomingMessage.Read.cs @@ -69,9 +69,9 @@ namespace Lidgren.Network } } - // - // 1 bit - // + /// + /// Reads a boolean value (stored as a single bit) written using Write(bool) + /// public bool ReadBoolean() { NetException.Assert(m_bitLength - m_readPosition >= 1, c_readOverflowError); @@ -79,10 +79,10 @@ namespace Lidgren.Network m_readPosition += 1; return (retval > 0 ? true : false); } - - // - // 8 bit - // + + /// + /// Reads a byte + /// public byte ReadByte() { NetException.Assert(m_bitLength - m_readPosition >= 8, c_readOverflowError); @@ -90,8 +90,10 @@ namespace Lidgren.Network m_readPosition += 8; return retval; } - - + + /// + /// Reads a signed byte + /// [CLSCompliant(false)] public sbyte ReadSByte() { @@ -101,13 +103,20 @@ namespace Lidgren.Network return (sbyte)retval; } + /// + /// Reads 1 to 8 bits into a byte + /// public byte ReadByte(int numberOfBits) { + NetException.Assert(numberOfBits > 0 && numberOfBits < 8); byte retval = NetBitWriter.ReadByte(m_data, numberOfBits, m_readPosition); m_readPosition += numberOfBits; return retval; } + /// + /// Reads the specified number of bytes + /// public byte[] ReadBytes(int numberOfBytes) { NetException.Assert(m_bitLength - m_readPosition + 7 >= (numberOfBytes * 8), c_readOverflowError); @@ -118,6 +127,12 @@ namespace Lidgren.Network return retval; } + /// + /// Reads the specified number of bytes into a preallocated array + /// + /// The destination array + /// The offset where to start writing in the destination array + /// The number of bytes to read public void ReadBytes(byte[] into, int offset, int numberOfBytes) { NetException.Assert(m_bitLength - m_readPosition + 7 >= (numberOfBytes * 8), c_readOverflowError); @@ -128,6 +143,12 @@ namespace Lidgren.Network return; } + /// + /// Reads the specified number of bits into a preallocated array + /// + /// The destination array + /// The offset where to start writing in the destination array + /// The number of bits to read public void ReadBits(byte[] into, int offset, int numberOfBits) { NetException.Assert(m_bitLength - m_readPosition >= numberOfBits, c_readOverflowError); @@ -145,9 +166,9 @@ namespace Lidgren.Network return; } - // - // 16 bit - // + /// + /// Reads a 16 bit signed integer written using Write(Int16) + /// public Int16 ReadInt16() { NetException.Assert(m_bitLength - m_readPosition >= 16, c_readOverflowError); @@ -156,6 +177,9 @@ namespace Lidgren.Network return (short)retval; } + /// + /// Reads a 16 bit unsigned integer written using Write(UInt16) + /// [CLSCompliant(false)] public UInt16 ReadUInt16() { @@ -165,9 +189,9 @@ namespace Lidgren.Network return (ushort)retval; } - // - // 32 bit - // + /// + /// Reads a 32 bit signed integer written using Write(Int32) + /// public Int32 ReadInt32() { NetException.Assert(m_bitLength - m_readPosition >= 32, c_readOverflowError); @@ -176,6 +200,9 @@ namespace Lidgren.Network return (Int32)retval; } + /// + /// Reads a signed integer stored in 1 to 32 bits, written using Write(Int32, Int32) + /// public Int32 ReadInt32(int numberOfBits) { NetException.Assert((numberOfBits > 0 && numberOfBits <= 32), "ReadInt() can only read between 1 and 32 bits"); @@ -200,6 +227,9 @@ namespace Lidgren.Network } } + /// + /// Reads an 32 bit unsigned integer written using Write(UInt32) + /// [CLSCompliant(false)] public UInt32 ReadUInt32() { @@ -209,6 +239,9 @@ namespace Lidgren.Network return retval; } + /// + /// Reads an unsigned integer stored in 1 to 32 bits, written using Write(UInt32, Int32) + /// [CLSCompliant(false)] public UInt32 ReadUInt32(int numberOfBits) { @@ -220,9 +253,9 @@ namespace Lidgren.Network return retval; } - // - // 64 bit - // + /// + /// Reads a 64 bit unsigned integer written using Write(UInt64) + /// [CLSCompliant(false)] public UInt64 ReadUInt64() { @@ -238,6 +271,9 @@ namespace Lidgren.Network return retval; } + /// + /// Reads a 64 bit signed integer written using Write(Int64) + /// public Int64 ReadInt64() { NetException.Assert(m_bitLength - m_readPosition >= 64, c_readOverflowError); @@ -249,6 +285,9 @@ namespace Lidgren.Network } } + /// + /// Reads an unsigned integer stored in 1 to 64 bits, written using Write(UInt64, Int32) + /// [CLSCompliant(false)] public UInt64 ReadUInt64(int numberOfBits) { @@ -269,20 +308,26 @@ namespace Lidgren.Network return retval; } + /// + /// Reads a signed integer stored in 1 to 64 bits, written using Write(Int64, Int32) + /// public Int64 ReadInt64(int numberOfBits) { NetException.Assert(((numberOfBits > 0) && (numberOfBits < 65)), "ReadInt64(bits) can only read between 1 and 64 bits"); return (long)ReadUInt64(numberOfBits); } - // - // Floating point - // + /// + /// Reads a 32 bit floating point value written using Write(Single) + /// public float ReadFloat() { return ReadSingle(); } + /// + /// Reads a 32 bit floating point value written using Write(Single) + /// public float ReadSingle() { NetException.Assert(m_bitLength - m_readPosition >= 32, c_readOverflowError); @@ -299,6 +344,9 @@ namespace Lidgren.Network return BitConverter.ToSingle(bytes, 0); // endianness is handled inside BitConverter.ToSingle } + /// + /// Reads a 64 bit floating point value written using Write(Double) + /// public double ReadDouble() { NetException.Assert(m_bitLength - m_readPosition >= 64, c_readOverflowError); @@ -320,7 +368,7 @@ namespace Lidgren.Network // /// - /// Reads a UInt32 written using WriteVariableUInt32() + /// Reads a variable sized UInt32 written using WriteVariableUInt32() /// [CLSCompliant(false)] public uint ReadVariableUInt32() @@ -338,7 +386,7 @@ namespace Lidgren.Network } /// - /// Reads a Int32 written using WriteVariableInt32() + /// Reads a variable sized Int32 written using WriteVariableInt32() /// public int ReadVariableInt32() { @@ -347,7 +395,7 @@ namespace Lidgren.Network } /// - /// Reads a Int64 written using WriteVariableInt64() + /// Reads a variable sized Int64 written using WriteVariableInt64() /// public Int64 ReadVariableInt64() { @@ -356,7 +404,7 @@ namespace Lidgren.Network } /// - /// Reads a UInt32 written using WriteVariableInt64() + /// Reads a variable sized UInt32 written using WriteVariableInt64() /// [CLSCompliant(false)] public UInt64 ReadVariableUInt64() @@ -377,8 +425,10 @@ namespace Lidgren.Network } /// - /// Reads a float written using WriteSignedSingle() + /// Reads a 32 bit floating point value written using WriteSignedSingle() /// + /// The number of bits used when writing the value + /// A floating point value larger or equal to -1 and smaller or equal to 1 public float ReadSignedSingle(int numberOfBits) { uint encodedVal = ReadUInt32(numberOfBits); @@ -387,8 +437,10 @@ namespace Lidgren.Network } /// - /// Reads a float written using WriteUnitSingle() + /// Reads a 32 bit floating point value written using WriteUnitSingle() /// + /// The number of bits used when writing the value + /// A floating point value larger or equal to 0 and smaller or equal to 1 public float ReadUnitSingle(int numberOfBits) { uint encodedVal = ReadUInt32(numberOfBits); @@ -397,8 +449,12 @@ namespace Lidgren.Network } /// - /// Reads a float written using WriteRangedSingle() using the same MIN and MAX values + /// Reads a 32 bit floating point value written using WriteRangedSingle() /// + /// The minimum value used when writing the value + /// The maximum value used when writing the value + /// The number of bits used when writing the value + /// A floating point value larger or equal to MIN and smaller or equal to MAX public float ReadRangedSingle(float min, float max, int numberOfBits) { float range = max - min; @@ -409,8 +465,11 @@ namespace Lidgren.Network } /// - /// Reads an integer written using WriteRangedInteger() using the same min/max values + /// Reads a 32 bit integer value written using WriteRangedInteger() /// + /// The minimum value used when writing the value + /// The maximum value used when writing the value + /// A signed integer value larger or equal to MIN and smaller or equal to MAX public int ReadRangedInteger(int min, int max) { uint range = (uint)(max - min); @@ -421,7 +480,7 @@ namespace Lidgren.Network } /// - /// Reads a string + /// Reads a string written using Write(string) /// public string ReadString() { diff --git a/Lidgren.Network/NetIncomingMessage.cs b/Lidgren.Network/NetIncomingMessage.cs index de1e550..44d7061 100644 --- a/Lidgren.Network/NetIncomingMessage.cs +++ b/Lidgren.Network/NetIncomingMessage.cs @@ -104,6 +104,11 @@ namespace Lidgren.Network m_isFragment = false; } + /// + /// Decrypt a message + /// + /// The encryption algorithm used to encrypt the message + /// true on success public bool Decrypt(INetEncryption encryption) { return encryption.Decrypt(this); diff --git a/Lidgren.Network/NetIncomingMessageType.cs b/Lidgren.Network/NetIncomingMessageType.cs index b05cd56..bff9557 100644 --- a/Lidgren.Network/NetIncomingMessageType.cs +++ b/Lidgren.Network/NetIncomingMessageType.cs @@ -28,20 +28,78 @@ namespace Lidgren.Network [SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags")] public enum NetIncomingMessageType { + // // library note: values are power-of-two, but they are not flags - it's a convenience for NetPeerConfiguration.DisabledMessageTypes + // + + /// + /// Error; this value should never appear + /// Error = 0, + + /// + /// Status for a connection changed + /// StatusChanged = 1 << 0, // Data (string) + + /// + /// Data sent using SendUnconnectedMessage + /// UnconnectedData = 1 << 1, // Data Based on data received + + /// + /// Connection approval is needed + /// ConnectionApproval = 1 << 2, // Data + + /// + /// Application data + /// Data = 1 << 3, // Data Based on data received + + /// + /// Receipt of delivery + /// Receipt = 1 << 4, // Data + + /// + /// Discovery request for a response + /// DiscoveryRequest = 1 << 5, // (no data) + + /// + /// Discovery response to a request + /// DiscoveryResponse = 1 << 6, // Data + + /// + /// Verbose debug message + /// VerboseDebugMessage = 1 << 7, // Data (string) + + /// + /// Debug message + /// DebugMessage = 1 << 8, // Data (string) + + /// + /// Warning message + /// WarningMessage = 1 << 9, // Data (string) + + /// + /// Error message + /// ErrorMessage = 1 << 10, // Data (string) + + /// + /// NAT introduction was successful + /// NatIntroductionSuccess = 1 << 11, // Data (as passed to master server) + + /// + /// A roundtrip was measured and NetConnection.AverageRoundtripTime was updated + /// ConnectionLatencyUpdated = 1 << 12, // Seconds as a Single } } diff --git a/Lidgren.Network/NetOutgoingMessage.Write.cs b/Lidgren.Network/NetOutgoingMessage.Write.cs index d12bbd1..e94d551 100644 --- a/Lidgren.Network/NetOutgoingMessage.Write.cs +++ b/Lidgren.Network/NetOutgoingMessage.Write.cs @@ -114,9 +114,9 @@ namespace Lidgren.Network return; } - // - // 1 bit - // + /// + /// Writes a boolean value using 1 bit + /// public void Write(bool value) { EnsureBufferSize(m_bitLength + 1); @@ -124,9 +124,9 @@ namespace Lidgren.Network m_bitLength += 1; } - // - // 8 bit - // + /// + /// Write a byte + /// public void Write(byte source) { EnsureBufferSize(m_bitLength + 8); @@ -134,6 +134,9 @@ namespace Lidgren.Network m_bitLength += 8; } + /// + /// Writes a signed byte + /// [CLSCompliant(false)] public void Write(sbyte source) { @@ -142,6 +145,9 @@ namespace Lidgren.Network m_bitLength += 8; } + /// + /// Writes 1 to 8 bits of a byte + /// public void Write(byte source, int numberOfBits) { NetException.Assert((numberOfBits > 0 && numberOfBits <= 8), "Write(byte, numberOfBits) can only write between 1 and 8 bits"); @@ -150,6 +156,9 @@ namespace Lidgren.Network m_bitLength += numberOfBits; } + /// + /// Writes all bytes in an array + /// public void Write(byte[] source) { if (source == null) @@ -160,6 +169,9 @@ namespace Lidgren.Network m_bitLength += bits; } + /// + /// Writes the specified number of bytes from an array + /// public void Write(byte[] source, int offsetInBytes, int numberOfBytes) { if (source == null) @@ -170,9 +182,10 @@ namespace Lidgren.Network m_bitLength += bits; } - // - // 16 bit - // + /// + /// Writes an unsigned 16 bit integer + /// + /// [CLSCompliant(false)] public void Write(UInt16 source) { @@ -181,6 +194,9 @@ namespace Lidgren.Network m_bitLength += 16; } + /// + /// Writes an unsigned integer using 1 to 16 bits + /// [CLSCompliant(false)] public void Write(UInt16 source, int numberOfBits) { @@ -190,6 +206,9 @@ namespace Lidgren.Network m_bitLength += numberOfBits; } + /// + /// Writes a signed 16 bit integer + /// public void Write(Int16 source) { EnsureBufferSize(m_bitLength + 16); @@ -197,10 +216,10 @@ namespace Lidgren.Network m_bitLength += 16; } - // - // 32 bit - // #if UNSAFE + /// + /// Writes a 32 bit signed integer + /// public unsafe void Write(Int32 source) { EnsureBufferSize(m_bitLength + 32); @@ -220,6 +239,9 @@ namespace Lidgren.Network m_bitLength += 32; } #else + /// + /// Writes a 32 bit signed integer + /// public void Write(Int32 source) { EnsureBufferSize(m_bitLength + 32); @@ -229,6 +251,9 @@ namespace Lidgren.Network #endif #if UNSAFE + /// + /// Writes a 32 bit unsigned integer + /// public unsafe void Write(UInt32 source) { EnsureBufferSize(m_bitLength + 32); @@ -249,6 +274,9 @@ namespace Lidgren.Network m_bitLength += 32; } #else + /// + /// Writes a 32 bit unsigned integer + /// [CLSCompliant(false)] public void Write(UInt32 source) { @@ -258,6 +286,9 @@ namespace Lidgren.Network } #endif + /// + /// Writes a 32 bit signed integer + /// [CLSCompliant(false)] public void Write(UInt32 source, int numberOfBits) { @@ -267,6 +298,9 @@ namespace Lidgren.Network m_bitLength += numberOfBits; } + /// + /// Writes a signed integer using 1 to 32 bits + /// public void Write(Int32 source, int numberOfBits) { NetException.Assert((numberOfBits > 0 && numberOfBits <= 32), "Write(int, numberOfBits) can only write between 1 and 32 bits"); @@ -287,9 +321,9 @@ namespace Lidgren.Network m_bitLength += numberOfBits; } - // - // 64 bit - // + /// + /// Writes a 64 bit unsigned integer + /// [CLSCompliant(false)] public void Write(UInt64 source) { @@ -298,6 +332,9 @@ namespace Lidgren.Network m_bitLength += 64; } + /// + /// Writes an unsigned integer using 1 to 64 bits + /// [CLSCompliant(false)] public void Write(UInt64 source, int numberOfBits) { @@ -306,6 +343,9 @@ namespace Lidgren.Network m_bitLength += numberOfBits; } + /// + /// Writes a 64 bit signed integer + /// public void Write(Int64 source) { EnsureBufferSize(m_bitLength + 64); @@ -314,6 +354,9 @@ namespace Lidgren.Network m_bitLength += 64; } + /// + /// Writes a signed integer using 1 to 64 bits + /// public void Write(Int64 source, int numberOfBits) { EnsureBufferSize(m_bitLength + numberOfBits); @@ -326,6 +369,9 @@ namespace Lidgren.Network // Floating point // #if UNSAFE + /// + /// Writes a 32 bit floating point value + /// public unsafe void Write(float source) { uint val = *((uint*)&source); @@ -335,6 +381,9 @@ namespace Lidgren.Network Write(val); } #else + /// + /// Writes a 32 bit floating point value + /// public void Write(float source) { byte[] val = BitConverter.GetBytes(source); @@ -352,6 +401,9 @@ namespace Lidgren.Network #endif #if UNSAFE + /// + /// Writes a 64 bit floating point value + /// public unsafe void Write(double source) { ulong val = *((ulong*)&source); @@ -361,6 +413,9 @@ namespace Lidgren.Network Write(val); } #else + /// + /// Writes a 64 bit floating point value + /// public void Write(double source) { byte[] val = BitConverter.GetBytes(source); diff --git a/Lidgren.Network/NetPeer.Send.cs b/Lidgren.Network/NetPeer.Send.cs index 384b496..d8fdf3f 100644 --- a/Lidgren.Network/NetPeer.Send.cs +++ b/Lidgren.Network/NetPeer.Send.cs @@ -71,6 +71,13 @@ namespace Lidgren.Network return mtu; } + /// + /// Send a message to a list of connections + /// + /// The message to send + /// The list of recipients to send to + /// How to deliver the message + /// Sequence channel within the delivery method public void SendMessage(NetOutgoingMessage msg, IList recipients, NetDeliveryMethod method, int sequenceChannel) { if (msg == null) diff --git a/Lidgren.Network/NetPeer.cs b/Lidgren.Network/NetPeer.cs index da05118..e1ef915 100644 --- a/Lidgren.Network/NetPeer.cs +++ b/Lidgren.Network/NetPeer.cs @@ -85,6 +85,9 @@ namespace Lidgren.Network /// public NetPeerConfiguration Configuration { get { return m_configuration; } } + /// + /// NetPeer constructor + /// public NetPeer(NetPeerConfiguration config) { m_configuration = config; @@ -132,6 +135,9 @@ namespace Lidgren.Network Thread.Sleep(10); } + /// + /// Get the connection, if any, for a certain remote endpoint + /// public NetConnection GetConnection(IPEndPoint ep) { NetConnection retval; @@ -253,6 +259,9 @@ namespace Lidgren.Network } #if DEBUG + /// + /// Send raw bytes; only used for debugging + /// public void RawSend(byte[] arr, int offset, int length, IPEndPoint destination) { // wrong thread - this miiiight crash with network thread... but what's a boy to do. diff --git a/Lidgren.Network/NetPeerConfiguration.cs b/Lidgren.Network/NetPeerConfiguration.cs index efc9825..b90bbab 100644 --- a/Lidgren.Network/NetPeerConfiguration.cs +++ b/Lidgren.Network/NetPeerConfiguration.cs @@ -59,6 +59,9 @@ namespace Lidgren.Network internal float m_expandMTUFrequency; internal int m_expandMTUFailAttempts; + /// + /// NetPeerConfiguration constructor + /// public NetPeerConfiguration(string appIdentifier) { if (string.IsNullOrEmpty(appIdentifier)) diff --git a/Lidgren.Network/NetQueue.cs b/Lidgren.Network/NetQueue.cs index 4636953..2b7c59b 100644 --- a/Lidgren.Network/NetQueue.cs +++ b/Lidgren.Network/NetQueue.cs @@ -57,6 +57,9 @@ namespace Lidgren.Network /// public int Capacity { get { return m_items.Length; } } + /// + /// NetQueue constructor + /// public NetQueue(int initialCapacity) { m_lock = new object(); diff --git a/Lidgren.Network/NetRandom.cs b/Lidgren.Network/NetRandom.cs index 975f4d4..2f9bf34 100644 --- a/Lidgren.Network/NetRandom.cs +++ b/Lidgren.Network/NetRandom.cs @@ -72,6 +72,9 @@ namespace Lidgren.Network Reinitialise(seed); } + /// + /// Create a semi-random seed based on an object + /// public int GetSeed(object forObject) { // mix some semi-random properties diff --git a/Lidgren.Network/NetSRP.cs b/Lidgren.Network/NetSRP.cs index 769663a..fa60cd2 100644 --- a/Lidgren.Network/NetSRP.cs +++ b/Lidgren.Network/NetSRP.cs @@ -123,6 +123,9 @@ namespace Lidgren.Network return B.ToByteArrayUnsigned(); } + /// + /// Compute intermediate value U + /// public static byte[] ComputeU(byte[] clientPublicEphemeral, byte[] serverPublicEphemeral) { // u = SHA-1(A || B) @@ -140,6 +143,9 @@ namespace Lidgren.Network return new NetBigInteger(NetUtility.ToHexString(ccHashed), 16).ToByteArrayUnsigned(); } + /// + /// Computes the server session value + /// public static byte[] ComputeServerSessionValue(byte[] clientPublicEphemeral, byte[] verifier, byte[] udata, byte[] serverPrivateEphemeral) { // S = (Av^u) ^ b (mod N) @@ -153,6 +159,9 @@ namespace Lidgren.Network return retval.ToByteArrayUnsigned(); } + /// + /// Computes the client session value + /// public static byte[] ComputeClientSessionValue(byte[] serverPublicEphemeral, byte[] xdata, byte[] udata, byte[] clientPrivateEphemeral) { // (B - kg^x) ^ (a + ux) (mod N) diff --git a/Lidgren.Network/NetServer.cs b/Lidgren.Network/NetServer.cs index 56ee3dd..02b1ee2 100644 --- a/Lidgren.Network/NetServer.cs +++ b/Lidgren.Network/NetServer.cs @@ -8,6 +8,9 @@ namespace Lidgren.Network /// public class NetServer : NetPeer { + /// + /// NetServer constructor + /// public NetServer(NetPeerConfiguration config) : base(config) { diff --git a/Lidgren.Network/NetUtility.cs b/Lidgren.Network/NetUtility.cs index b0d6128..c992902 100644 --- a/Lidgren.Network/NetUtility.cs +++ b/Lidgren.Network/NetUtility.cs @@ -118,6 +118,9 @@ namespace Lidgren.Network return best; } + /// + /// Returns the physical (MAC) address for the first usable network interface + /// public static PhysicalAddress GetMacAddress() { NetworkInterface ni = GetNetworkInterface(); @@ -126,11 +129,17 @@ namespace Lidgren.Network return ni.GetPhysicalAddress(); } + /// + /// Create a hex string from an Int64 value + /// public static string ToHexString(long data) { return ToHexString(BitConverter.GetBytes(data)); } + /// + /// Create a hex string from an array of bytes + /// public static string ToHexString(byte[] data) { char[] c = new char[data.Length * 2]; @@ -283,6 +292,9 @@ namespace Lidgren.Network return retval; } + /// + /// Gets the window size used internally in the library for a certain delivery method + /// public static int GetWindowSize(NetDeliveryMethod method) { switch (method) diff --git a/UnitTests/Program.cs b/UnitTests/Program.cs index fbfcdef..93621ee 100644 --- a/UnitTests/Program.cs +++ b/UnitTests/Program.cs @@ -49,6 +49,9 @@ namespace UnitTests Console.ReadKey(); } + /// + /// Helper method + /// public static NetIncomingMessage CreateIncomingMessage(byte[] fromData, int bitLength) { NetIncomingMessage inc = (NetIncomingMessage)Activator.CreateInstance(typeof(NetIncomingMessage), true);