wspush

package module
v0.0.0-...-5d08768 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: BSD-3-Clause Imports: 5 Imported by: 0

README

wspush

websocket数据订阅,服务器从redis,rabbitmq等其中一种数据源订阅数据并推送到客户端

Documentation

Index

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(patterns ...string) error
	UnSubFunc func(patterns ...string) error
	// contains filtered or unexported fields
}

Hub 接收redis数据并用websocket推送的server 支持channel不固定,订阅多个channel

func NewHub

func NewHub(subfunc func(patterns ...string) error, unsubfunc func(patterns ...string) error) *Hub

NewHub ..

func (*Hub) AddClient

func (h *Hub) AddClient(channels []string, conn *websocket.Conn)

AddClient 新增客户端

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) GetChannels

func (h *Hub) GetChannels() []string

GetChannels 获取所有channel

func (*Hub) HandlerDynamicChannel

func (h *Hub) HandlerDynamicChannel() func(w http.ResponseWriter, r *http.Request)

HandlerDynamicChannel 向websocket推送mq数据,可以变更channel

func (*Hub) HandlerStaticChannels

func (h *Hub) HandlerStaticChannels(channels []string) func(w http.ResponseWriter, r *http.Request)

HandlerStaticChannels 向websocket推送mq数据,不可变更channel

func (*Hub) RemoveClient

func (h *Hub) RemoveClient(conn *websocket.Conn)

RemoveClient 移除客户端

func (*Hub) UpdateSubChannels

func (h *Hub) UpdateSubChannels()

UpdateSubChannels 更新Sub的channels

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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