Documentation ¶
Index ¶
- Variables
- func ClientDemo()
- func ServerDemo()
- type Client
- type ClientInstance
- type ClientPool
- func (ClientPool) Close() error
- func (ClientPool) CloseClient(instanceName, clientName string)
- func (ClientPool) CloseInstance(instanceName string) error
- func (ClientPool) GetClientInstance(instanceName string) (*ClientInstance, bool)
- func (ClientPool) Once() *ClientPool
- func (ClientPool) SendMessageByConn(client *Client, message string, isSync bool) ([]byte, error)
- func (ClientPool) SendMessageByName(instanceName, clientName, message string, isSync bool) ([]byte, error)
- func (ClientPool) SetClient(instanceName, clientName, host, path string, ...) error
- func (ClientPool) SetOnCloseClientErr(fn func(string, error)) *ClientPool
- func (ClientPool) SetOnConnect(fn func(string)) *ClientPool
- func (ClientPool) SetOnConnectErr(fn func(string, error)) *ClientPool
- func (ClientPool) SetOnReceiveMessageErr(fn func(string, []byte, error)) *ClientPool
- func (ClientPool) SetOnSendMessageErr(fn func(error)) *ClientPool
- type ResponseWrt
- type Server
- type ServerInstance
- type ServerPool
- func (ServerPool) Close()
- func (ServerPool) Handle(writer http.ResponseWriter, req *http.Request, header http.Header, ...)
- func (ServerPool) Once() *ServerPool
- func (ServerPool) RegisterRouter(routerKey string, fn func(ws *websocket.Conn)) *ServerPool
- func (ServerPool) SendMessageByAccountOpenId(accountOpenId string, message []byte) error
- func (ServerPool) SendMessageByWsConn(ws *websocket.Conn, message []byte) error
- func (ServerPool) SendMessageByWsManyConn(servers *array.AnyArray[*Server], message []byte)
- func (ServerPool) SetOnCloseConnectionErr(onCloseConnectionErr func(conn *websocket.Conn, err error)) *ServerPool
- func (ServerPool) SetOnConnect(onConnect func(*websocket.Conn)) *ServerPool
- func (ServerPool) SetOnConnectErr(onConnectionErr func(error)) *ServerPool
- func (ServerPool) SetOnPing(fn func(*websocket.Conn)) *ServerPool
- func (ServerPool) SetOnReceiveMessage(onMessage func(*websocket.Conn, []byte) string) *ServerPool
- func (ServerPool) SetOnReceiveMessageErr(onMessageErr func(*websocket.Conn, error)) *ServerPool
- func (ServerPool) SetOnRouterErr(onRouterErr func(*websocket.Conn, error)) *ServerPool
- func (ServerPool) SetOnSendMessageErr(onSendMessageErr func(conn *websocket.Conn, err error)) *ServerPool
Constants ¶
This section is empty.
Variables ¶
var ( ServerPoolApp ServerPool SeverInstanceApp ServerInstance )
Functions ¶
func ClientDemo ¶ added in v2.13.0
func ClientDemo()
func ServerDemo ¶ added in v2.13.0
func ServerDemo()
Types ¶
type ClientInstance ¶ added in v2.12.3
ClientInstance websocket 客户端链接实例
func (*ClientInstance) GetClient ¶ added in v2.12.3
func (r *ClientInstance) GetClient(clientName string) (*websocket.Conn, bool)
GetClient 获取websocket客户端链接
func (ClientInstance) New ¶ added in v2.12.3
func (ClientInstance) New() *ClientInstance
New 实例化:websocket 客户端实例
type ClientPool ¶ added in v2.12.2
type ClientPool struct {
// contains filtered or unexported fields
}
ClientPool websocket 客户端连接池
var (
ClientPoolApp ClientPool
)
func (ClientPool) CloseClient ¶ added in v2.12.3
func (ClientPool) CloseClient(instanceName, clientName string)
CloseClient 关闭链接
func (ClientPool) CloseInstance ¶ added in v2.12.3
func (ClientPool) CloseInstance(instanceName string) error
CloseInstance 关闭实例
func (ClientPool) GetClientInstance ¶ added in v2.12.3
func (ClientPool) GetClientInstance(instanceName string) (*ClientInstance, bool)
GetClientInstance 获取链接实例
func (ClientPool) Once ¶ added in v2.12.3
func (ClientPool) Once() *ClientPool
Once 单例化:websocket 客户端连接池
func (ClientPool) SendMessageByConn ¶ added in v2.13.3
SendMessageByConn 发送消息:通过链接
func (ClientPool) SendMessageByName ¶ added in v2.13.3
func (ClientPool) SendMessageByName(instanceName, clientName, message string, isSync bool) ([]byte, error)
SendMessageByName 发送消息:通过名称
func (ClientPool) SetClient ¶ added in v2.12.3
func (ClientPool) SetClient( instanceName, clientName, host, path string, receiveMessageFunc func(string, []byte), heartInterval time.Duration, heartFn func(*Client), ) error
SetClient 设置websocket客户端链接
func (ClientPool) SetOnCloseClientErr ¶ added in v2.12.3
func (ClientPool) SetOnCloseClientErr(fn func(string, error)) *ClientPool
SetOnCloseClientErr 设置回调:关闭客户端链接错
func (ClientPool) SetOnConnect ¶ added in v2.12.4
func (ClientPool) SetOnConnect(fn func(string)) *ClientPool
SetOnConnect 设置回调:成功创建链接
func (ClientPool) SetOnConnectErr ¶ added in v2.12.4
func (ClientPool) SetOnConnectErr(fn func(string, error)) *ClientPool
SetOnConnectErr 设置回调:链接错误
func (ClientPool) SetOnReceiveMessageErr ¶ added in v2.12.3
func (ClientPool) SetOnReceiveMessageErr(fn func(string, []byte, error)) *ClientPool
SetOnReceiveMessageErr 设置回调:接收消息错误
func (ClientPool) SetOnSendMessageErr ¶ added in v2.12.4
func (ClientPool) SetOnSendMessageErr(fn func(error)) *ClientPool
SetOnSendMessageErr 设置回调:发送消息错误
type ResponseWrt ¶ added in v2.13.1
type ResponseWrt struct{}
func (ResponseWrt) Header ¶ added in v2.13.1
func (ResponseWrt) Header() http.Header
func (ResponseWrt) WriteHeader ¶ added in v2.13.1
func (ResponseWrt) WriteHeader(statusCode int)
type ServerInstance ¶ added in v2.12.3
ServerInstance websocket服务端实例
func (ServerInstance) New ¶ added in v2.12.3
func (ServerInstance) New() *ServerInstance
New 实例化:链接切片
type ServerPool ¶ added in v2.12.1
type ServerPool struct {
// contains filtered or unexported fields
}
ServerPool websocket 服务端连接池
func (ServerPool) Handle ¶ added in v2.12.1
func (ServerPool) Handle( writer http.ResponseWriter, req *http.Request, header http.Header, condition func() (string, bool), )
Handle 消息处理
func (ServerPool) RegisterRouter ¶ added in v2.12.1
func (ServerPool) RegisterRouter(routerKey string, fn func(ws *websocket.Conn)) *ServerPool
RegisterRouter 注册路由
func (ServerPool) SendMessageByAccountOpenId ¶ added in v2.12.1
func (ServerPool) SendMessageByAccountOpenId(accountOpenId string, message []byte) error
SendMessageByAccountOpenId 根据用户openId发送消息
func (ServerPool) SendMessageByWsConn ¶ added in v2.12.1
func (ServerPool) SendMessageByWsConn(ws *websocket.Conn, message []byte) error
SendMessageByWsConn 通过链接发送消息
func (ServerPool) SendMessageByWsManyConn ¶ added in v2.12.1
func (ServerPool) SendMessageByWsManyConn(servers *array.AnyArray[*Server], message []byte)
SendMessageByWsManyConn 通过链接切片发送消息
func (ServerPool) SetOnCloseConnectionErr ¶ added in v2.12.1
func (ServerPool) SetOnCloseConnectionErr(onCloseConnectionErr func(conn *websocket.Conn, err error)) *ServerPool
SetOnCloseConnectionErr 设置回调:关闭链接错误
func (ServerPool) SetOnConnect ¶ added in v2.12.1
func (ServerPool) SetOnConnect(onConnect func(*websocket.Conn)) *ServerPool
SetOnConnect 设置回调:链接成功后
func (ServerPool) SetOnConnectErr ¶ added in v2.12.4
func (ServerPool) SetOnConnectErr(onConnectionErr func(error)) *ServerPool
SetOnConnectErr 设置回调:链接失败后
func (ServerPool) SetOnPing ¶ added in v2.12.6
func (ServerPool) SetOnPing(fn func(*websocket.Conn)) *ServerPool
SetOnPing 设置回调:ping
func (ServerPool) SetOnReceiveMessage ¶ added in v2.12.4
func (ServerPool) SetOnReceiveMessage(onMessage func(*websocket.Conn, []byte) string) *ServerPool
SetOnReceiveMessage 设置回调:接收消息
func (ServerPool) SetOnReceiveMessageErr ¶ added in v2.12.4
func (ServerPool) SetOnReceiveMessageErr(onMessageErr func(*websocket.Conn, error)) *ServerPool
SetOnReceiveMessageErr 设置回调:接收消息失败
func (ServerPool) SetOnRouterErr ¶ added in v2.12.1
func (ServerPool) SetOnRouterErr(onRouterErr func(*websocket.Conn, error)) *ServerPool
SetOnRouterErr 设置回调:路由解析失败
func (ServerPool) SetOnSendMessageErr ¶ added in v2.12.1
func (ServerPool) SetOnSendMessageErr(onSendMessageErr func(conn *websocket.Conn, err error)) *ServerPool
SetOnSendMessageErr 设置回调:发送消息失败