This commit is contained in:
心隨緣動 2025-09-10 16:41:06 +08:00 committed by GitHub
parent fabe1fa245
commit 74411707e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,6 +9,7 @@ import (
"os"
"os/exec"
"runtime"
"sync"
"syscall"
"time"
@ -102,6 +103,7 @@ type process struct {
apiPort int
onlineClients []string
mutex sync.RWMutex
config *Config
logWriter *LogWriter
@ -152,11 +154,17 @@ func (p *Process) GetConfig() *Config {
}
func (p *Process) GetOnlineClients() []string {
return p.onlineClients
p.mutex.RLock()
defer p.mutex.RUnlock()
clientsCopy := make([]string, len(p.onlineClients))
copy(clientsCopy, p.onlineClients)
return clientsCopy
}
func (p *Process) SetOnlineClients(users []string) {
p.onlineClients = users
func (p *Process) SetOnlineClients(clients []string) {
p.mutex.Lock()
defer p.mutex.Unlock()
p.onlineClients = clients
}
func (p *Process) GetUptime() uint64 {