Documentation ¶
Index ¶
- Variables
- func ClientDemo()
- func ServerDemo()
- type Client
- type ClientInstance
- func (r *ClientInstance) Close()
- func (r *ClientInstance) GetClient(clientName string) (*Client, bool)
- func (ClientInstance) New(instanceName string) *ClientInstance
- func (r *ClientInstance) SendMsgByName(clientName string, msgType int, msg []byte) ([]byte, error)
- func (r *ClientInstance) SetClient(clientName, host, path string, ...) (*Client, error)
- type ClientPool
- func (ClientPool) Close()
- func (ClientPool) CloseClient(instanceName, clientName string) error
- func (ClientPool) GetClient(instanceName, clientName string) *Client
- func (ClientPool) GetClientInstance(instanceName string) (*ClientInstance, bool)
- func (ClientPool) Once() *ClientPool
- func (ClientPool) SendMsgByName(instanceName, clientName string, msgType int, msg []byte) ([]byte, error)
- func (ClientPool) SetClient(instanceName, clientName, host, path string, ...) (*Client, error)
- func (ClientPool) SetClientInstance(instanceName string) (*ClientInstance, error)
- func (ClientPool) SetOnCloseClientErr(fn func(instanceName, clientName string, err error)) *ClientPool
- func (ClientPool) SetOnConnect(fn func(instanceName, clientName string)) *ClientPool
- func (ClientPool) SetOnConnectErr(fn func(instanceName, clientName string, err error)) *ClientPool
- func (ClientPool) SetOnReceiveMsgErr(fn func(instanceName, clientName string, propertyMessage []byte, err error)) *ClientPool
- func (ClientPool) SetOnSendMsgErr(fn func(instanceName, clientName string, err error)) *ClientPool
- type Heart
- type MessageTimeout
- type PendingRequest
- 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) SendMsgByAccountOpenId(accountOpenId string, message []byte) error
- func (ServerPool) SendMsgByWsConn(ws *websocket.Conn, message []byte) error
- func (ServerPool) SendMsgByWsManyConn(servers *array.AnyArray[*Server], message []byte)
- func (ServerPool) SetOnCloseConnErr(onCloseConnectionErr func(conn *websocket.Conn, err error)) *ServerPool
- func (ServerPool) SetOnConnect(onConnect func(*websocket.Conn)) *ServerPool
- func (ServerPool) SetOnConnectErr(onConnectErr func(error)) *ServerPool
- func (ServerPool) SetOnPing(fn func(*websocket.Conn)) *ServerPool
- func (ServerPool) SetOnReceiveMsg(onMessage func(*websocket.Conn, []byte) string) *ServerPool
- func (ServerPool) SetOnReceiveMsgErr(onMessageErr func(*websocket.Conn, error)) *ServerPool
- func (ServerPool) SetOnRouterErr(onRouterErr func(*websocket.Conn, error)) *ServerPool
- func (ServerPool) SetOnSendMsgErr(onSendMessageErr func(conn *websocket.Conn, err error)) *ServerPool
Constants ¶
This section is empty.
Variables ¶
var ( ClientPoolApp ClientPool ClientInstanceApp ClientInstance HeartOpt Heart MessageTimeoutOpt MessageTimeout )
var ( ServerPoolApp ServerPool SeverInstanceApp ServerInstance )
var MsgType msgType
Functions ¶
func ClientDemo ¶ added in v2.13.0
func ClientDemo()
func ServerDemo ¶ added in v2.13.0
func ServerDemo()
Types ¶
type Client ¶ added in v2.12.3
type Client struct {
InstanceName, Name string
Conn *websocket.Conn
// contains filtered or unexported fields
}
Client websocket 客户端链接
type ClientInstance ¶ added in v2.12.3
ClientInstance websocket 客户端链接实例
func (*ClientInstance) GetClient ¶ added in v2.12.3
func (r *ClientInstance) GetClient(clientName string) (*Client, bool)
GetClient 获取websocket客户端链接
func (ClientInstance) New ¶ added in v2.12.3
func (ClientInstance) New(instanceName string) *ClientInstance
New 实例化:websocket 客户端实例
func (*ClientInstance) SendMsgByName ¶ added in v2.14.20
SendMsgByName 发送消息:通过名称
type ClientPool ¶ added in v2.12.2
type ClientPool struct { Error error // contains filtered or unexported fields }
ClientPool websocket 客户端连接池
func (ClientPool) CloseClient ¶ added in v2.12.3
func (ClientPool) CloseClient(instanceName, clientName string) error
CloseClient 关闭链接
func (ClientPool) GetClient ¶ added in v2.14.8
func (ClientPool) GetClient(instanceName, clientName string) *Client
GetClient 获取客户端链接
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) SendMsgByName ¶ added in v2.14.11
func (ClientPool) SendMsgByName(instanceName, clientName string, msgType int, msg []byte) ([]byte, error)
SendMsgByName 发送消息:通过名称
func (ClientPool) SetClient ¶ added in v2.12.3
func (ClientPool) SetClient( instanceName, clientName, host, path string, receiveMessageFn func(instanceName, clientName string, prototypeMsg []byte) ([]byte, error), heart *Heart, timeout *MessageTimeout, ) (*Client, error)
SetClient 设置websocket客户端链接
func (ClientPool) SetClientInstance ¶ added in v2.14.2
func (ClientPool) SetClientInstance(instanceName string) (*ClientInstance, error)
SetClientInstance 设置实例链接
func (ClientPool) SetOnCloseClientErr ¶ added in v2.12.3
func (ClientPool) SetOnCloseClientErr(fn func(instanceName, clientName string, err error)) *ClientPool
SetOnCloseClientErr 设置回调:关闭客户端链接错
func (ClientPool) SetOnConnect ¶ added in v2.12.4
func (ClientPool) SetOnConnect(fn func(instanceName, clientName string)) *ClientPool
SetOnConnect 设置回调:成功创建链接
func (ClientPool) SetOnConnectErr ¶ added in v2.12.4
func (ClientPool) SetOnConnectErr(fn func(instanceName, clientName string, err error)) *ClientPool
SetOnConnectErr 设置回调:链接错误
func (ClientPool) SetOnReceiveMsgErr ¶ added in v2.14.11
func (ClientPool) SetOnReceiveMsgErr(fn func(instanceName, clientName string, propertyMessage []byte, err error)) *ClientPool
SetOnReceiveMsgErr 设置回调:接收消息错误
func (ClientPool) SetOnSendMsgErr ¶ added in v2.14.11
func (ClientPool) SetOnSendMsgErr(fn func(instanceName, clientName string, err error)) *ClientPool
SetOnSendMsgErr 设置回调:发送消息错误
type Heart ¶ added in v2.14.4
type Heart struct {
// contains filtered or unexported fields
}
Heart 链接心跳
func (*Heart) SetInterval ¶ added in v2.14.6
SetInterval 设置定时器
type MessageTimeout ¶ added in v2.14.1
type MessageTimeout struct {
// contains filtered or unexported fields
}
MessageTimeout 通信超时
func (MessageTimeout) Default ¶ added in v2.14.6
func (MessageTimeout) Default() *MessageTimeout
Default 默认消息超时:5秒
func (MessageTimeout) New ¶ added in v2.14.1
func (MessageTimeout) New() *MessageTimeout
New 实例化:链接超时
func (*MessageTimeout) SetInterval ¶ added in v2.14.6
func (r *MessageTimeout) SetInterval(interval time.Duration) *MessageTimeout
SetInterval 设置定时器时间
type PendingRequest ¶ added in v2.14.20
PendingRequest
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) SendMsgByAccountOpenId ¶ added in v2.14.11
func (ServerPool) SendMsgByAccountOpenId(accountOpenId string, message []byte) error
SendMsgByAccountOpenId 根据用户openId发送消息
func (ServerPool) SendMsgByWsConn ¶ added in v2.14.10
func (ServerPool) SendMsgByWsConn(ws *websocket.Conn, message []byte) error
SendMsgByWsConn 通过链接发送消息
func (ServerPool) SendMsgByWsManyConn ¶ added in v2.14.11
func (ServerPool) SendMsgByWsManyConn(servers *array.AnyArray[*Server], message []byte)
SendMsgByWsManyConn 通过链接切片发送消息
func (ServerPool) SetOnCloseConnErr ¶ added in v2.14.10
func (ServerPool) SetOnCloseConnErr(onCloseConnectionErr func(conn *websocket.Conn, err error)) *ServerPool
SetOnCloseConnErr 设置回调:关闭链接错误
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(onConnectErr func(error)) *ServerPool
SetOnConnectErr 设置回调:链接失败后
func (ServerPool) SetOnPing ¶ added in v2.12.6
func (ServerPool) SetOnPing(fn func(*websocket.Conn)) *ServerPool
SetOnPing 设置回调:ping
func (ServerPool) SetOnReceiveMsg ¶ added in v2.14.10
func (ServerPool) SetOnReceiveMsg(onMessage func(*websocket.Conn, []byte) string) *ServerPool
SetOnReceiveMsg 设置回调:接收消息
func (ServerPool) SetOnReceiveMsgErr ¶ added in v2.14.10
func (ServerPool) SetOnReceiveMsgErr(onMessageErr func(*websocket.Conn, error)) *ServerPool
SetOnReceiveMsgErr 设置回调:接收消息失败
func (ServerPool) SetOnRouterErr ¶ added in v2.12.1
func (ServerPool) SetOnRouterErr(onRouterErr func(*websocket.Conn, error)) *ServerPool
SetOnRouterErr 设置回调:路由解析失败
func (ServerPool) SetOnSendMsgErr ¶ added in v2.14.10
func (ServerPool) SetOnSendMsgErr(onSendMessageErr func(conn *websocket.Conn, err error)) *ServerPool
SetOnSendMsgErr 设置回调:发送消息失败