using WIDESEAWCS_Core.Core;
namespace WIDESEAWCS_Tasks.SocketServer
{
///
/// Socket 服务器配置选项
///
///
/// 用于配置 TCP Socket 服务器的运行参数。
/// 配置通过 appsettings.json 的 SocketServer 节点加载。
///
public class SocketServerOptions : IConfigurableOptions
{
///
/// 是否启用 Socket 服务器
///
///
/// 设置为 false 时,服务器不会启动。
///
public bool Enabled { get; set; } = true;
///
/// 服务器监听端口
///
///
/// TCP 客户端连接到此端口。
/// 默认为 2000。
///
public int Port { get; set; } = 2000;
///
/// 监听地址
///
///
/// 服务器绑定到此地址。
/// 0.0.0.0 表示监听所有网络接口。
///
public string IpAddress { get; set; } = "0.0.0.0";
///
/// 连接队列长度
///
///
/// 等待接受的连接队列最大长度。
///
public int Backlog { get; set; } = 1000;
///
/// 字符编码名称
///
///
/// 用于消息的字符编码,如 utf-8、gbk。
///
public string EncodingName { get; set; } = "utf-8";
///
/// 是否自动检测编码(针对 GBK 客户端)
///
///
/// 当设置为 true 时,会自动检测客户端消息的编码。
/// 如果消息是 UTF-8 格式则用 UTF-8 解码,否则尝试 GBK 解码。
///
public bool AutoDetectEncoding { get; set; } = true;
///
/// 客户端空闲超时时间(秒)
///
///
/// 如果客户端在此时间内没有活动,断开连接。
/// 设置为 0 表示不启用超时。
///
public int IdleTimeoutSeconds { get; set; } = 300;
///
/// 是否启用心跳检测
///
///
/// 启用后,会在连接空闲时发送心跳探测。
///
public bool EnableHeartbeat { get; set; } = true;
///
/// 日志文件路径
///
///
/// 日志文件的相对路径,相对于应用程序目录。
///
public string LogFilePath { get; set; } = "socketserver.log";
///
/// 消息头标识
///
///
/// 用于帧解析的消息头。
/// 接收消息时查找此头标识。
///
public string MessageHeader { get; set; } = "";
///
/// 消息尾标识
///
///
/// 用于帧解析的消息尾。
/// 接收消息时查找此尾标识。
///
public string MessageFooter { get; set; } = "";
}
}