hehe
This commit is contained in:
parent
5fe8e5de76
commit
55cb20946f
13
io/io.js
13
io/io.js
@ -33,7 +33,7 @@ function ioServer(io) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
io.on('connection',async function (socket) {
|
io.on('connection', async function (socket) {
|
||||||
console.log('有新的连接进来了:', socket.id);
|
console.log('有新的连接进来了:', socket.id);
|
||||||
|
|
||||||
//用户与Socket进行绑定
|
//用户与Socket进行绑定
|
||||||
@ -63,11 +63,12 @@ function ioServer(io) {
|
|||||||
"type": 'online'
|
"type": 'online'
|
||||||
};
|
};
|
||||||
// 添加客户到 对应的客服
|
// 添加客户到 对应的客服
|
||||||
await sessoionModel.createOrUpdate({uid}, {
|
await sessoionModel.createOrUpdate({uid}, {
|
||||||
uid,
|
uid,
|
||||||
socket: socket.id,
|
socket: socket.id,
|
||||||
type: 'customer',
|
type: 'customer',
|
||||||
kefu_id: gongHao,
|
kefu_id: gongHao,
|
||||||
|
status: 1,
|
||||||
nickname: clientInfo.name,
|
nickname: clientInfo.name,
|
||||||
})
|
})
|
||||||
// 给管理员发送通知
|
// 给管理员发送通知
|
||||||
@ -75,7 +76,7 @@ function ioServer(io) {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//TODO 失败重发机制
|
//TODO 失败重发机制
|
||||||
console.log('给管理员发送通知失败',e);
|
console.log('给管理员发送通知失败', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -149,13 +150,15 @@ function ioServer(io) {
|
|||||||
socket.broadcast.emit("message", sendMsg);
|
socket.broadcast.emit("message", sendMsg);
|
||||||
} else if (msg.type == msgType.messageType.private) {
|
} else if (msg.type == msgType.messageType.private) {
|
||||||
let uid = msg.uid; // 对方uid
|
let uid = msg.uid; // 对方uid
|
||||||
|
console.log('find kefu data', msg)
|
||||||
// 暂时不 await
|
// 暂时不 await
|
||||||
sessoionModel.find(uid).then(toUser => {
|
sessoionModel.find(uid).then(toUser => {
|
||||||
|
console.log('find kefu data', toUser)
|
||||||
if (toUser && toUser.status == 1) { // 对方在线才发送消息哟
|
if (toUser && toUser.status == 1) { // 对方在线才发送消息哟
|
||||||
io.to(toUser.socket()).emit('message', sendMsg);
|
io.to(toUser.socket).emit('message', sendMsg);
|
||||||
}
|
}
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
|
console.log('find kefu data exception', e)
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ./bin/www"
|
"start": "nodemon ./bin/www"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "~1.17.1",
|
"body-parser": "~1.17.1",
|
||||||
|
@ -99,7 +99,7 @@ $(function(){
|
|||||||
if(msg){
|
if(msg){
|
||||||
var msg_sender = {
|
var msg_sender = {
|
||||||
"type":'private',
|
"type":'private',
|
||||||
"uid":'chat-admin-' + gongHao,
|
"uid":gongHao,
|
||||||
"content":msg,
|
"content":msg,
|
||||||
"from_uid":uuid,
|
"from_uid":uuid,
|
||||||
"chat_type":'text'
|
"chat_type":'text'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user