fix
This commit is contained in:
parent
0dd4a4c696
commit
6c8ead6604
5
main.go
5
main.go
@ -107,7 +107,7 @@ func main() {
|
|||||||
c.Set("Cache-Control", "no-cache")
|
c.Set("Cache-Control", "no-cache")
|
||||||
c.Set("Connection", "keep-alive")
|
c.Set("Connection", "keep-alive")
|
||||||
|
|
||||||
events := make(chan SSE)
|
events := make(chan SSE, 100)
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
clients[events] = true
|
clients[events] = true
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
@ -126,7 +126,8 @@ func main() {
|
|||||||
c.Context().SetBodyStreamWriter(func(w *bufio.Writer) {
|
c.Context().SetBodyStreamWriter(func(w *bufio.Writer) {
|
||||||
for event := range events {
|
for event := range events {
|
||||||
if _, err := fmt.Fprintf(w, "event: %s\ndata: %s\n\n", event.Event, event.Data); err != nil {
|
if _, err := fmt.Fprintf(w, "event: %s\ndata: %s\n\n", event.Event, event.Data); err != nil {
|
||||||
panic(err)
|
fmt.Println(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
w.Flush()
|
w.Flush()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user