add new webui
Some checks failed
Build Multi-Platform Binaries / build (push) Failing after 4m53s

This commit is contained in:
Flik
2025-12-25 18:26:52 +08:00
parent 16a238f346
commit 790d3b682a
26 changed files with 2986 additions and 5 deletions

View File

@@ -300,3 +300,63 @@ func (s *Server) heartbeatLoop(cs *ClientSession) {
}
}
}
// GetClientStatus 获取客户端状态
func (s *Server) GetClientStatus(clientID string) (online bool, lastPing string) {
s.mu.RLock()
defer s.mu.RUnlock()
if cs, ok := s.clients[clientID]; ok {
cs.mu.Lock()
defer cs.mu.Unlock()
return true, cs.LastPing.Format(time.RFC3339)
}
return false, ""
}
// GetAllClientStatus 获取所有客户端状态
func (s *Server) GetAllClientStatus() map[string]struct {
Online bool
LastPing string
} {
s.mu.RLock()
defer s.mu.RUnlock()
result := make(map[string]struct {
Online bool
LastPing string
})
for id, cs := range s.clients {
cs.mu.Lock()
result[id] = struct {
Online bool
LastPing string
}{
Online: true,
LastPing: cs.LastPing.Format(time.RFC3339),
}
cs.mu.Unlock()
}
return result
}
// ReloadConfig 重新加载配置
func (s *Server) ReloadConfig() error {
// 目前仅返回nil后续可实现热重载
return nil
}
// SetConfig 设置配置
func (s *Server) SetConfig(cfg *config.ServerConfig) {
s.mu.Lock()
defer s.mu.Unlock()
s.config = cfg
}
// GetConfig 获取配置
func (s *Server) GetConfig() *config.ServerConfig {
s.mu.RLock()
defer s.mu.RUnlock()
return s.config
}