Documentation
¶
Index ¶
- func BroadcastNotification(notice *models.Notice)
- func GenerateClientID() string
- func GetOnlineInfo() gin.H
- func HandleWebSocket(ctx *gin.Context)
- func RegisterEventHandler(event EventType, handler EventHandler)
- func SendKickToUser(userID string, reason string)
- func SendNotificationToUser(userID string, notice *models.Notice) bool
- type Client
- type EventHandler
- type EventType
- type Hub
- func (h *Hub) Broadcast(msg *WResponse)
- func (h *Hub) GetOnlineCount() int
- func (h *Hub) GetOnlineUserCount() int
- func (h *Hub) IsUserOnline(userID string) bool
- func (h *Hub) Register(client *Client)
- func (h *Hub) Run()
- func (h *Hub) SendToUser(userID string, msg *WResponse)
- func (h *Hub) SendToUserDirect(userID string, msg *WResponse) int
- func (h *Hub) SetOnMessage(fn func(*Client, *WRequest))
- func (h *Hub) Stop()
- func (h *Hub) Unregister(client *Client)
- type WRequest
- type WResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BroadcastNotification ¶
func GenerateClientID ¶
func GenerateClientID() string
func GetOnlineInfo ¶
func HandleWebSocket ¶
func RegisterEventHandler ¶
func RegisterEventHandler(event EventType, handler EventHandler)
func SendKickToUser ¶
Types ¶
type Client ¶
type Client struct {
ID string
UserID string
Conn *websocket.Conn
Send chan *WResponse
HeartbeatTime time.Time
IP string
UserAgent string
// contains filtered or unexported fields
}
type EventHandler ¶
type EventHandler func(*Client, json.RawMessage)
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
func (*Hub) GetOnlineCount ¶
func (*Hub) GetOnlineUserCount ¶
func (*Hub) IsUserOnline ¶
func (*Hub) SendToUser ¶
func (*Hub) SetOnMessage ¶
func (*Hub) Unregister ¶
Click to show internal directories.
Click to hide internal directories.