struct
parent
45b873f462
commit
1842023224
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue