IReceiveFilter.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using SuperSocket.SocketBase.Command;
  6. namespace SuperSocket.SocketBase.Protocol
  7. {
  8. /// <summary>
  9. /// Receive filter interface
  10. /// </summary>
  11. /// <typeparam name="TRequestInfo">The type of the request info.</typeparam>
  12. public interface IReceiveFilter<TRequestInfo>
  13. where TRequestInfo : IRequestInfo
  14. {
  15. /// <summary>
  16. /// Filters received data of the specific session into request info.
  17. /// </summary>
  18. /// <param name="readBuffer">The read buffer.</param>
  19. /// <param name="offset">The offset of the current received data in this read buffer.</param>
  20. /// <param name="length">The length of the current received data.</param>
  21. /// <param name="toBeCopied">if set to <c>true</c> [to be copied].</param>
  22. /// <param name="rest">The rest, the length of the data which hasn't been parsed.</param>
  23. /// <returns></returns>
  24. TRequestInfo Filter(byte[] readBuffer, int offset, int length, bool toBeCopied, out int rest);
  25. /// <summary>
  26. /// Gets the size of the rest buffer.
  27. /// </summary>
  28. /// <value>
  29. /// The size of the rest buffer.
  30. /// </value>
  31. int LeftBufferSize { get; }
  32. /// <summary>
  33. /// Gets the next Receive filter.
  34. /// </summary>
  35. IReceiveFilter<TRequestInfo> NextReceiveFilter { get; }
  36. /// <summary>
  37. /// Resets this instance to initial state.
  38. /// </summary>
  39. void Reset();
  40. /// <summary>
  41. /// Gets the filter state.
  42. /// </summary>
  43. /// <value>
  44. /// The filter state.
  45. /// </value>
  46. FilterState State { get; }
  47. }
  48. }