diff --git a/config.yml b/config.yml index ad8f8ab..dd313bf 100644 --- a/config.yml +++ b/config.yml @@ -26,6 +26,8 @@ database: websocket: # WebSocket请求超时时间(秒) timeout: 5 + # 心跳检测间隔(秒), 如果超过这个时间没有消息往来系统会自动发送一个心跳包维持长链接 + heartbeat_interval: 54 # 心跳配置 heartbeat: diff --git a/internal/config/config.go b/internal/config/config.go index ca8e74a..0444a90 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -77,6 +77,9 @@ type DatabaseConfig struct { type WebSocketConfig struct { // Timeout WebSocket请求超时时间(秒) Timeout int `yaml:"timeout"` + + // HeartbeatInterval 心跳检测间隔(秒), 如果超过这个时间没有消息往来系统会自动发送一个心跳包维持长链接 + HeartbeatInterval int `yaml:"heartbeat_interval"` } // HeartbeatConfig 代表心跳配置 @@ -130,12 +133,9 @@ func (c *Config) GetDatabaseConnectionString() string { ) } -// GetWebSocketTimeout 获取WebSocket超时时间(秒) -func (c *Config) GetWebSocketTimeout() int { - if c.WebSocket.Timeout <= 0 { - return 5 // 默认5秒超时 - } - return c.WebSocket.Timeout +// GetWebSocketConfig 获取WebSocket配置 +func (c *Config) GetWebSocketConfig() WebSocketConfig { + return c.WebSocket } // GetHeartbeatConfig 获取心跳配置