Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Bytes = &myBytes{}
View Source
var (
ErrConnClosed = errors.New("the connection has been closed")
)
Functions ¶
Types ¶
type CheckPacketCallBack ¶
type Client ¶
type Client interface { Connection Stop() }
func NewClient ¶
func NewClient(svrAddr string, buffLength int, protocol PackProtocol, callback ConnCallback, relinkWaitTime, keepAlivePeriod time.Duration) Client
type ConnCallback ¶
type ConnCallback interface { OnLinked(c Connection) OnReceived(c Connection, packet Packet) OnClosed(c Connection) OnErrored(e error, c Connection) }
ConnCallback 建立连接时的委托定义
type Connection ¶
type ECheckType ¶
type ECheckType byte
const ( ECheckTypeNone ECheckType = 0 ECheckTypeCheckSum ECheckType = 1 ECheckTypeCRC16 ECheckType = 4 )
func (ECheckType) ToString ¶
func (v ECheckType) ToString() (string, error)
type PackProtocol ¶
type PackProtocol interface { //GetFrame 组包 如果成功 推一个包到接收缓冲区 GetFrame(b *[]byte, recChan chan<- Packet) error BuildFrame(typeBytes, content []byte) (Packet, error) }
PackProtocol 封包协议
func NewFHProtocol ¶
func NewFHProtocol(head []byte, typeLen, lenSize int, bigEndian bool, checkType ECheckType) PackProtocol
NewFHProtocol 新建固定包头协议 head 特征头 typeLen 包类型长度 字节 lenSize 包长位数 仅支持8 16 32 CheckType 校验方法
func NewHatProtocol ¶
func NewHatProtocol(head, tail []byte, typeLen int, checkType ECheckType) PackProtocol
Click to show internal directories.
Click to hide internal directories.