mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-19 14:53:44 +00:00
fix message encode issue
This commit is contained in:
1 parent
d6c88d0c4b
commit
075852b847
2 files changed
+16
-8
No files matched your search
@@ -4,7 +4,7 @@ import (
|
||||
"encoding/binary"
|
||||
)
|
||||
|
||||
type MessageID byte
|
||||
type MessageID int
|
||||
|
||||
const (
|
||||
Keepalive MessageID = -1
|
||||
@@ -42,7 +42,7 @@ func (msg *Message) Encode() []byte {
|
||||
buf := make([]byte, 5+len(msg.Payload))
|
||||
binary.BigEndian.PutUint32(buf, msg.Length)
|
||||
buf[4] = byte(msg.ID)
|
||||
buf = append(buf, msg.Payload[:]...)
|
||||
copy(buf[5:], msg.Payload[:])
|
||||
return buf
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user