Hello, World!

This commit is contained in:
2026-07-21 20:58:05 +02:00
commit 8a45d91e8d
6 changed files with 273 additions and 0 deletions

25
shared/proto.go Normal file
View File

@@ -0,0 +1,25 @@
package shared
import "encoding/binary"
const PROTO_VERSION uint16 = 1
const (
unused uint16 = iota
REQ_REGISTER
RESP_REGISTER
)
func Uint16(v uint16) []byte {
out := make([]byte, 2)
binary.LittleEndian.PutUint16(out, v)
return out
}
func BuildPkt(pktType uint16, data []byte) []byte {
out := make([]byte, 4+len(data))
binary.LittleEndian.PutUint16(out[0:], PROTO_VERSION)
binary.LittleEndian.PutUint16(out[2:], pktType)
copy(out[4:], data)
return out
}