diff --git a/modules/structs/WebClient.go b/modules/structs/WebClient.go index bab2805..cdbd79c 100644 --- a/modules/structs/WebClient.go +++ b/modules/structs/WebClient.go @@ -17,17 +17,23 @@ type WebClientDb struct { type WebClient struct { Uuid string MobileConn *websocket.Conn + mobileConnMu sync.Mutex VoiceConn *websocket.Conn + voiceConnMu sync.Mutex MobileCmdIDs []int mobileCmdMu sync.Mutex VoiceCmdIDs []int voiceCmdMu sync.Mutex - mu sync.Mutex } func (webClient *WebClient) SendBinaryMessage(conn *websocket.Conn, msg []byte) error { - webClient.mu.Lock() - defer webClient.mu.Unlock() + if conn == webClient.MobileConn { + webClient.mobileConnMu.Lock() + defer webClient.mobileConnMu.Unlock() + return conn.WriteMessage(websocket.BinaryMessage, msg) + } + webClient.voiceConnMu.Lock() + defer webClient.voiceConnMu.Unlock() return conn.WriteMessage(websocket.BinaryMessage, msg) }