better error handling for SendBinaryMessage
parent
7afb928123
commit
6606c1fbde
|
@ -41,14 +41,28 @@ type WebClient struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (webClient *WebClient) SendBinaryMessage(conn *websocket.Conn, msg []byte) error {
|
func (webClient *WebClient) SendBinaryMessage(conn *websocket.Conn, msg []byte) error {
|
||||||
|
var err error
|
||||||
if conn == webClient.MobileConn {
|
if conn == webClient.MobileConn {
|
||||||
webClient.mobileConnMu.Lock()
|
webClient.mobileConnMu.Lock()
|
||||||
defer webClient.mobileConnMu.Unlock()
|
defer webClient.mobileConnMu.Unlock()
|
||||||
return conn.WriteMessage(websocket.BinaryMessage, msg)
|
err = conn.WriteMessage(websocket.BinaryMessage, msg)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logger.WebMobile.Warnln("err SendBinaryMessage to mobile client")
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
webClient.voiceConnMu.Lock()
|
webClient.voiceConnMu.Lock()
|
||||||
defer webClient.voiceConnMu.Unlock()
|
defer webClient.voiceConnMu.Unlock()
|
||||||
return conn.WriteMessage(websocket.BinaryMessage, msg)
|
|
||||||
|
err = conn.WriteMessage(websocket.BinaryMessage, msg)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logger.WebVoice.Warnln("err SendBinaryMessage to voice client")
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (webClient *WebClient) RemoveVoiceCmdID(cmdID int) {
|
func (webClient *WebClient) RemoveVoiceCmdID(cmdID int) {
|
||||||
|
|
Loading…
Reference in New Issue