Documentation ¶
Index ¶
- type Hub
- func (h *Hub) AddClient(channels []string, conn *websocket.Conn)
- func (h *Hub) DiffChannelMap(oldChannelMap map[string]bool, newChannels []string) (removeChannelMap map[string]bool, addChannelMap map[string]bool)
- func (h *Hub) GetChannels() []string
- func (h *Hub) HandlerDynamicChannel(prefix string, checkToken func(token string) bool) func(w http.ResponseWriter, r *http.Request)
- func (h *Hub) HandlerStaticChannels(channels []string) func(w http.ResponseWriter, r *http.Request)
- func (h *Hub) RemoveClient(conn *websocket.Conn)
- func (h *Hub) UpdateSubChannels()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hub ¶
type Hub struct { ClientMap map[*websocket.Conn]map[string]bool SubFunc func(context.Context, ...string) error UnSubFunc func(context.Context, ...string) error // contains filtered or unexported fields }
Hub receive mq data and user websocket to push to browser 支持channel不固定,订阅多个channel
func NewHub ¶
func NewHub(ctx context.Context, subfunc func(context.Context, ...string) error, unsubfunc func(context.Context, ...string) error) *Hub
NewHub ..
func (*Hub) DiffChannelMap ¶
func (h *Hub) DiffChannelMap(oldChannelMap map[string]bool, newChannels []string) (removeChannelMap map[string]bool, addChannelMap map[string]bool)
DiffChannelMap channelMap比较
func (*Hub) HandlerDynamicChannel ¶
func (h *Hub) HandlerDynamicChannel(prefix string, checkToken func(token string) bool) func(w http.ResponseWriter, r *http.Request)
HandlerDynamicChannel 向websocket推送mq数据,可以变更channel
func (*Hub) HandlerStaticChannels ¶
HandlerStaticChannels 向websocket推送mq数据,不可变更channel
Click to show internal directories.
Click to hide internal directories.