From 5382f8dfa73b7d62642ce0ff568c72add2168b83 Mon Sep 17 00:00:00 2001 From: shoopea Date: Sun, 14 Jun 2020 16:45:07 +0200 Subject: [PATCH] update --- def.go | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/def.go b/def.go index 756a726..992e15f 100644 --- a/def.go +++ b/def.go @@ -1,16 +1,8 @@ package main -type Packet struct { - PLength uint16 - PType uint8 -} - -type PacketAdminJoin struct { - Packet - Password string - AppName string - AppVersion string -} +import ( + "bytes" +) const ( AdminPacketAdminJoin uint8 = 0 @@ -50,3 +42,22 @@ const ( AdminPacketServerPong 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() +}