代码拉取完成,页面将自动刷新
package pomelo
import (
"time"
)
type Option func(*Options)
type Options struct {
MaxConnNum int
MaxMsgLen uint32
HeartbeatTimeout time.Duration
// websocket
WSAddr string
HTTPTimeout time.Duration
CertFile string
KeyFile string
// tcp
TCPAddr string
}
func newOptions(opts...Option) *Options {
opt := &Options{
MaxConnNum: 20000,
MaxMsgLen: 4096,
HTTPTimeout: 10 * time.Second,
HeartbeatTimeout: 20 * time.Second,
}
for _,o := range opts {
o(opt)
}
return opt
}
// Max connections support. Default is 20000
func MaxConnNum(num int) Option {
return func(options *Options) {
options.MaxConnNum = num
}
}
// Max message length. If a message exceeds the limit, the connection sends a close message to the peer. Default is 4096
func MaxMsgLen(length uint32) Option {
return func(options *Options) {
options.MaxMsgLen = length
}
}
// Address of tcp server as "host:port"
func TCPAddr(addr string) Option {
return func(options *Options) {
options.TCPAddr = addr
}
}
// Address of websocket server as "host:port"
func WSAddr(addr string) Option {
return func(options *Options) {
options.WSAddr = addr
}
}
// Timeout for http handshake. Default is 10s
func HTTPTimeout(t time.Duration) Option {
return func(options *Options) {
options.HTTPTimeout = t
}
}
// Cert file for https
func CertFile(f string) Option {
return func(options *Options) {
options.CertFile = f
}
}
// Key file for https
func KeyFile(f string) Option {
return func(options *Options) {
options.KeyFile = f
}
}
// Heartbeat timeout. Default is 10s. Disconnect if after 2*t
func HeartbeatTimeout(t time.Duration) Option {
return func(options *Options) {
options.HeartbeatTimeout = t
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。