test it
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m51s

This commit is contained in:
matst80
2024-11-10 20:30:12 +01:00
parent 8f0e062817
commit 113ecaccad
5 changed files with 42 additions and 40 deletions

View File

@@ -17,22 +17,22 @@ type PacketWithData struct {
}
type PacketQueue struct {
mu sync.RWMutex
Packets []PacketWithData
connection net.Conn
mu sync.RWMutex
Packets []PacketWithData
//connection net.Conn
}
func NewPacketQueue(connection net.Conn) *PacketQueue {
queue := &PacketQueue{
Packets: make([]PacketWithData, 0),
connection: connection,
Packets: make([]PacketWithData, 0),
//connection: connection,
}
go func() {
defer connection.Close()
var packet Packet
for {
err := ReadPacket(queue.connection, &packet)
err := ReadPacket(connection, &packet)
ts := time.Now()
if err != nil {
@@ -42,10 +42,9 @@ func NewPacketQueue(connection net.Conn) *PacketQueue {
log.Printf("Error receiving packet: %v\n", err)
//return
}
data, err := GetPacketData(queue.connection, int(packet.DataLength))
data, err := GetPacketData(connection, int(packet.DataLength))
if err != nil {
log.Printf("Error receiving packet data: %v\n", err)
return
}
queue.mu.Lock()