master
Bel LaPointe 2023-03-27 06:53:46 -06:00
parent 45b873f462
commit 1842023224
1 changed files with 9 additions and 10 deletions

View File

@ -179,18 +179,17 @@ func (v01 *V01) serveGM(w http.ResponseWriter, r *http.Request) {
} }
func (v01 *V01) serveGMStatus(w http.ResponseWriter, r *http.Request) { func (v01 *V01) serveGMStatus(w http.ResponseWriter, r *http.Request) {
log.Printf("status with %+v", v01.cfg) users := map[string]struct {
users := map[string]interface{}{} Lag time.Duration `yaml:"lag,omitempty"`
Player int `yaml:"player,omitempty"`
IdleFor time.Duration `yaml:"last_activity,omitempty"`
}{}
for k, v := range v01.cfg.Users { for k, v := range v01.cfg.Users {
v2 := map[string]interface{}{} v2 := users[k]
if v.LastLag > 0 { v2.Lag = time.Duration(v.LastLag) / time.Millisecond
v2["Lag"] = time.Duration(v.LastLag) / time.Millisecond v2.Player = v.Player
}
if v.Player > 0 {
v2["Player"] = v.Player
}
if v.LastTSMS > 0 { if v.LastTSMS > 0 {
v2["Last Activity"] = time.Since(time.Unix(0, v.LastTSMS/int64(time.Millisecond))) v2.IdleFor = time.Since(time.Unix(0, v.LastTSMS/int64(time.Millisecond)))
} }
users[k] = v2 users[k] = v2
} }