jiazx0107
2025-09-01 ce4f9b9f72a4269a1f25812dadd59bfb92c7b3cf
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
package com.ld.io.api;
 
public class IoServerOption {
    private int port = 50051;
    private int splitDecoderType = SplitByteDecoderType.DELIMITER_SYMBOL;// 拆包解码器
    private byte[] delimiter;// 拆包结束分隔符,splitDecoderType为DELIMITER_SYMBOL时有效
    private int fixedLength = 1024;// 定长拆包长度,splitDecoderType为FIXED_LENGTH时有效
    private int lengthFieldLength = 8;// 变长拆分中指定包长度的字节数,splitDecoderType为LENGTH_FIELD时有效
    private int maxFrameSize = 1024 * 1024 * 2;// 单次接收最大字节数
    private int readerIdleTime = 60;// 最大读取空闲秒数,超出该时长认为客户端掉线
    private int connectTimeoutMillis = 60 * 1000;// 链接超时毫秒数
 
 
    public IoServerOption() {
    }
 
    public IoServerOption(int port) {
        this.port = port;
    }
 
    public IoServerOption(int port, int splitDecoderType, byte[] delimiter,
            int maxFrameSize, int readerIdleTime, int connectTimeoutMillis) {
        this.port = port;
        this.splitDecoderType = splitDecoderType;
        this.delimiter = delimiter;
        this.maxFrameSize = maxFrameSize;
        this.readerIdleTime = readerIdleTime;
        this.connectTimeoutMillis = connectTimeoutMillis;
    }
 
    public int getPort() {
        return port;
    }
 
    public IoServerOption setPort(int port) {
        this.port = port;
        return this;
    }
 
    public int getSplitDecoderType() {
        return splitDecoderType;
    }
 
    public IoServerOption setSplitDecoderType(int splitDecoderType) {
        this.splitDecoderType = splitDecoderType;
        return this;
    }
 
    public byte[] getDelimiter() {
        return delimiter;
    }
 
    public void setDelimiter(byte[] delimiter) {
        this.delimiter = delimiter;
    }
 
    public int getFixedLength() {
        return fixedLength;
    }
 
    public IoServerOption setFixedLength(int fixedLength) {
        this.fixedLength = fixedLength;
        return this;
    }
 
    public int getLengthFieldLength() {
        return lengthFieldLength;
    }
 
    public IoServerOption setLengthFieldLength(int lengthFieldLength) {
        this.lengthFieldLength = lengthFieldLength;
        return this;
    }
 
    public int getMaxFrameSize() {
        return maxFrameSize;
    }
 
    public IoServerOption setMaxFrameSize(int maxFrameSize) {
        this.maxFrameSize = maxFrameSize;
        return this;
    }
 
    public int getReaderIdleTime() {
        return readerIdleTime;
    }
 
    public IoServerOption setReaderIdleTime(int readerIdleTime) {
        this.readerIdleTime = readerIdleTime;
        return this;
    }
 
    public int getConnectTimeoutMillis() {
        return connectTimeoutMillis;
    }
 
    public IoServerOption setConnectTimeoutMillis(int connectTimeoutMillis) {
        this.connectTimeoutMillis = connectTimeoutMillis;
        return this;
    }
}