Documentation
¶
Index ¶
- type BroadcastMessage
- type Client
- type Message
- type MessageType
- type SubscriptionManager
- func (sm *SubscriptionManager) NotifyConfigUpdate(userIDs []uint, configType string)
- func (sm *SubscriptionManager) NotifyNodeUpdate(nodeID uint, changeType string)
- func (sm *SubscriptionManager) NotifySubscriptionUpdate(changeType string, groupID *uint)
- func (sm *SubscriptionManager) NotifyUserUpdate(userIDs []uint, changeType string)
- func (sm *SubscriptionManager) Run()
- type WebSocketHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BroadcastMessage ¶
type BroadcastMessage struct {
UserIDs []uint // 目标用户ID,nil 表示广播给所有
Message *Message // 消息内容
Exclude uint // 排除的用户ID
}
BroadcastMessage 广播消息
type Message ¶
type Message struct {
Type MessageType `json:"type"`
Timestamp int64 `json:"timestamp"`
Data map[string]any `json:"data,omitempty"`
Error string `json:"error,omitempty"`
}
Message WebSocket 消息
type MessageType ¶
type MessageType string
MessageType 消息类型
const ( MessageTypeSubscribe MessageType = "subscribe" MessageTypeUnsubscribe MessageType = "unsubscribe" MessageTypeNodeUpdate MessageType = "node_update" MessageTypeUserUpdate MessageType = "user_update" MessageTypeConfigUpdate MessageType = "config_update" MessageTypeSubscriptionUpdate MessageType = "subscription_update" MessageTypeHeartbeat MessageType = "heartbeat" MessageTypeError MessageType = "error" )
type SubscriptionManager ¶
type SubscriptionManager struct {
// contains filtered or unexported fields
}
SubscriptionManager 订阅管理器
func NewSubscriptionManager ¶
func NewSubscriptionManager() *SubscriptionManager
NewSubscriptionManager 创建订阅管理器
func (*SubscriptionManager) NotifyConfigUpdate ¶
func (sm *SubscriptionManager) NotifyConfigUpdate(userIDs []uint, configType string)
NotifyConfigUpdate 通知配置更新
func (*SubscriptionManager) NotifyNodeUpdate ¶
func (sm *SubscriptionManager) NotifyNodeUpdate(nodeID uint, changeType string)
NotifyNodeUpdate 通知节点更新
func (*SubscriptionManager) NotifySubscriptionUpdate ¶
func (sm *SubscriptionManager) NotifySubscriptionUpdate(changeType string, groupID *uint)
NotifySubscriptionUpdate 通知订阅更新
func (*SubscriptionManager) NotifyUserUpdate ¶
func (sm *SubscriptionManager) NotifyUserUpdate(userIDs []uint, changeType string)
NotifyUserUpdate 通知用户更新
type WebSocketHandler ¶
type WebSocketHandler struct {
// contains filtered or unexported fields
}
WebSocketHandler WebSocket 处理器
func NewWebSocketHandler ¶
func NewWebSocketHandler(sm *SubscriptionManager, jwtSecret string) *WebSocketHandler
NewWebSocketHandler 创建 WebSocket 处理器
func (*WebSocketHandler) GetSubscriptionManager ¶
func (h *WebSocketHandler) GetSubscriptionManager() *SubscriptionManager
GetSubscriptionManager 获取订阅管理器
func (*WebSocketHandler) HandleWebSocket ¶
func (h *WebSocketHandler) HandleWebSocket(w http.ResponseWriter, r *http.Request)
HandleWebSocket 处理 WebSocket 连接
Click to show internal directories.
Click to hide internal directories.