revert packet concatenation

This commit is contained in:
wish
2024-11-09 17:22:43 +11:00
parent 366ec833d5
commit 7bf2fd5b8f

View File

@@ -154,22 +154,14 @@ func (s *Session) QueueAck(ackHandle uint32, data []byte) {
func (s *Session) sendLoop() { func (s *Session) sendLoop() {
var pkt packet var pkt packet
var buffer []byte
for { for {
if s.closed { if s.closed {
return return
} }
for len(s.sendPackets) > 0 { err := s.cryptConn.SendPacket(append(pkt.data, []byte{0x00, 0x10}...))
pkt = <-s.sendPackets
buffer = append(buffer, pkt.data...)
}
if len(buffer) > 0 {
err := s.cryptConn.SendPacket(append(buffer, []byte{0x00, 0x10}...))
if err != nil { if err != nil {
s.logger.Warn("Failed to send packet") s.logger.Warn("Failed to send packet")
} }
buffer = buffer[:0]
}
time.Sleep(time.Duration(_config.ErupeConfig.LoopDelay) * time.Millisecond) time.Sleep(time.Duration(_config.ErupeConfig.LoopDelay) * time.Millisecond)
} }
} }