This commit is contained in:
shoopea 2020-06-14 16:45:07 +02:00
parent 231c1c5605
commit 5382f8dfa7

33
def.go
View File

@ -1,16 +1,8 @@
package main package main
type Packet struct { import (
PLength uint16 "bytes"
PType uint8 )
}
type PacketAdminJoin struct {
Packet
Password string
AppName string
AppVersion string
}
const ( const (
AdminPacketAdminJoin uint8 = 0 AdminPacketAdminJoin uint8 = 0
@ -50,3 +42,22 @@ const (
AdminPacketServerPong AdminPacketServerPong
InvalidAdminPacket = 0xFF InvalidAdminPacket = 0xFF
) )
type Packet struct {
PLength uint16
PType uint8
}
type PacketAdminJoin struct {
Packet
Password string
AppName string
AppVersion string
}
func (p *PacketAdminJoin) Bytes() []byte {
buf := new(bytes.Buffer)
p.PLength = binary.Size(p)
_ = binary.Write(buf, binary.LittleEndian, p)
return buf.Bytes()
}