generated from gemstone/gemtem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TransportStatistics.cs
117 lines (101 loc) · 3.88 KB
/
TransportStatistics.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//******************************************************************************************************
// 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 Gemstone.Communication
{
/// <summary>
/// A class for statistics related to server-client communication.
/// </summary>
public class TransportStatistics
{
#region [ Members ]
// Fields
/// <summary>
/// <see cref="DateTime"/> of the last send operation. (UTC Time)
/// </summary>
public DateTime LastSend;
/// <summary>
/// <see cref="DateTime"/> of the last receive operation. (UTC Time)
/// </summary>
public DateTime LastReceive;
/// <summary>
/// Number of bytes sent in the last send operation.
/// </summary>
public int LastBytesSent;
/// <summary>
/// Number of bytes received in the last receive operation.
/// </summary>
public int LastBytesReceived;
/// <summary>
/// Total number of bytes sent.
/// </summary>
public long TotalBytesSent;
/// <summary>
/// Total number of bytes received.
/// </summary>
public long TotalBytesReceived;
///// <summary>
///// Size of the current payload being received.
///// </summary>
//public int ReceivePayloadLength;
#endregion
#region [ Methods ]
/// <summary>
/// Resets the <see cref="TransportStatistics"/>.
/// </summary>
public void Reset()
{
LastSend = DateTime.MinValue;
LastReceive = DateTime.MinValue;
LastBytesSent = 0;
LastBytesReceived = 0;
TotalBytesSent = 0;
TotalBytesReceived = 0;
}
/// <summary>
/// Updates statistics related to sending of data.
/// </summary>
/// <param name="bytesSent">Number of bytes sent in the send operation.</param>
public void UpdateBytesSent(int bytesSent)
{
LastSend = DateTime.UtcNow;
LastBytesSent = bytesSent;
TotalBytesSent += LastBytesSent;
}
/// <summary>
/// Updates statistics related to receiving of data.
/// </summary>
/// <param name="bytesReceived">Number of bytes received in the receive operation.</param>
public void UpdateBytesReceived(int bytesReceived)
{
LastReceive = DateTime.UtcNow;
LastBytesReceived = bytesReceived;
TotalBytesReceived += LastBytesReceived;
}
#endregion
}
}