12345678910111213141516171819202122232425262728293031 |
- package conn
- import (
- "net"
- )
- // 消息类型
- type MsgType byte
- const (
- PingMsg MsgType = iota
- RequestMsg
- ResponseMsg
- )
- // 连接接口,代表一个原始的连接
- type Connect interface {
- WriteAuthInfo(channel string, auth []byte) (err error)
- ReadAuthInfo() (proto string, version uint8, channel string, auth []byte, err error)
- // WriteChannel(data []byte) error
- WriteRequest(id uint16, cmd string, data []byte) error
- WriteResponse(id uint16, state uint8, data []byte) error
- WritePing(id uint16) error
- ReadMessage(deadline int) (msgType MsgType, id uint16, cmd string, state uint8, data []byte, err error)
- RemoteAddr() net.Addr
- LocalAddr() net.Addr
- Close() error
- }
- // 服务请求连接
- type ServerConnectFunc func(conn Connect)
|