清除ws发信息代码

pull/30/head
taoshihan1991 4 years ago
parent 30ac128a5f
commit f3420db5d4

@ -279,58 +279,6 @@ func singleBroadcaster(){
continue
}
SendKefuOnline(clientMsg, visitor.conn)
case "kfChatMessage":
json.Unmarshal(msgData, &clientMsg)
models.CreateMessage(clientMsg.Id,clientMsg.ToId,clientMsg.Content,"kefu")
guest,ok:=clientList[clientMsg.ToId]
if guest==nil||!ok{
continue
}
conn := guest.conn
msg := TypeMessage{
Type: "message",
Data: ClientMessage{
Name: clientMsg.Name,
Avator: clientMsg.Avator,
Id: clientMsg.Id,
Time: time.Now().Format("2006-01-02 15:04:05"),
ToId: clientMsg.ToId,
Content: clientMsg.Content,
},
}
str, _ := json.Marshal(msg)
conn.WriteMessage(websocket.TextMessage,str)
//kefuConns,ok := kefuList[clientMsg.Id]
//if kefuConns==nil||!ok{
// continue
//}
//for _,kefuConn:=range kefuConns{
// kefuConn.WriteMessage(websocket.TextMessage,str)
//}
case "chatMessage":
json.Unmarshal(msgData, &clientMsg)
models.CreateMessage(clientMsg.ToId,clientMsg.Id,clientMsg.Content,"visitor")
kefuConns,ok := kefuList[clientMsg.ToId]
if kefuConns==nil||!ok{
continue
}
msg := TypeMessage{
Type: "message",
Data: ClientMessage{
Avator: clientMsg.Avator,
Id: clientMsg.Id,
Name: clientMsg.Name,
ToId: clientMsg.ToId,
Content: clientMsg.Content,
Time: time.Now().Format("2006-01-02 15:04:05"),
},
}
str, _ := json.Marshal(msg)
for _,kefuConn:=range kefuConns{
kefuConn.WriteMessage(websocket.TextMessage,str)
}
//心跳
case "ping":
msg := TypeMessage{

@ -198,17 +198,20 @@
return;
}
let _this=this;
let mes = {};
mes.type = "chatMessage";
guest.content = this.messageContent;
mes.data = guest;
this.socket.send(JSON.stringify(mes));
this.messageContent = "";
mes.type = "visitor";
mes.content = this.messageContent;
mes.from_id = guest.id;
mes.to_id = guest.to_id;
mes.content = this.messageContent;
$.post("/message",mes,function(){
_this.messageContent = "";
});
let content = {}
content.avator=guest.avator;
content.content = guest.content;
content.content = this.messageContent;
content.name = guest.name;
content.is_kefu = true;
content.time = this.getNowDate();

Loading…
Cancel
Save