ClientState.cs 930 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.Net.Sockets;
  3. namespace SWRIS.Models
  4. {
  5. public class ClientState
  6. {
  7. public string SerialNo { get; set; }
  8. public string IpAddress { get; }
  9. public Socket ClientSocket { get; set; }
  10. public byte[] Buffer { get; set; }
  11. public ByteCircularBuffer ReceiveBuffer { get; set; } = new ByteCircularBuffer(32768); // 添加环形缓冲区
  12. public DateTime LastActiveTime { get; set; } = DateTime.UtcNow;
  13. public ClientState(Socket clientSocket, string ipAddress, string serialNo)
  14. {
  15. ClientSocket = clientSocket;
  16. IpAddress = ipAddress;
  17. SerialNo = serialNo;
  18. Buffer = new byte[8192];
  19. }
  20. public ClientState(Socket clientSocket, string ipAddress)
  21. {
  22. ClientSocket = clientSocket;
  23. IpAddress = ipAddress;
  24. Buffer = new byte[8192];
  25. }
  26. }
  27. }