mux sending
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user