test manager

This commit is contained in:
张超
2025-05-22 13:56:57 +08:00
parent 405305415f
commit f5d570eb2d
5 changed files with 212 additions and 102 deletions

View File

@@ -7,6 +7,7 @@ import (
"go_blog/serializers"
"log"
"net/http"
"time"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
@@ -91,6 +92,13 @@ func esSSE(c *gin.Context) {
log.Panic("server not support") //浏览器不兼容
}
for {
// Simulate sending events every second
fmt.Fprintf(w, "data: %s\n\n", time.Now().Format(time.Stamp))
w.(http.Flusher).Flush()
time.Sleep(1 * time.Second)
}
_, err := fmt.Fprintf(w, "id: aaa\ndata: %s\n\n", "dsdf")
_, er1r := fmt.Fprintf(w, "event: connecttime\ndata: %s\n\n", "connecttime")
if err != nil || er1r != nil {