Documentation ¶
Index ¶
- Variables
- type WebsocketClient
- type WebsocketPool
- func (r *WebsocketPool) Close()
- func (r *WebsocketPool) Handle(writer http.ResponseWriter, req *http.Request, header http.Header, ...)
- func (WebsocketPool) Once() *WebsocketPool
- func (r *WebsocketPool) RegisterRouter(routerKey string, fn func(ws *websocket.Conn)) *WebsocketPool
- func (r *WebsocketPool) SendMessageByAccountOpenId(accountOpenId string, message []byte) error
- func (WebsocketPool) SendMessageByWsConn(ws *websocket.Conn, message []byte) error
- func (r WebsocketPool) SendMessageByWsManyConn(wsList *array.AnyArray[*websocket.Conn], message []byte)
- func (WebsocketPool) SetOnCloseConnectionErr(onCloseConnectionErr func(conn *websocket.Conn, err error)) *WebsocketPool
- func (WebsocketPool) SetOnConnect(onConnect func(*websocket.Conn)) *WebsocketPool
- func (WebsocketPool) SetOnConnectionErr(onConnectionErr func(error)) *WebsocketPool
- func (WebsocketPool) SetOnMessage(onMessage func(*websocket.Conn, []byte) string) *WebsocketPool
- func (WebsocketPool) SetOnMessageErr(onMessageErr func(*websocket.Conn, error)) *WebsocketPool
- func (WebsocketPool) SetOnRouterErr(onRouterErr func(*websocket.Conn, error)) *WebsocketPool
- func (WebsocketPool) SetOnSendMessageErr(onSendMessageErr func(conn *websocket.Conn, err error)) *WebsocketPool
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
WebsocketClient websocket客户端
func (WebsocketClient) New ¶ added in v2.1.2
func (WebsocketClient) New() *WebsocketClient
New 实例化:链接切片
type WebsocketPool ¶ added in v2.1.2
type WebsocketPool struct {
// contains filtered or unexported fields
}
WebsocketPool websocket连接池
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 设置发送消息失败回调
Click to show internal directories.
Click to hide internal directories.