能连接和通讯,还未解析数据

This commit is contained in:
钱纯净
2024-10-13 23:23:34 +08:00
parent 04e405d3f1
commit 0464d8512f
7 changed files with 407 additions and 9 deletions

25
protocol/frame_test.go Normal file
View File

@@ -0,0 +1,25 @@
package protocol
import (
"encoding/hex"
"testing"
)
func TestFrame_Bytes(t *testing.T) {
f := Frame{
MsgID: 1,
Control: 1,
Type: Connect,
Data: []byte{0x01},
}
hex := f.Bytes().HEX()
t.Log(hex)
if hex != "0c0100000001030003000d0001" {
t.Error("编码错误")
}
}
func TestBytes(t *testing.T) {
t.Log(hex.EncodeToString(Bytes(uint32(1))))
t.Log(hex.EncodeToString(Bytes(uint16(0x0d00))))
}