stash last lag and ts for each user

master
bel 2023-03-26 22:10:51 -06:00
parent f07e67b3fd
commit e968ce17ce
2 changed files with 14 additions and 4 deletions

View File

@ -22,6 +22,9 @@ type (
configUser struct { configUser struct {
Player int Player int
Message string Message string
Alias string
LastTSMS int64
LastLag int64
} }
configPlayer struct { configPlayer struct {

View File

@ -70,9 +70,16 @@ func (v01 *V01) Read() []button.Button {
} }
func (v01 *V01) telemetry(msg message) { func (v01 *V01) telemetry(msg message) {
if FlagDebug { if v01.cfg.Users == nil {
log.Printf("%s|%dms", msg.U, time.Now().UnixNano()/int64(time.Millisecond)-msg.T) v01.cfg.Users = map[string]configUser{}
} }
u := v01.cfg.Users[msg.U]
u.LastLag = time.Now().UnixNano()/int64(time.Millisecond) - msg.T
u.LastTSMS = msg.T
if FlagDebug {
log.Printf("%s|%dms", msg.U, u.LastLag)
}
v01.cfg.Users[msg.U] = u
} }
func (v01 *V01) transform(msg message) message { func (v01 *V01) transform(msg message) message {