test manager
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user