mirror of
https://github.com/trafficlunar/api.git
synced 2026-06-27 22:24:08 +00:00
feat: add getting computer data route
This commit is contained in:
parent
840e584082
commit
58adca9cd0
4 changed files with 34 additions and 0 deletions
18
internal/service/computer.go
Normal file
18
internal/service/computer.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"backend/internal/model"
|
||||
)
|
||||
|
||||
var ComputerData model.ComputerGraphData
|
||||
|
||||
func AddComputerData(online bool, clientMessage model.ComputerWebSocketMessage) {
|
||||
ComputerData.Online = online
|
||||
ComputerData.Cpu = append(ComputerData.Cpu, int(clientMessage.Cpu))
|
||||
ComputerData.Ram = append(ComputerData.Ram, int(clientMessage.Ram))
|
||||
|
||||
if len(ComputerData.Cpu) > 20 {
|
||||
ComputerData.Cpu = ComputerData.Cpu[1:]
|
||||
ComputerData.Ram = ComputerData.Ram[1:]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue