Documentation
¶
Index ¶
- Constants
- Variables
- type BufferPool
- type CloseType
- type Option
- type WSConn
- func (c *WSConn) Close(ct CloseType, err error)
- func (c *WSConn) Decompress(data []byte) ([]byte, error)
- func (c *WSConn) GetId() ID.Id
- func (c *WSConn) Pack(msgId uint32, msg []byte) []byte
- func (c *WSConn) SendIDMSG(msgId uint32, msg []byte)
- func (c *WSConn) SendMSG(msg []byte)
- func (c *WSConn) SendNow(msgId uint32, msg []byte)
- func (c *WSConn) Start()
- func (c *WSConn) Unpack(header []byte) (dataLen uint32, isCompressed bool)
- type WSServer
- func (s *WSServer) GetConnect(uid ID.Id) *WSConn
- func (s *WSServer) Listen()
- func (s *WSServer) Remove(c *WSConn, ct CloseType, err error)
- func (s *WSServer) RemoveDelay(c *WSConn, unixMilli int64)
- func (s *WSServer) SetCheckOriginFunc(f func(r *http.Request) bool)
- func (s *WSServer) SetCloseHandler(f func(session *WSConn, ct CloseType))
- func (s *WSServer) SetDispatcher(f func(session *WSConn, msgId uint32, data []byte))
- func (s *WSServer) SetTLS(certificate, key string)
- func (s *WSServer) SetVerifyHandler(f func(*http.Request) (ID.Id, error))
Constants ¶
View Source
const CompressThreshold = 1024 // 1KB
CompressThreshold 压缩阈值:超过1KB的消息才压缩
View Source
const HeaderLen = 4
HeaderLen 固定头部长度:4字节
View Source
const MaxMessageSize = 8 * 1024 // 单条消息最大16KB
Variables ¶
View Source
var ByteOrder = binary.BigEndian
新增:全局字节序变量,方便外部调用
Functions ¶
This section is empty.
Types ¶
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
func (*BufferPool) Get ¶
func (p *BufferPool) Get() interface{}
func (*BufferPool) Put ¶
func (p *BufferPool) Put(v interface{})
type Option ¶
type Option struct {
Port string
Path string
ReadBufferSize int
WriteBufferSize int
WriteBufferPool websocket.BufferPool
CheckOrigin func(r *http.Request) bool
EnableCompression bool
}
func DefaultOption ¶
func DefaultOption() *Option
type WSConn ¶
type WSConn struct {
// contains filtered or unexported fields
}
func (*WSConn) Decompress ¶
Decompress 解压数据(仅当isCompressed=true时调用)
type WSServer ¶
type WSServer struct {
Opt *Option //配置
// contains filtered or unexported fields
}
func DefaultServer ¶
func (*WSServer) RemoveDelay ¶
func (*WSServer) SetCheckOriginFunc ¶
func (*WSServer) SetCloseHandler ¶
func (*WSServer) SetDispatcher ¶
Click to show internal directories.
Click to hide internal directories.