Use amf.DecodeInt32LE() instead of decodeInt32LE().

This commit is contained in:
scruzin 2019-01-13 10:01:03 +10:30
parent e8002582da
commit 9ff10dbbac
1 changed files with 1 additions and 15 deletions

View File

@ -183,9 +183,8 @@ func (pkt *packet) read(s *Session) error {
if size > 6 {
pkt.packetType = header[6]
if size == 11 {
pkt.info = decodeInt32LE(header[7:11])
pkt.info = int32(amf.DecodeInt32LE(header[7:11]))
}
}
}
@ -232,10 +231,6 @@ func (pkt *packet) read(s *Session) error {
s.channelsIn[pkt.channel].timestamp = 0xffffff
}
if pkt.bytesRead != pkt.bodySize {
panic("readPacket: bytesRead != bodySize")
}
if !pkt.hasAbsTimestamp {
// timestamps seem to always be relative
pkt.timestamp += uint32(s.channelTimestamp[pkt.channel])
@ -494,12 +489,3 @@ func (pkt *packet) write(s *Session, queue bool) error {
return nil
}
func decodeInt32LE(data []byte) int32 {
return int32(data[3])<<24 | int32(data[2])<<16 | int32(data[1])<<8 | int32(data[0])
}
func encodeInt32LE(dst []byte, v int32) int32 {
binary.LittleEndian.PutUint32(dst, uint32(v))
return 4
}