//****************************************************************************************************** // TransportStatistics.cs - Gbtc // // Copyright © 2010, 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 Eclipse Public License -v 1.0 (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/eclipse-1.0.php // // 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. // 10/8/2012 - Danyelle Gilliam // Modified Header // //****************************************************************************************************** #region [ Contributor License Agreements ] //****************************************************************************************************** // // Copyright © 2011, Grid Protection Alliance. All Rights Reserved. // // The GPA licenses this file to you under the Eclipse Public License -v 1.0 (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/eclipse-1.0.php // // 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. // //****************************************************************************************************** #endregion 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. /// public DateTime LastSend; /// /// of the last receive operation. /// 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.Now; 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.Now; LastBytesReceived = bytesReceived; TotalBytesReceived += LastBytesReceived; } #endregion } }