fix message encode issue

This commit is contained in:
liwei committed 2019-07-09 10:34:33 +08:00
1 parent d6c88d0c4b
commit 075852b847
2 files changed
+16 -8

No files matched your search

+2 -2
View File
@@ -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
}
}