=sse update event

This commit is contained in:
Miki 2024-01-07 11:54:29 +00:00
parent 2464596698
commit 066b72385e
12 changed files with 56 additions and 36 deletions

View file

@ -5,6 +5,7 @@ import (
"fmt"
"io"
"log"
"net/http"
"slices"
"strconv"
"strings"
@ -136,6 +137,9 @@ func (e *Event) SendMessage(c *gin.Context) {
Event: "message",
Data: "Ciao",
})
e.Send(Message{
Data: "Senza event",
})
}
func (e *Event) SendMsg(c *gin.Context) {
@ -143,6 +147,7 @@ func (e *Event) SendMsg(c *gin.Context) {
Event: "msg",
Data: "hello",
})
c.JSON(http.StatusOK, gin.H{"status": "msg"})
}
func (e *Event) SendPing(c *gin.Context) {
@ -150,7 +155,7 @@ func (e *Event) SendPing(c *gin.Context) {
Event: "ping",
Data: "Ping",
})
c.JSON(http.StatusOK, gin.H{"status": "ping"})
}
func (e *Event) SendPong(c *gin.Context) {
@ -158,6 +163,7 @@ func (e *Event) SendPong(c *gin.Context) {
Event: "pong",
Data: "Pong",
})
c.JSON(http.StatusOK, gin.H{"status": "pong"})
}
func remove(slice []Client, s *Client) []Client {