test
This commit is contained in:
parent
e94dc950c1
commit
456c479a41
23
packet.go
23
packet.go
@ -117,9 +117,32 @@ func (p *PacketAdminServerWelcome) Read(b []byte) {
|
||||
p.MapY = binary.LittleEndian.Uint16(bs[11:])
|
||||
}
|
||||
|
||||
func (p *AdminPacketServerProtocol) Read(b []byte) {
|
||||
r := bufio.NewReader(bytes.NewReader(b))
|
||||
r.Discard(3)
|
||||
c, _ = r.ReadByte()
|
||||
p.ProtocolVersion = uint8(c)
|
||||
c, _ = r.ReadByte()
|
||||
if c > 0 {
|
||||
p.FurtherData = true
|
||||
} else {
|
||||
p.FurtherData = false
|
||||
}
|
||||
bs := make([]byte, 13)
|
||||
_, _ = r.Read(bs)
|
||||
p.UpdatePacketType = binary.LittleEndian.Uint16(bs[0:])
|
||||
p.FrequenciesAllowed = binary.LittleEndian.Uint16(bs[2:])
|
||||
}
|
||||
|
||||
func handlePacket(p Packet, b []byte) {
|
||||
switch p.PType {
|
||||
case AdminPacketServerProtocol:
|
||||
logInfoDebug("AdminPacketServerProtocol Raw : %v", b)
|
||||
sp := AdminPacketServerProtocol{
|
||||
Packet: p,
|
||||
}
|
||||
sp.Read(b)
|
||||
logInfoDebug("AdminPacketServerProtocol :\n- ProtocolVersion: %v\n- FurtherData: %v\n- UpdatePacketType: %v\n- FrequenciesAllowed: %b", sp.ProtocolVersion, sp.FurtherData, sp.UpdatePacketType, sp.FrequenciesAllowed)
|
||||
case AdminPacketServerWelcome:
|
||||
logInfoDebug("AdminPacketServerWelcome Raw : %v", b)
|
||||
sp := PacketAdminServerWelcome{
|
||||
|
Loading…
Reference in New Issue
Block a user