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; } }