Documentation ¶
Overview ¶
分帧器
Index ¶
- Constants
- Variables
- type Channel
- func (p *Channel) CheckPing(duration time.Duration)
- func (p *Channel) CheckPong(duration time.Duration)
- func (p *Channel) Close(reason error) (err error)
- func (p *Channel) Read() (bs []byte, err error)
- func (p *Channel) SetValue(key string, value interface{})
- func (p *Channel) StartPing(duration time.Duration)
- func (p *Channel) Value(key string) (value interface{}, ok bool)
- func (p *Channel) Write(bs []byte) (err error)
- func (p *Channel) WriteSync(bs []byte) (err error)
- type Kcp
- type LenProtoCol
- type ProtoCol
- type ReadWriteCloser
- type Tcp
- type Ws
Constants ¶
View Source
const (
BufSize = 32
)
Variables ¶
View Source
var ( Ping = []byte("ping") Pong = []byte("pong") )
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
解决粘包等问题,以及心跳
func FromKcpConn ¶
func FromReadWriteCloser ¶
func FromReadWriteCloser(conn ReadWriteCloser) *Channel
从连接得到有个新管道, 如果没有可用的协程服务连接则会阻塞
func FromWsConn ¶
type LenProtoCol ¶
type LenProtoCol struct { }
第一个字节是头长度1:uint8, 2:uint16, 4:uint32 后面x个的是内容长度 在后面是内容
type ProtoCol ¶
type ProtoCol interface { Read(io.Reader) ([]byte, error) // 从一个流里读取一帧 Write(io.Writer, []byte) (int, error) // 将一帧写入流 }
func NewLenProtoCol ¶
func NewLenProtoCol() ProtoCol
type ReadWriteCloser ¶
Click to show internal directories.
Click to hide internal directories.