sse_hub

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UISuggestReasonLibraryRescan     = "library_rescan_done"
	UISuggestReasonAutoLibraryRescan = "auto_library_rescan_done"
	UISuggestReasonSingleStoreRescan = "single_store_rescan_done"
	UISuggestReasonDebugToggle       = "debug_toggle"
	UISuggestReasonPluginsChanged    = "plugins_changed"
	UISuggestReasonServerConfig      = "server_config_changed"
	UISuggestReasonLoginSettings     = "login_settings_changed"
)

前端 ui_suggest_reload 事件使用的 reason,与 assets/locale 中 i18n key 后缀一致。

Variables

This section is empty.

Functions

func BroadcastUISuggestReload added in v1.2.25

func BroadcastUISuggestReload(reason string)

BroadcastUISuggestReload 通知浏览器根据 reason 刷新整页或提示用户确认(SSE event: ui_suggest_reload)。

func SSEHandler

func SSEHandler(c echo.Context) error

Types

type Event

type Event struct {
	Name string // 可选:自定义事件名(不写则走默认 "message" 事件)
	ID   string // 可选:事件 ID(配合 Last-Event-ID 可断点续传)
	Data string // 必填:消息内容
}

Event SSE消息

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

Hub 广播中心

var MessageHub *Hub

func NewHub

func NewHub() *Hub

NewHub 创建一个新的 Hub 实例

func (*Hub) Add

func (h *Hub) Add(id string, ch chan Event)

Add 注册一个新的客户端

func (*Hub) Broadcast

func (h *Hub) Broadcast(ev Event)

Broadcast 向所有注册的客户端广播事件

func (*Hub) CloseAll

func (h *Hub) CloseAll()

CloseAll 关闭所有客户端连接并清空列表(用于优雅关机)

func (*Hub) Remove

func (h *Hub) Remove(id string)

Remove 注销一个客户端

Jump to

Keyboard shortcuts

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