5
5
6
6
namespace SuperSocket . ProtoBase
7
7
{
8
+ /// <summary>
9
+ /// The receive filter which is designed for the protocol with begin and end mark within each message
10
+ /// </summary>
11
+ /// <typeparam name="TPackageInfo">The type of the package info.</typeparam>
8
12
public abstract class BeginEndMarkReceiveFilter < TPackageInfo > : IReceiveFilter < TPackageInfo > , IPackageResolver < TPackageInfo >
9
13
where TPackageInfo : IPackageInfo
10
14
{
11
15
private readonly SearchMarkState < byte > m_BeginSearchState ;
12
16
private readonly SearchMarkState < byte > m_EndSearchState ;
13
17
private bool m_FoundBegin = false ;
14
18
19
+ /// <summary>
20
+ /// Initializes a new instance of the <see cref="BeginEndMarkReceiveFilter{TPackageInfo}"/> class.
21
+ /// </summary>
22
+ /// <param name="beginMark">The begin mark.</param>
23
+ /// <param name="endMark">The end mark.</param>
15
24
public BeginEndMarkReceiveFilter ( byte [ ] beginMark , byte [ ] endMark )
16
25
{
17
26
m_BeginSearchState = new SearchMarkState < byte > ( beginMark ) ;
@@ -32,6 +41,10 @@ private bool CheckChanged(byte[] oldMark, byte[] newMark)
32
41
return false ;
33
42
}
34
43
44
+ /// <summary>
45
+ /// Changes the begin mark.
46
+ /// </summary>
47
+ /// <param name="beginMark">The begin mark.</param>
35
48
public void ChangeBeginMark ( byte [ ] beginMark )
36
49
{
37
50
if ( ! CheckChanged ( m_BeginSearchState . Mark , beginMark ) )
@@ -40,6 +53,10 @@ public void ChangeBeginMark(byte[] beginMark)
40
53
m_BeginSearchState . Change ( beginMark ) ;
41
54
}
42
55
56
+ /// <summary>
57
+ /// Changes the end mark.
58
+ /// </summary>
59
+ /// <param name="endMark">The end mark.</param>
43
60
public void ChangeEndMark ( byte [ ] endMark )
44
61
{
45
62
if ( ! CheckChanged ( m_EndSearchState . Mark , endMark ) )
@@ -48,8 +65,19 @@ public void ChangeEndMark(byte[] endMark)
48
65
m_EndSearchState . Change ( endMark ) ;
49
66
}
50
67
68
+ /// <summary>
69
+ /// Resolves the package binary data to package instance
70
+ /// </summary>
71
+ /// <param name="packageData">The package binary data.</param>
72
+ /// <returns></returns>
51
73
public abstract TPackageInfo ResolvePackage ( IList < ArraySegment < byte > > packageData ) ;
52
74
75
+ /// <summary>
76
+ /// Filters the received data.
77
+ /// </summary>
78
+ /// <param name="data">The received data.</param>
79
+ /// <param name="rest">The length of the rest data after filtering.</param>
80
+ /// <returns>the received packageInfo instance</returns>
53
81
public virtual TPackageInfo Filter ( ReceiveCache data , out int rest )
54
82
{
55
83
rest = 0 ;
@@ -139,10 +167,25 @@ public virtual TPackageInfo Filter(ReceiveCache data, out int rest)
139
167
}
140
168
}
141
169
170
+ /// <summary>
171
+ /// Gets or sets the next receive filter. The next receive filter will be used when the next network data is received.
172
+ /// </summary>
173
+ /// <value>
174
+ /// The next receive filter.
175
+ /// </value>
142
176
public IReceiveFilter < TPackageInfo > NextReceiveFilter { get ; protected set ; }
143
177
178
+ /// <summary>
179
+ /// Gets or sets the filter state.
180
+ /// </summary>
181
+ /// <value>
182
+ /// The state.
183
+ /// </value>
144
184
public FilterState State { get ; protected set ; }
145
185
186
+ /// <summary>
187
+ /// Resets this receive filter.
188
+ /// </summary>
146
189
public void Reset ( )
147
190
{
148
191
m_BeginSearchState . Matched = 0 ;
0 commit comments