websocketPool

package
v2.8.2 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WebsocketPoolHelper   WebsocketPool
	WebsocketClientHelper WebsocketClient
)

Functions

This section is empty.

Types

type WebsocketClient added in v2.1.2

type WebsocketClient struct {
	Connections *array.AnyArray[*websocket.Conn]
}

WebsocketClient websocket客户端

func (WebsocketClient) New added in v2.1.2

New 实例化:链接切片

type WebsocketPool added in v2.1.2

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

WebsocketPool websocket连接池

func (*WebsocketPool) Close added in v2.1.2

func (r *WebsocketPool) Close()

Close 关闭连接池

func (*WebsocketPool) Handle added in v2.1.2

func (r *WebsocketPool) Handle(
	writer http.ResponseWriter,
	req *http.Request,
	header http.Header,
	condition func() (string, bool),
)

Handle 消息处理

func (WebsocketPool) Once added in v2.1.2

func (WebsocketPool) Once() *WebsocketPool

Once 单例化:WebSocket连接池

func (*WebsocketPool) RegisterRouter added in v2.1.2

func (r *WebsocketPool) RegisterRouter(routerKey string, fn func(ws *websocket.Conn)) *WebsocketPool

RegisterRouter 注册路由

func (*WebsocketPool) SendMessageByAccountOpenId added in v2.1.2

func (r *WebsocketPool) SendMessageByAccountOpenId(accountOpenId string, message []byte) error

SendMessageByAccountOpenId 根据用户openId发送消息

func (WebsocketPool) SendMessageByWsConn added in v2.1.2

func (WebsocketPool) SendMessageByWsConn(ws *websocket.Conn, message []byte) error

SendMessageByWsConn 通过链接发送消息

func (WebsocketPool) SendMessageByWsManyConn added in v2.1.2

func (r WebsocketPool) SendMessageByWsManyConn(wsList *array.AnyArray[*websocket.Conn], message []byte)

SendMessageByWsManyConn 通过链接切片发送消息

func (WebsocketPool) SetOnCloseConnectionErr added in v2.1.2

func (WebsocketPool) SetOnCloseConnectionErr(onCloseConnectionErr func(conn *websocket.Conn, err error)) *WebsocketPool

SetOnCloseConnectionErr 设置关闭链接错误回调

func (WebsocketPool) SetOnConnect added in v2.1.2

func (WebsocketPool) SetOnConnect(onConnect func(*websocket.Conn)) *WebsocketPool

SetOnConnect 设置链接成功后回调

func (WebsocketPool) SetOnConnectionErr added in v2.1.2

func (WebsocketPool) SetOnConnectionErr(onConnectionErr func(error)) *WebsocketPool

SetOnConnectionErr 设置链接失败后回调

func (WebsocketPool) SetOnMessage added in v2.1.2

func (WebsocketPool) SetOnMessage(onMessage func(*websocket.Conn, []byte) string) *WebsocketPool

SetOnMessage 设置接收消息回调

func (WebsocketPool) SetOnMessageErr added in v2.1.2

func (WebsocketPool) SetOnMessageErr(onMessageErr func(*websocket.Conn, error)) *WebsocketPool

SetOnMessageErr 设置接收消息失败回调

func (WebsocketPool) SetOnRouterErr added in v2.1.2

func (WebsocketPool) SetOnRouterErr(onRouterErr func(*websocket.Conn, error)) *WebsocketPool

SetOnRouterErr 路由失败回调

func (WebsocketPool) SetOnSendMessageErr added in v2.1.2

func (WebsocketPool) SetOnSendMessageErr(onSendMessageErr func(conn *websocket.Conn, err error)) *WebsocketPool

SetOnSendMessageErr 设置发送消息失败回调

Jump to

Keyboard shortcuts

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