Fix issue with reader disconnecting due to closd channel

This commit is contained in:
2024-06-27 12:21:55 +02:00
parent f368436325
commit cdcdb18c57

View File

@@ -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{}{}