Documentation ¶
Index ¶
- Constants
- func NewClient(opts ...ClientOption) network.Client
- type CheckOriginFunc
- type ClientOption
- func WithClientDialUrl(url string) ClientOption
- func WithClientEnableHeartbeat(enable bool) ClientOption
- func WithClientHandshakeTimeout(handshakeTimeout time.Duration) ClientOption
- func WithClientHeartbeatInterval(heartbeatInterval time.Duration) ClientOption
- func WithClientMaxMsgLen(maxMsgLen int) ClientOption
- func WithClientMsgType(msgType string) ClientOption
- type Server
- type ServerOption
- func WithServerCheckOrigin(checkOrigin CheckOriginFunc) ServerOption
- func WithServerCredentials(certFile, keyFile string) ServerOption
- func WithServerHandshakeTimeout(handshakeTimeout time.Duration) ServerOption
- func WithServerHeartbeatInterval(heartbeatInterval time.Duration) ServerOption
- func WithServerListenAddr(addr string) ServerOption
- func WithServerMaxConnNum(maxConnNum int) ServerOption
- func WithServerPath(path string) ServerOption
- type UpgradeHandler
Constants ¶
View Source
const ( TextMessage = ws.OpText BinaryMessage = ws.OpBinary )
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
func NewClient(opts ...ClientOption) network.Client
Types ¶
type CheckOriginFunc ¶
type ClientOption ¶
type ClientOption func(o *clientOptions)
func WithClientEnableHeartbeat ¶
func WithClientEnableHeartbeat(enable bool) ClientOption
WithClientEnableHeartbeat 设置是否启用心跳间隔时间
func WithClientHandshakeTimeout ¶
func WithClientHandshakeTimeout(handshakeTimeout time.Duration) ClientOption
WithClientHandshakeTimeout 设置握手超时时间
func WithClientHeartbeatInterval ¶
func WithClientHeartbeatInterval(heartbeatInterval time.Duration) ClientOption
WithClientHeartbeatInterval 设置心跳间隔时间
func WithClientMaxMsgLen ¶
func WithClientMaxMsgLen(maxMsgLen int) ClientOption
WithClientMaxMsgLen 设置消息最大长度
func WithClientMsgType ¶
func WithClientMsgType(msgType string) ClientOption
WithClientMsgType 设置默认消息类型
type Server ¶
type Server interface { network.Server // OnUpgrade 监听HTTP请求升级 OnUpgrade(handler UpgradeHandler) }
func NewServer ¶
func NewServer(opts ...ServerOption) Server
type ServerOption ¶
type ServerOption func(o *serverOptions)
func WithServerCheckOrigin ¶
func WithServerCheckOrigin(checkOrigin CheckOriginFunc) ServerOption
WithServerCheckOrigin 设置Websocket跨域检测函数
func WithServerCredentials ¶
func WithServerCredentials(certFile, keyFile string) ServerOption
WithServerCredentials 设置证书和秘钥
func WithServerHandshakeTimeout ¶
func WithServerHandshakeTimeout(handshakeTimeout time.Duration) ServerOption
WithServerHandshakeTimeout 设置握手超时时间
func WithServerHeartbeatInterval ¶
func WithServerHeartbeatInterval(heartbeatInterval time.Duration) ServerOption
WithServerHeartbeatInterval 设置心跳检测间隔时间
func WithServerListenAddr ¶
func WithServerListenAddr(addr string) ServerOption
WithServerListenAddr 设置监听地址
func WithServerMaxConnNum ¶
func WithServerMaxConnNum(maxConnNum int) ServerOption
WithServerMaxConnNum 设置连接的最大连接数
type UpgradeHandler ¶
type UpgradeHandler func(w http.ResponseWriter, r *http.Request) (allowed bool)
Click to show internal directories.
Click to hide internal directories.