This commit is contained in:
shoopea 2020-01-14 14:47:23 +08:00
parent 715026fd17
commit 708ff883ef

View File

@ -60,6 +60,7 @@ func setClientBusy(userID64 int64, from time.Time, duration time.Duration) error
clt.CWIdle = false
clt.CWBusyUntil = from.UTC().Add(duration)
clt.Mux.Unlock()
log.Printf("setClientBusy[%s] : set for %s.\n", clt.Login, duration.String())
return nil
} else {
return errors.New("Client not found.")
@ -69,15 +70,15 @@ func setClientBusy(userID64 int64, from time.Time, duration time.Duration) error
}
func setClientIdle(userID64 int64, from time.Time) error {
fmt.Printf("setClientIdle : starting for %d.\n", userID64)
if clt, ok := getLockedClient(userID64, false); ok {
if from.UTC().After(clt.CWLastUpdate.UTC()) {
fmt.Printf("setClientIdle : updated.\n")
clt.CWBusyUntil = from
clt.CWIdle = true
clt.CWLastUpdate = from
log.Printf("setClientIdle[%s] : updated.\n", clt.Login)
} else {
fmt.Printf("setClientIdle : not updated.\n")
log.Printf("setClientIdle[%s] : not updated.\n", clt.Login)
}
clt.Mux.Unlock()
return nil