test
This commit is contained in:
parent
8b781d9eae
commit
024fc73fb0
14
main.go
14
main.go
@ -130,7 +130,19 @@ func main() {
|
||||
Packet: p,
|
||||
}
|
||||
sp.Read(b[:p.PLength])
|
||||
logInfoDebug("AdminPacketServerClientError :\n- ClientID: %d", sp.ClientID)
|
||||
logInfoDebug("AdminPacketServerClientQuit :\n- ClientID: %d", sp.ClientID)
|
||||
case AdminPacketServerChat:
|
||||
sp := PacketAdminServerChat{
|
||||
Packet: p,
|
||||
}
|
||||
sp.Read(b[:p.PLength])
|
||||
logInfoDebug("AdminPacketServerChat :\n- ActionID: %d\n- DestinationID: %d\n- ClientID: %d\n- Message: %s\n- Amount: %d", sp.ActionID, sp.DestinationID, sp.ClientID, sp.Message, sp.Amount)
|
||||
case AdminPacketServerConsole:
|
||||
sp := PacketAdminServerConsole{
|
||||
Packet: p,
|
||||
}
|
||||
sp.Read(b[:p.PLength])
|
||||
logInfoDebug("AdminPacketServerConsole :\n- Origin: %s\n- Text: %s", sp.Origin, sp.Text)
|
||||
default:
|
||||
logInfoDebug("Packet fully read : len : %d / type : %d", p.PLength, p.PType)
|
||||
}
|
||||
|
38
packet.go
38
packet.go
@ -135,6 +135,21 @@ type PacketAdminServerClientError struct {
|
||||
ErrorID uint8
|
||||
}
|
||||
|
||||
type PacketAdminServerChat struct {
|
||||
Packet
|
||||
ActionID uint8
|
||||
DestinationID uint8
|
||||
ClientID uint32
|
||||
Message string
|
||||
Amount uint64
|
||||
}
|
||||
|
||||
type PacketAdminServerConsole struct {
|
||||
Packet
|
||||
Origin string
|
||||
Text string
|
||||
}
|
||||
|
||||
func (p *PacketAdminJoin) Bytes() []byte {
|
||||
buf := new(bytes.Buffer)
|
||||
p.PLength = uint16(len(p.Password) + len(p.AppName) + len(p.AppVersion) + 6)
|
||||
@ -253,3 +268,26 @@ func (p *PacketAdminServerClientQuit) Read(b []byte) {
|
||||
_, _ = r.Read(bs)
|
||||
p.ClientID = binary.LittleEndian.Uint32(bs[0:])
|
||||
}
|
||||
|
||||
func (p *PacketAdminServerChat) Read(b []byte) {
|
||||
r := bufio.NewReader(bytes.NewReader(b))
|
||||
r.Discard(3)
|
||||
c, _ := r.ReadByte()
|
||||
p.ActionID = uint8(c)
|
||||
c, _ = r.ReadByte()
|
||||
p.DestinationID = uint8(c)
|
||||
bs := make([]byte, 4)
|
||||
_, _ = r.Read(bs)
|
||||
p.ClientID = binary.LittleEndian.Uint32(bs[0:])
|
||||
p.Message, _ = r.ReadString(0)
|
||||
bs = make([]byte, 8)
|
||||
_, _ = r.Read(bs)
|
||||
p.Amount = binary.LittleEndian.Uint64(bs[0:])
|
||||
}
|
||||
|
||||
func (p *PacketAdminServerConsole) Read(b []byte) {
|
||||
r := bufio.NewReader(bytes.NewReader(b))
|
||||
r.Discard(3)
|
||||
p.Origin, _ = r.ReadString(0)
|
||||
p.Text, _ = r.ReadString(0)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user