diff --git a/downloader/main.go b/downloader/main.go index f9211b2..3e86bd0 100644 --- a/downloader/main.go +++ b/downloader/main.go @@ -63,12 +63,20 @@ func main() { // listener.initialize() var ws WSConnection + read := make(chan string) go func() { for { - ws := WSConnection{ + ws = WSConnection{ url: WEBSOCKET_SERVER, } ws.Open() + for { + msg, ok := <-ws.ReadChan + if !ok { + break + } + read <- msg + } <-ws.Dead log.Printf("Reconnecting in 5 seconds...") time.Sleep(5 * time.Second) @@ -78,7 +86,7 @@ func main() { sem := make(chan struct{}, 4) for { select { - case event := <-ws.ReadChan: + case event := <-read: eventCopy := event status := make(chan error) sem <- struct{}{}