mutext for voice and mobile conn
parent
eb5cce66f5
commit
7326a1c98b
|
@ -17,17 +17,23 @@ type WebClientDb struct {
|
||||||
type WebClient struct {
|
type WebClient struct {
|
||||||
Uuid string
|
Uuid string
|
||||||
MobileConn *websocket.Conn
|
MobileConn *websocket.Conn
|
||||||
|
mobileConnMu sync.Mutex
|
||||||
VoiceConn *websocket.Conn
|
VoiceConn *websocket.Conn
|
||||||
|
voiceConnMu sync.Mutex
|
||||||
MobileCmdIDs []int
|
MobileCmdIDs []int
|
||||||
mobileCmdMu sync.Mutex
|
mobileCmdMu sync.Mutex
|
||||||
VoiceCmdIDs []int
|
VoiceCmdIDs []int
|
||||||
voiceCmdMu sync.Mutex
|
voiceCmdMu sync.Mutex
|
||||||
mu sync.Mutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (webClient *WebClient) SendBinaryMessage(conn *websocket.Conn, msg []byte) error {
|
func (webClient *WebClient) SendBinaryMessage(conn *websocket.Conn, msg []byte) error {
|
||||||
webClient.mu.Lock()
|
if conn == webClient.MobileConn {
|
||||||
defer webClient.mu.Unlock()
|
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)
|
return conn.WriteMessage(websocket.BinaryMessage, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue