Fix issue with reader disconnecting due to closd channel
This commit is contained in:
@@ -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{}{}
|
||||
|
Reference in New Issue
Block a user