fix: remove unused variable prevMessage
- update logic to send current serverMessage instead of prevMessage
- simplify message processing for improved clarity
🤖
This commit is contained in:
parent
74ee5f3693
commit
46c3a4c0b1
1 changed files with 2 additions and 3 deletions
|
@ -14,7 +14,7 @@ var Done = make(chan struct{})
|
||||||
// Receives websocket messages and writes them to a channel.
|
// Receives websocket messages and writes them to a channel.
|
||||||
// Closes the channel if websocket closes.
|
// Closes the channel if websocket closes.
|
||||||
func (c *Client) ProcessServerMessages(channel chan<- GoTomato.ServerMessage) {
|
func (c *Client) ProcessServerMessages(channel chan<- GoTomato.ServerMessage) {
|
||||||
var serverMessage, prevMessage GoTomato.ServerMessage
|
var serverMessage GoTomato.ServerMessage
|
||||||
|
|
||||||
defer close(Done)
|
defer close(Done)
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ func (c *Client) ProcessServerMessages(channel chan<- GoTomato.ServerMessage) {
|
||||||
c.LastErr = err
|
c.LastErr = err
|
||||||
// Try to reconnect on unexpected disconnect
|
// Try to reconnect on unexpected disconnect
|
||||||
for {
|
for {
|
||||||
channel <- prevMessage // send previous ServerMessage to update view
|
channel <- serverMessage // send last known ServerMessage to update view
|
||||||
|
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
|
|
||||||
|
@ -50,6 +50,5 @@ func (c *Client) ProcessServerMessages(channel chan<- GoTomato.ServerMessage) {
|
||||||
c.LastErr = err
|
c.LastErr = err
|
||||||
|
|
||||||
channel <- serverMessage
|
channel <- serverMessage
|
||||||
prevMessage = serverMessage
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue