diff --git a/internal/websocket/receive.go b/internal/websocket/receive.go index 7912de3..510ad34 100644 --- a/internal/websocket/receive.go +++ b/internal/websocket/receive.go @@ -14,7 +14,7 @@ var Done = make(chan struct{}) // Receives websocket messages and writes them to a channel. // Closes the channel if websocket closes. func (c *Client) ProcessServerMessages(channel chan<- GoTomato.ServerMessage) { - var serverMessage, prevMessage GoTomato.ServerMessage + var serverMessage GoTomato.ServerMessage defer close(Done) @@ -30,7 +30,7 @@ func (c *Client) ProcessServerMessages(channel chan<- GoTomato.ServerMessage) { c.LastErr = err // Try to reconnect on unexpected disconnect for { - channel <- prevMessage // send previous ServerMessage to update view + channel <- serverMessage // send last known ServerMessage to update view time.Sleep(time.Second) @@ -50,6 +50,5 @@ func (c *Client) ProcessServerMessages(channel chan<- GoTomato.ServerMessage) { c.LastErr = err channel <- serverMessage - prevMessage = serverMessage } }