websocketPool

package
v2.0.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WebSocketPoolApp   WebSocketPool
	WebSocketClientApp WebSocketClient
)

Functions

This section is empty.

Types

type WebSocketClient

type WebSocketClient struct {
	Connections []*websocket.Conn
}

WebSocketClient websocket客户端

func (WebSocketClient) New

New 实例化:链接切片

type WebSocketPool

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

WebSocketPool websocket连接池

func (*WebSocketPool) Close

func (r *WebSocketPool) Close()

Close 关闭连接池

func (*WebSocketPool) Handle

func (r *WebSocketPool) Handle(condition func() (string, bool))

Handle 消息处理

func (WebSocketPool) Once

Once 单例化:WebSocket连接池

func (*WebSocketPool) RegisterRouter

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

RegisterRouter 注册路由

func (*WebSocketPool) SendMessageByAccountOpenId

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

SendMessageByAccountOpenId 根据用户openId发送消息

func (WebSocketPool) SendMessageByWsConn

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

SendMessageByWsConn 通过链接发送消息

func (WebSocketPool) SendMessageByWsManyConn

func (r WebSocketPool) SendMessageByWsManyConn(wsList []*websocket.Conn, message []byte)

SendMessageByWsManyConn 通过链接切片发送消息

func (WebSocketPool) SetOnCloseConnectionErr

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

SetOnCloseConnectionErr 设置关闭链接错误回调

func (WebSocketPool) SetOnConnect

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

SetOnConnect 设置链接成功后回调

func (WebSocketPool) SetOnConnectionErr

func (WebSocketPool) SetOnConnectionErr(onConnectionErr func(error)) *WebSocketPool

SetOnConnectionErr 设置链接失败后回调

func (WebSocketPool) SetOnMessage

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

SetOnMessage 设置接收消息回调

func (WebSocketPool) SetOnMessageErr

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

SetOnMessageErr 设置接收消息失败回调

func (WebSocketPool) SetOnRouterErr

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

SetOnRouterErr 路由失败回调

func (WebSocketPool) SetOnSendMessageErr

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