[🚀] message #15

Merged
bvbej merged 1 commits from dev into main 2024-09-07 16:00:43 +08:00

View File

@ -90,6 +90,10 @@ func (stream *event) HandlerFunc() mux.HandlerFunc {
c.Context().Writer.Header().Set("Connection", "keep-alive") c.Context().Writer.Header().Set("Connection", "keep-alive")
c.Context().Writer.Header().Set("Transfer-Encoding", "chunked") c.Context().Writer.Header().Set("Transfer-Encoding", "chunked")
time.AfterFunc(time.Second, func() {
e <- msgChan{Name: "message", Message: "success"}
})
c.Context().Stream(func(w io.Writer) bool { c.Context().Stream(func(w io.Writer) bool {
if msg, ok := <-e; ok { if msg, ok := <-e; ok {
c.Context().SSEvent(msg.Name, msg.Message) c.Context().SSEvent(msg.Name, msg.Message)