更新锁问题

pull/23/head
630892807@qq.com 4 years ago
parent 62bdd757c4
commit d0719dabaa

File diff suppressed because one or more lines are too long

@ -115,14 +115,17 @@ func SuperAdminMessage(str []byte) {
//给指定客服发消息
func OneKefuMessage(toId string, str []byte) {
//新版
mKefuConns := KefuList[toId]
if mKefuConns != nil {
for _, kefu := range mKefuConns {
mKefuConns, ok := KefuList[toId]
if mKefuConns != nil && ok {
log.Println("OneKefuMessage lock")
Mux.Lock()
defer Mux.Unlock()
log.Println("OneKefuMessage unlock")
for _, kefu := range mKefuConns {
kefu.Conn.WriteMessage(websocket.TextMessage, str)
Mux.Unlock()
}
}
SuperAdminMessage(str)
}

@ -130,21 +130,8 @@ func WsServerBackend() {
conn.WriteMessage(websocket.TextMessage, str)
Mux.Unlock()
case "inputing":
//msg := TypeMessage{
// Type: "pong",
//}
//str, _ := json.Marshal(msg)
//var data SimpleMessage
//json.Unmarshal([]byte(typeMsg.Data.(string)),&data)
//log.Println(data)
//from:=typeMsg.Data["from"]
to := typeMsg.Data.(map[string]interface{})["to"].(string)
//content:=typeMsg.Data["content"]
log.Println(to)
Mux.Lock()
//conn.WriteMessage(websocket.TextMessage, str)
OneKefuMessage(to, message.content)
Mux.Unlock()
}
}

Loading…
Cancel
Save