mux sending
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 27s
Build and Publish / BuildAndDeploy (push) Successful in 2m19s

This commit is contained in:
matst80
2024-11-12 22:35:03 +01:00
parent e1b254668f
commit addec8788f
4 changed files with 14 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/binary"
"fmt"
"log"
"sync"
"time"
)
@@ -29,6 +30,7 @@ func (c *Client) Close() {
type CartTCPClient struct {
*PersistentConnection
sendMux sync.Mutex
ErrorCount int
address string
*CartPacketQueue
@@ -48,6 +50,8 @@ func NewCartTCPClient(address string) (*CartTCPClient, error) {
}
func (m *CartTCPClient) SendPacket(messageType CartMessage, id CartId, data []byte) error {
m.sendMux.Lock()
defer m.sendMux.Unlock()
m.Conn.Write(header[:])
err := binary.Write(m.Conn, binary.LittleEndian, CartPacket{
Version: CurrentPacketVersion,