alielie
2025-11-25 006c98e5650b530e5220f279c1e803fefe69d40d
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
using ScottPlot.Colormaps;
using SuperSocket.SocketBase;
using SuperSocket.SocketBase.Protocol;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
 
namespace Plugin.TestResult_WPF.Model
{
    public class DTReceiveFilter : ReceiveFilterBase<StringRequestInfo>
    {
        public override StringRequestInfo Filter(byte[] readBuffer, int offset, int length, bool toBeCopied, out int rest)
        {
            rest = 0;
            StringBuilder sb = new StringBuilder();
            int i = offset;
            List<byte> bytes = new List<byte>();
            while (i < readBuffer.Length)
            {
                byte b = readBuffer[i++];
                if (b == '\n')
                {
                    break;
                }
                sb.Append((char)b);
                bytes.Add(b);
            }
            byte[] arr = bytes.ToArray();
            return new StringRequestInfo(DateTime.Now + "", Encoding.UTF8.GetString(arr), null);//sb.ToString()
        }
    }
 
    public class TcpServer : AppServer<TcpSession>
    {
        public TcpServer() : base(new DefaultReceiveFilterFactory<DTReceiveFilter, StringRequestInfo>())
        {
 
        }
    }
 
    public class TcpSession : AppSession<TcpSession, StringRequestInfo>
    {
 
    }
}