sse

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BroadcastMessage

func BroadcastMessage(channel, message string)

func GetChannelConnections

func GetChannelConnections(channel string) int

func GetSseMsgStr

func GetSseMsgStr(event string, data interface{}) string

func HandleSSE

func HandleSSE(r *ghttp.Request)

func HasChannelConnections

func HasChannelConnections(channel string) bool

func RegisterChannelHandler

func RegisterChannelHandler(channel string, handler ChannelHandler)

func StartAutoSend

func StartAutoSend(channel string, interval time.Duration, fn func())

func StopAutoSend

func StopAutoSend(channel string)

Types

type ChannelHandler

type ChannelHandler interface {
	OnConnect(channel string)
	OnDisconnect(channel string)
}

type SSEMessage

type SSEMessage struct {
	Event     string      `json:"event"`
	Data      interface{} `json:"data"`
	ID        string      `json:"id"`
	Retry     int         `json:"retry"`
	Timestamp int64       `json:"timestamp"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL