This commit is contained in:
LittleBoy 2019-09-30 23:43:55 +08:00
parent 5fe8e5de76
commit 55cb20946f
3 changed files with 10 additions and 7 deletions

View File

@ -68,6 +68,7 @@ function ioServer(io) {
socket: socket.id,
type: 'customer',
kefu_id: gongHao,
status: 1,
nickname: clientInfo.name,
})
// 给管理员发送通知
@ -149,13 +150,15 @@ function ioServer(io) {
socket.broadcast.emit("message", sendMsg);
} else if (msg.type == msgType.messageType.private) {
let uid = msg.uid; // 对方uid
console.log('find kefu data', msg)
// 暂时不 await
sessoionModel.find(uid).then(toUser => {
console.log('find kefu data', toUser)
if (toUser && toUser.status == 1) { // 对方在线才发送消息哟
io.to(toUser.socket()).emit('message', sendMsg);
io.to(toUser.socket).emit('message', sendMsg);
}
}).catch(e => {
console.log('find kefu data exception', e)
});
}

View File

@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
"start": "nodemon ./bin/www"
},
"dependencies": {
"body-parser": "~1.17.1",

View File

@ -99,7 +99,7 @@ $(function(){
if(msg){
var msg_sender = {
"type":'private',
"uid":'chat-admin-' + gongHao,
"uid":gongHao,
"content":msg,
"from_uid":uuid,
"chat_type":'text'