diff --git a/client/client.go b/client/client.go index 230cd14..961ecc2 100644 --- a/client/client.go +++ b/client/client.go @@ -233,7 +233,6 @@ func (c *Client) writeLoop(conn clientConn, incoming <-chan Message) { defer timer.Stop() for { - now := time.Now() if currentCommand == nil { select { case msg := <-c.txAudio: @@ -243,9 +242,11 @@ func (c *Client) writeLoop(conn clientConn, incoming <-chan Message) { continue } case cmd := <-c.commands: + now := time.Now() if cmd.reply != nil { currentCommand = &cmd currentDeadline = now.Add(c.timeout) + log.Printf("cmd %v now %v deadline %v", cmd, now, currentDeadline) } err := conn.WriteMessage(websocket.TextMessage, []byte(cmd.String())) if err != nil { @@ -256,7 +257,9 @@ func (c *Client) writeLoop(conn clientConn, incoming <-chan Message) { continue } } else { + now := time.Now() timer.Reset(currentDeadline.Sub(now)) + log.Printf("cmd %v now %v deadline %v", *currentCommand, now, currentDeadline) select { case <-c.disconnectChan: return