fix: client requests

This commit is contained in:
0x1a8510f2 2023-01-21 13:55:34 +00:00
parent 55e1f59456
commit d5a5c3d6b1
Signed by: 0x1a8510f2
GPG Key ID: 1C692E355D76775D
2 changed files with 8 additions and 5 deletions

View File

@ -18,8 +18,8 @@ func MkState() *state {
}
type client struct {
lastHeartbeatTime time.Time
lastHeartbeat proto.PacketHeartbeat
LastHeartbeatTime time.Time `json:"lastHeartbeatTime"`
LastHeartbeat proto.PacketHeartbeat `json:"lastHeartbeat"`
}
type request struct {
@ -48,8 +48,8 @@ func (s *state) Heartbeat(src string, hb proto.PacketHeartbeat) {
defer s.clientsMutex.Unlock()
s.clients[src] = client{
lastHeartbeatTime: time.Now(),
lastHeartbeat: hb,
LastHeartbeatTime: time.Now(),
LastHeartbeat: hb,
}
}
@ -94,7 +94,7 @@ func (s *state) Prune() {
defer s.clientsMutex.Unlock()
for id, c := range s.clients {
if time.Since(c.lastHeartbeatTime) > proto.HEARTBEAT_MARK_DEAD_DELAY {
if time.Since(c.LastHeartbeatTime) > proto.HEARTBEAT_MARK_DEAD_DELAY {
delete(s.clients, id)
}
}

View File

@ -135,6 +135,9 @@ export default class API {
return false
}
// Prevents an error log to console.
await res.blob()
return true
}