mutext for voice and mobile conn
parent
eb5cce66f5
commit
7326a1c98b
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue