feat: #57 增加connectedClients、latestReport线程安全

This commit is contained in:
Akizon77
2025-06-20 21:39:50 +08:00
parent d669d2862e
commit b85d1d1a48
5 changed files with 58 additions and 15 deletions

View File

@@ -25,7 +25,7 @@ func Exec(c *gin.Context) {
api.RespondError(c, 400, "Invalid or missing request body: "+err.Error())
return
}
for uuid := range ws.ConnectedClients {
for uuid := range ws.GetConnectedClients() {
if contain(req.Clients, uuid) {
onlineClients = append(onlineClients, uuid)
} else {
@@ -53,7 +53,7 @@ func Exec(c *gin.Context) {
send.TaskId = taskId
payload, _ := json.Marshal(send)
client := ws.ConnectedClients[uuid]
client := ws.GetConnectedClients()[uuid]
if client != nil {
client.WriteMessage(websocket.TextMessage, payload)
} else {