//******************************************************************************************************
// TransportStatistics.cs - Gbtc
//
// Copyright © 2012, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may
// not use this file except in compliance with the License. You may obtain a copy of the License at:
//
// http://www.opensource.org/licenses/MIT
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 11/12/2008 - Pinal C. Patel
// Generated original version of source code.
// 09/14/2009 - Stephen C. Wills
// Added new header and license agreement.
// 12/13/2012 - Starlynn Danyelle Gilliam
// Modified Header.
//
//******************************************************************************************************
using System;
namespace GSF.Communication
{
///
/// A class for statistics related to server-client communication.
///
public class TransportStatistics
{
#region [ Members ]
// Fields
///
/// of the last send operation. (UTC Time)
///
public DateTime LastSend;
///
/// of the last receive operation. (UTC Time)
///
public DateTime LastReceive;
///
/// Number of bytes sent in the last send operation.
///
public int LastBytesSent;
///
/// Number of bytes received in the last receive operation.
///
public int LastBytesReceived;
///
/// Total number of bytes sent.
///
public long TotalBytesSent;
///
/// Total number of bytes received.
///
public long TotalBytesReceived;
/////
///// Size of the current payload being received.
/////
//public int ReceivePayloadLength;
#endregion
#region [ Methods ]
///
/// Resets the .
///
public void Reset()
{
LastSend = DateTime.MinValue;
LastReceive = DateTime.MinValue;
LastBytesSent = 0;
LastBytesReceived = 0;
TotalBytesSent = 0;
TotalBytesReceived = 0;
}
///
/// Updates statistics related to sending of data.
///
/// Number of bytes sent in the send operation.
public void UpdateBytesSent(int bytesSent)
{
LastSend = DateTime.UtcNow;
LastBytesSent = bytesSent;
TotalBytesSent += LastBytesSent;
}
///
/// Updates statistics related to receiving of data.
///
/// Number of bytes received in the receive operation.
public void UpdateBytesReceived(int bytesReceived)
{
LastReceive = DateTime.UtcNow;
LastBytesReceived = bytesReceived;
TotalBytesReceived += LastBytesReceived;
}
#endregion
}
}