</When>
<Otherwise>
<ItemGroup>
- <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
+ <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework">
+ <Private>False</Private>
+ </Reference>
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
+ <Compile Include="StatisticsTests.cs" />
<Compile Include="TestHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TcpConnectionTests.cs" />
--- /dev/null
+using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Hazel.UnitTests
+{
+ [TestClass]
+ public class StatisticsTests
+ {
+ [TestMethod]
+ public void SendTests()
+ {
+ ConnectionStatistics statistics = new ConnectionStatistics();
+
+ statistics.LogUnreliableSend(10, 11);
+
+ Assert.AreEqual(1, statistics.MessagesSent);
+ Assert.AreEqual(1, statistics.UnreliableMessagesSent);
+ Assert.AreEqual(0, statistics.ReliableMessagesSent);
+ Assert.AreEqual(0, statistics.FragmentedMessagesSent);
+ Assert.AreEqual(0, statistics.AcknowledgementMessagesSent);
+ Assert.AreEqual(0, statistics.HelloMessagesSent);
+
+ Assert.AreEqual(10, statistics.DataBytesSent);
+ Assert.AreEqual(11, statistics.TotalBytesSent);
+
+ statistics.LogReliableSend(5, 8);
+
+ Assert.AreEqual(2, statistics.MessagesSent);
+ Assert.AreEqual(1, statistics.UnreliableMessagesSent);
+ Assert.AreEqual(1, statistics.ReliableMessagesSent);
+ Assert.AreEqual(0, statistics.FragmentedMessagesSent);
+ Assert.AreEqual(0, statistics.AcknowledgementMessagesSent);
+ Assert.AreEqual(0, statistics.HelloMessagesSent);
+
+ Assert.AreEqual(15, statistics.DataBytesSent);
+ Assert.AreEqual(19, statistics.TotalBytesSent);
+
+ statistics.LogFragmentedSend(6, 10);
+
+ Assert.AreEqual(3, statistics.MessagesSent);
+ Assert.AreEqual(1, statistics.UnreliableMessagesSent);
+ Assert.AreEqual(1, statistics.ReliableMessagesSent);
+ Assert.AreEqual(1, statistics.FragmentedMessagesSent);
+ Assert.AreEqual(0, statistics.AcknowledgementMessagesSent);
+ Assert.AreEqual(0, statistics.HelloMessagesSent);
+
+ Assert.AreEqual(21, statistics.DataBytesSent);
+ Assert.AreEqual(29, statistics.TotalBytesSent);
+
+ statistics.LogAcknowledgementSend(4);
+
+ Assert.AreEqual(4, statistics.MessagesSent);
+ Assert.AreEqual(1, statistics.UnreliableMessagesSent);
+ Assert.AreEqual(1, statistics.ReliableMessagesSent);
+ Assert.AreEqual(1, statistics.FragmentedMessagesSent);
+ Assert.AreEqual(1, statistics.AcknowledgementMessagesSent);
+ Assert.AreEqual(0, statistics.HelloMessagesSent);
+
+ Assert.AreEqual(21, statistics.DataBytesSent);
+ Assert.AreEqual(33, statistics.TotalBytesSent);
+
+ statistics.LogHelloSend(7);
+
+ Assert.AreEqual(5, statistics.MessagesSent);
+ Assert.AreEqual(1, statistics.UnreliableMessagesSent);
+ Assert.AreEqual(1, statistics.ReliableMessagesSent);
+ Assert.AreEqual(1, statistics.FragmentedMessagesSent);
+ Assert.AreEqual(1, statistics.AcknowledgementMessagesSent);
+ Assert.AreEqual(1, statistics.HelloMessagesSent);
+
+ Assert.AreEqual(21, statistics.DataBytesSent);
+ Assert.AreEqual(40, statistics.TotalBytesSent);
+
+ Assert.AreEqual(0, statistics.MessagesReceived);
+ Assert.AreEqual(0, statistics.UnreliableMessagesReceived);
+ Assert.AreEqual(0, statistics.ReliableMessagesReceived);
+ Assert.AreEqual(0, statistics.FragmentedMessagesReceived);
+ Assert.AreEqual(0, statistics.AcknowledgementMessagesReceived);
+ Assert.AreEqual(0, statistics.HelloMessagesReceived);
+
+ Assert.AreEqual(0, statistics.DataBytesReceived);
+ Assert.AreEqual(0, statistics.TotalBytesReceived);
+ }
+
+ [TestMethod]
+ public void ReceiveTests()
+ {
+ ConnectionStatistics statistics = new ConnectionStatistics();
+
+ statistics.LogUnreliableReceive(10, 11);
+
+ Assert.AreEqual(1, statistics.MessagesReceived);
+ Assert.AreEqual(1, statistics.UnreliableMessagesReceived);
+ Assert.AreEqual(0, statistics.ReliableMessagesReceived);
+ Assert.AreEqual(0, statistics.FragmentedMessagesReceived);
+ Assert.AreEqual(0, statistics.AcknowledgementMessagesReceived);
+ Assert.AreEqual(0, statistics.HelloMessagesReceived);
+
+ Assert.AreEqual(10, statistics.DataBytesReceived);
+ Assert.AreEqual(11, statistics.TotalBytesReceived);
+
+ statistics.LogReliableReceive(5, 8);
+
+ Assert.AreEqual(2, statistics.MessagesReceived);
+ Assert.AreEqual(1, statistics.UnreliableMessagesReceived);
+ Assert.AreEqual(1, statistics.ReliableMessagesReceived);
+ Assert.AreEqual(0, statistics.FragmentedMessagesReceived);
+ Assert.AreEqual(0, statistics.AcknowledgementMessagesReceived);
+ Assert.AreEqual(0, statistics.HelloMessagesReceived);
+
+ Assert.AreEqual(15, statistics.DataBytesReceived);
+ Assert.AreEqual(19, statistics.TotalBytesReceived);
+
+ statistics.LogFragmentedReceive(6, 10);
+
+ Assert.AreEqual(3, statistics.MessagesReceived);
+ Assert.AreEqual(1, statistics.UnreliableMessagesReceived);
+ Assert.AreEqual(1, statistics.ReliableMessagesReceived);
+ Assert.AreEqual(1, statistics.FragmentedMessagesReceived);
+ Assert.AreEqual(0, statistics.AcknowledgementMessagesReceived);
+ Assert.AreEqual(0, statistics.HelloMessagesReceived);
+
+ Assert.AreEqual(21, statistics.DataBytesReceived);
+ Assert.AreEqual(29, statistics.TotalBytesReceived);
+
+ statistics.LogAcknowledgementReceive(4);
+
+ Assert.AreEqual(4, statistics.MessagesReceived);
+ Assert.AreEqual(1, statistics.UnreliableMessagesReceived);
+ Assert.AreEqual(1, statistics.ReliableMessagesReceived);
+ Assert.AreEqual(1, statistics.FragmentedMessagesReceived);
+ Assert.AreEqual(1, statistics.AcknowledgementMessagesReceived);
+ Assert.AreEqual(0, statistics.HelloMessagesReceived);
+
+ Assert.AreEqual(21, statistics.DataBytesReceived);
+ Assert.AreEqual(33, statistics.TotalBytesReceived);
+
+ statistics.LogHelloReceive(7);
+
+ Assert.AreEqual(5, statistics.MessagesReceived);
+ Assert.AreEqual(1, statistics.UnreliableMessagesReceived);
+ Assert.AreEqual(1, statistics.ReliableMessagesReceived);
+ Assert.AreEqual(1, statistics.FragmentedMessagesReceived);
+ Assert.AreEqual(1, statistics.AcknowledgementMessagesReceived);
+ Assert.AreEqual(1, statistics.HelloMessagesReceived);
+
+ Assert.AreEqual(21, statistics.DataBytesReceived);
+ Assert.AreEqual(40, statistics.TotalBytesReceived);
+
+ Assert.AreEqual(0, statistics.MessagesSent);
+ Assert.AreEqual(0, statistics.UnreliableMessagesSent);
+ Assert.AreEqual(0, statistics.ReliableMessagesSent);
+ Assert.AreEqual(0, statistics.FragmentedMessagesSent);
+ Assert.AreEqual(0, statistics.AcknowledgementMessagesSent);
+ Assert.AreEqual(0, statistics.HelloMessagesSent);
+
+ Assert.AreEqual(0, statistics.DataBytesSent);
+ Assert.AreEqual(0, statistics.TotalBytesSent);
+ }
+ }
+}
//Setup listener
listener.NewConnection += delegate(object sender, NewConnectionEventArgs args)
{
- Assert.AreEqual(0, args.Connection.Statistics.DataBytesReceived);
- Assert.AreEqual(0, args.Connection.Statistics.TotalBytesReceived);
-
args.Connection.SendBytes(data, sendOption);
-
- Assert.AreEqual(data.Length, args.Connection.Statistics.DataBytesSent);
- Assert.AreEqual(data.Length + headerSize, args.Connection.Statistics.TotalBytesSent);
};
listener.Start();
//Wait until data is received
mutex.WaitOne();
-
- Assert.AreEqual(1, connection.Statistics.DataBytesSent);
- Assert.AreEqual(data.Length, connection.Statistics.DataBytesReceived);
- Assert.AreEqual(totalHandshakeSize, connection.Statistics.TotalBytesSent);
- Assert.AreEqual(data.Length + headerSize, connection.Statistics.TotalBytesReceived);
}
/// <summary>
Assert.AreEqual(sendOption, innerArgs.SendOption);
- Assert.AreEqual(0, args.Connection.Statistics.DataBytesSent);
- Assert.AreEqual(data.Length, args.Connection.Statistics.DataBytesReceived);
- Assert.AreEqual(0, args.Connection.Statistics.TotalBytesSent);
- Assert.AreEqual(data.Length + headerSize, args.Connection.Statistics.TotalBytesReceived);
-
mutex2.Set();
};
//Wait until data is received
mutex2.WaitOne();
-
- Assert.AreEqual(data.Length + 1, connection.Statistics.DataBytesSent);
- Assert.AreEqual(0, connection.Statistics.DataBytesReceived);
- Assert.AreEqual(totalHandshakeSize + data.Length + headerSize, connection.Statistics.TotalBytesSent);
- Assert.AreEqual(0, connection.Statistics.TotalBytesReceived);
}
/// <summary>
public class ConnectionStatistics
{
/// <summary>
- /// The number of messages sent.
+ /// The total number of messages sent.
+ /// </summary>
+ public long MessagesSent
+ {
+ get
+ {
+ return UnreliableMessagesSent + ReliableMessagesSent + FragmentedMessagesSent + AcknowledgementMessagesSent + HelloMessagesSent;
+ }
+ }
+
+ /// <summary>
+ /// The number of unreliable messages sent.
/// </summary>
/// <remarks>
- /// This is the number of messages that were sent from the <see cref="Connection"/>, incremented each time that
- /// LogSend is called by the Connection. Messages that caused an error are not counted and messages are only
- /// counted once all other operations in the send are complete.
+ /// This is the number of unreliable messages that were sent from the <see cref="Connection"/>, incremented
+ /// each time that LogUnreliableSend is called by the Connection. Messages that caused an error are not
+ /// counted and messages are only counted once all other operations in the send are complete.
/// </remarks>
- public long MessagesSent
+ public long UnreliableMessagesSent
+ {
+ get
+ {
+ return Interlocked.Read(ref unreliableMessagesSent);
+ }
+ }
+
+ /// <summary>
+ /// The number of unreliable messages sent.
+ /// </summary>
+ long unreliableMessagesSent;
+
+ /// <summary>
+ /// The number of reliable messages sent.
+ /// </summary>
+ /// <remarks>
+ /// This is the number of reliable messages that were sent from the <see cref="Connection"/>, incremented
+ /// each time that LogReliableSend is called by the Connection. Messages that caused an error are not
+ /// counted and messages are only counted once all other operations in the send are complete.
+ /// </remarks>
+ public long ReliableMessagesSent
+ {
+ get
+ {
+ return Interlocked.Read(ref reliableMessagesSent);
+ }
+ }
+
+ /// <summary>
+ /// The number of unreliable messages sent.
+ /// </summary>
+ long reliableMessagesSent;
+
+ /// <summary>
+ /// The number of fragmented messages sent.
+ /// </summary>
+ /// <remarks>
+ /// This is the number of fragmented messages that were sent from the <see cref="Connection"/>, incremented
+ /// each time that LogFragmentedSend is called by the Connection. Messages that caused an error are not
+ /// counted and messages are only counted once all other operations in the send are complete.
+ /// </remarks>
+ public long FragmentedMessagesSent
+ {
+ get
+ {
+ return Interlocked.Read(ref fragmentedMessagesSent);
+ }
+ }
+
+ /// <summary>
+ /// The number of fragmented messages sent.
+ /// </summary>
+ long fragmentedMessagesSent;
+
+ /// <summary>
+ /// The number of acknowledgement messages sent.
+ /// </summary>
+ /// <remarks>
+ /// This is the number of acknowledgements that were sent from the <see cref="Connection"/>, incremented
+ /// each time that LogAcknowledgementSend is called by the Connection. Messages that caused an error are not
+ /// counted and messages are only counted once all other operations in the send are complete.
+ /// </remarks>
+ public long AcknowledgementMessagesSent
+ {
+ get
+ {
+ return Interlocked.Read(ref acknowledgementMessagesSent);
+ }
+ }
+
+ /// <summary>
+ /// The number of acknowledgement messages sent.
+ /// </summary>
+ long acknowledgementMessagesSent;
+
+ /// <summary>
+ /// The number of hello messages sent.
+ /// </summary>
+ /// <remarks>
+ /// This is the number of hello messages that were sent from the <see cref="Connection"/>, incremented
+ /// each time that LogHelloSend is called by the Connection. Messages that caused an error are not
+ /// counted and messages are only counted once all other operations in the send are complete.
+ /// </remarks>
+ public long HelloMessagesSent
{
get
{
- return Interlocked.Read(ref messagesSent);
+ return Interlocked.Read(ref helloMessagesSent);
}
}
/// <summary>
- /// The number of messages sent.
+ /// The number of hello messages sent.
/// </summary>
- long messagesSent;
+ long helloMessagesSent;
/// <summary>
/// The number of bytes of data sent.
long totalBytesSent;
/// <summary>
- /// The number of messages received.
+ /// The total number of messages received.
+ /// </summary>
+ public long MessagesReceived
+ {
+ get
+ {
+ return UnreliableMessagesReceived + ReliableMessagesReceived + FragmentedMessagesReceived + AcknowledgementMessagesReceived + helloMessagesReceived;
+ }
+ }
+
+ /// <summary>
+ /// The number of unreliable messages received.
/// </summary>
/// <remarks>
- /// This is the number of messages that were received by the <see cref="Connection"/>, incremented each time that
- /// LogReceive is called by the Connection. Messages are counted before the receive event is invoked.
+ /// This is the number of unreliable messages that were received by the <see cref="Connection"/>, incremented
+ /// each time that LogUnreliableReceive is called by the Connection. Messages are counted before the receive event is invoked.
/// </remarks>
- public long MessagesReceived
+ public long UnreliableMessagesReceived
{
get
{
- return Interlocked.Read(ref messagesReceived);
+ return Interlocked.Read(ref unreliableMessagesReceived);
}
}
/// <summary>
- /// The number of messages received.
+ /// The number of unreliable messages received.
/// </summary>
- long messagesReceived;
+ long unreliableMessagesReceived;
+
+ /// <summary>
+ /// The number of reliable messages received.
+ /// </summary>
+ /// <remarks>
+ /// This is the number of reliable messages that were received by the <see cref="Connection"/>, incremented
+ /// each time that LogReliableReceive is called by the Connection. Messages are counted before the receive event is invoked.
+ /// </remarks>
+ public long ReliableMessagesReceived
+ {
+ get
+ {
+ return Interlocked.Read(ref reliableMessagesReceived);
+ }
+ }
+
+ /// <summary>
+ /// The number of reliable messages received.
+ /// </summary>
+ long reliableMessagesReceived;
+
+ /// <summary>
+ /// The number of fragmented messages received.
+ /// </summary>
+ /// <remarks>
+ /// This is the number of fragmented messages that were received by the <see cref="Connection"/>, incremented
+ /// each time that LogFragmentedReceive is called by the Connection. Messages are counted before the receive event is invoked.
+ /// </remarks>
+ public long FragmentedMessagesReceived
+ {
+ get
+ {
+ return Interlocked.Read(ref fragmentedMessagesReceived);
+ }
+ }
+
+ /// <summary>
+ /// The number of fragmented messages received.
+ /// </summary>
+ long fragmentedMessagesReceived;
+
+ /// <summary>
+ /// The number of acknowledgement messages received.
+ /// </summary>
+ /// <remarks>
+ /// This is the number of acknowledgement messages that were received by the <see cref="Connection"/>, incremented
+ /// each time that LogAcknowledgemntReceive is called by the Connection. Messages are counted before the receive event is invoked.
+ /// </remarks>
+ public long AcknowledgementMessagesReceived
+ {
+ get
+ {
+ return Interlocked.Read(ref acknowledgementMessagesReceived);
+ }
+ }
+
+ /// <summary>
+ /// The number of acknowledgement messages received.
+ /// </summary>
+ long acknowledgementMessagesReceived;
+
+ /// <summary>
+ /// The number of hello messages received.
+ /// </summary>
+ /// <remarks>
+ /// This is the number of hello messages that were received by the <see cref="Connection"/>, incremented
+ /// each time that LogHelloReceive is called by the Connection. Messages are counted before the receive event is invoked.
+ /// </remarks>
+ public long HelloMessagesReceived
+ {
+ get
+ {
+ return Interlocked.Read(ref helloMessagesReceived);
+ }
+ }
+
+ /// <summary>
+ /// The number of hello messages received.
+ /// </summary>
+ long helloMessagesReceived;
/// <summary>
/// The number of bytes of data received.
long totalBytesReceived;
/// <summary>
- /// Logs the sending of a data packet in the statistics.
+ /// Logs the sending of an unreliable data packet in the statistics.
/// </summary>
/// <param name="dataLength">The number of bytes of data sent.</param>
/// <param name="totalLength">The total number of bytes sent.</param>
/// <remarks>
/// This should be called after the data has been sent and should only be called for data that is sent sucessfully.
/// </remarks>
- internal void LogSend(int dataLength, int totalLength)
+ internal void LogUnreliableSend(int dataLength, int totalLength)
{
- Interlocked.Increment(ref messagesSent);
+ Interlocked.Increment(ref unreliableMessagesSent);
Interlocked.Add(ref dataBytesSent, dataLength);
Interlocked.Add(ref totalBytesSent, totalLength);
}
/// <summary>
- /// Logs the receiving of a data packet in the statistics.
+ /// Logs the sending of a reliable data packet in the statistics.
+ /// </summary>
+ /// <param name="dataLength">The number of bytes of data sent.</param>
+ /// <param name="totalLength">The total number of bytes sent.</param>
+ /// <remarks>
+ /// This should be called after the data has been sent and should only be called for data that is sent sucessfully.
+ /// </remarks>
+ internal void LogReliableSend(int dataLength, int totalLength)
+ {
+ Interlocked.Increment(ref reliableMessagesSent);
+ Interlocked.Add(ref dataBytesSent, dataLength);
+ Interlocked.Add(ref totalBytesSent, totalLength);
+ }
+
+ /// <summary>
+ /// Logs the sending of a fragmented data packet in the statistics.
+ /// </summary>
+ /// <param name="dataLength">The number of bytes of data sent.</param>
+ /// <param name="totalLength">The total number of bytes sent.</param>
+ /// <remarks>
+ /// This should be called after the data has been sent and should only be called for data that is sent sucessfully.
+ /// </remarks>
+ internal void LogFragmentedSend(int dataLength, int totalLength)
+ {
+ Interlocked.Increment(ref fragmentedMessagesSent);
+ Interlocked.Add(ref dataBytesSent, dataLength);
+ Interlocked.Add(ref totalBytesSent, totalLength);
+ }
+
+ /// <summary>
+ /// Logs the sending of a acknowledgement data packet in the statistics.
+ /// </summary>
+ /// <param name="totalLength">The total number of bytes sent.</param>
+ /// <remarks>
+ /// This should be called after the data has been sent and should only be called for data that is sent sucessfully.
+ /// </remarks>
+ internal void LogAcknowledgementSend(int totalLength)
+ {
+ Interlocked.Increment(ref acknowledgementMessagesSent);
+ Interlocked.Add(ref totalBytesSent, totalLength);
+ }
+
+ /// <summary>
+ /// Logs the sending of a hellp data packet in the statistics.
+ /// </summary>
+ /// <param name="totalLength">The total number of bytes sent.</param>
+ /// <remarks>
+ /// This should be called after the data has been sent and should only be called for data that is sent sucessfully.
+ /// </remarks>
+ internal void LogHelloSend(int totalLength)
+ {
+ Interlocked.Increment(ref helloMessagesSent);
+ Interlocked.Add(ref totalBytesSent, totalLength);
+ }
+
+ /// <summary>
+ /// Logs the receiving of an unreliable data packet in the statistics.
+ /// </summary>
+ /// <param name="dataLength">The number of bytes of data received.</param>
+ /// <param name="totalLength">The total number of bytes received.</param>
+ /// <remarks>
+ /// This should be called before the received event is invoked so it is up to date for subscribers to that event.
+ /// </remarks>
+ internal void LogUnreliableReceive(int dataLength, int totalLength)
+ {
+ Interlocked.Increment(ref unreliableMessagesReceived);
+ Interlocked.Add(ref dataBytesReceived, dataLength);
+ Interlocked.Add(ref totalBytesReceived, totalLength);
+ }
+
+ /// <summary>
+ /// Logs the receiving of a reliable data packet in the statistics.
+ /// </summary>
+ /// <param name="dataLength">The number of bytes of data received.</param>
+ /// <param name="totalLength">The total number of bytes received.</param>
+ /// <remarks>
+ /// This should be called before the received event is invoked so it is up to date for subscribers to that event.
+ /// </remarks>
+ internal void LogReliableReceive(int dataLength, int totalLength)
+ {
+ Interlocked.Increment(ref reliableMessagesReceived);
+ Interlocked.Add(ref dataBytesReceived, dataLength);
+ Interlocked.Add(ref totalBytesReceived, totalLength);
+ }
+
+ /// <summary>
+ /// Logs the receiving of a fragmented data packet in the statistics.
/// </summary>
/// <param name="dataLength">The number of bytes of data received.</param>
/// <param name="totalLength">The total number of bytes received.</param>
/// <remarks>
/// This should be called before the received event is invoked so it is up to date for subscribers to that event.
/// </remarks>
- internal void LogReceive(int dataLength, int totalLength)
+ internal void LogFragmentedReceive(int dataLength, int totalLength)
{
- Interlocked.Increment(ref messagesReceived);
+ Interlocked.Increment(ref fragmentedMessagesReceived);
Interlocked.Add(ref dataBytesReceived, dataLength);
Interlocked.Add(ref totalBytesReceived, totalLength);
}
+
+ /// <summary>
+ /// Logs the receiving of an acknowledgement data packet in the statistics.
+ /// </summary>
+ /// <param name="totalLength">The total number of bytes received.</param>
+ /// <remarks>
+ /// This should be called before the received event is invoked so it is up to date for subscribers to that event.
+ /// </remarks>
+ internal void LogAcknowledgementReceive(int totalLength)
+ {
+ Interlocked.Increment(ref acknowledgementMessagesReceived);
+ Interlocked.Add(ref totalBytesReceived, totalLength);
+ }
+
+ /// <summary>
+ /// Logs the receiving of a hello data packet in the statistics.
+ /// </summary>
+ /// <param name="totalLength">The total number of bytes received.</param>
+ /// <remarks>
+ /// This should be called before the received event is invoked so it is up to date for subscribers to that event.
+ /// </remarks>
+ internal void LogHelloReceive(int totalLength)
+ {
+ Interlocked.Increment(ref helloMessagesReceived);
+ Interlocked.Add(ref totalBytesReceived, totalLength);
+ }
}
}
// NuGet version information
[assembly: AssemblyInformationalVersion("0.0.0-beta")]
+
+// Show internals to unit testing assembly so it can test
+[assembly:InternalsVisibleTo("Hazel.UnitTests")]
\ No newline at end of file
}
}
- Statistics.LogSend(bytes.Length, fullBytes.Length);
+ Statistics.LogFragmentedSend(bytes.Length, fullBytes.Length);
}
/// <summary>
HandleDisconnect(new HazelException("An exception occured while initiating a header receive operation.", e));
}
- Statistics.LogReceive(bytes.Length, bytes.Length + 4);
+ Statistics.LogFragmentedReceive(bytes.Length, bytes.Length + 4);
//Fire DataReceived event
InvokeDataReceived(bytes, SendOption.FragmentedReliable);
//Write to connection
WriteBytesToConnection(bytes);
- Statistics.LogSend(data.Length, bytes.Length);
+ Statistics.LogReliableSend(data.Length, bytes.Length);
}
/// <summary>
if (ProcessReliableReceive(buffer))
InvokeDataReceived(SendOption.Reliable, buffer, 3);
- Statistics.LogReceive(buffer.Length - 3, buffer.Length);
+ Statistics.LogReliableReceive(buffer.Length - 3, buffer.Length);
}
/// <summary>
}
}
- Statistics.LogReceive(0, bytes.Length);
+ Statistics.LogReliableReceive(0, bytes.Length);
}
/// <summary>
//We need to acknowledge hello messages but dont want to invoke any events!
case (byte)SendOptionInternal.Hello:
ProcessReliableReceive(buffer);
- Statistics.LogReceive(buffer.Length - 3, buffer.Length);
+ Statistics.LogHelloReceive(buffer.Length);
break;
case (byte)SendOptionInternal.Disconnect:
- HandleDisconnect();
- Statistics.LogReceive(0, buffer.Length);
+ HandleDisconnect();
break;
//Treat everything else as unreliable
default:
InvokeDataReceived(SendOption.None, buffer, 1);
- Statistics.LogReceive(buffer.Length - 1, buffer.Length);
+ Statistics.LogUnreliableReceive(buffer.Length - 1, buffer.Length);
break;
}
}
//Write to connection
WriteBytesToConnection(bytes);
- Statistics.LogSend(data.Length, bytes.Length);
+ Statistics.LogUnreliableSend(data.Length, bytes.Length);
}
/// <summary>