modified main.go add sse

This commit is contained in:
张超
2024-11-07 17:44:14 +08:00
parent 549649866d
commit f9b330e5a9

View File

@@ -64,8 +64,10 @@ func esSSE(c *gin.Context) {
log.Panic("server not support") //浏览器不兼容 log.Panic("server not support") //浏览器不兼容
} }
_, err := fmt.Fprintf(w, "data: %s\n\n", "dsdf") _, err := fmt.Fprintf(w, "id: aaa\ndata: %s\n\n", "dsdf")
if err != nil { _, er1r := fmt.Fprintf(w, "event: connecttime\ndata: %s\n\n", "connecttime")
if err != nil || er1r != nil {
print("error", err)
return return
} }
} }