Commit 41061989 by 蒋勇

d

parent f4c599f3
...@@ -64,11 +64,15 @@ class RedisClient { ...@@ -64,11 +64,15 @@ class RedisClient {
if (channel == "brc") {//如果是广播频道,则发送广播到客户端 if (channel == "brc") {//如果是广播频道,则发送广播到客户端
self.chatserver.server.emit("brc", message); self.chatserver.server.emit("brc", message);
} else if (self.chatserver.users[channel]) { } else if (self.chatserver.users[channel]) {
if (!message.type || message.type == "single") { if (!message.toType || message.toType == "single" || message.toType == "sys") {
self.chatserver.users[channel].client.emit("chatmsg", message); if (message.toType && message.toType == "sys") {
self.chatserver.users[channel].client.emit("backtofront", message);
} else {
self.chatserver.users[channel].client.emit("chatmsg", message);
}
//self.chatserver.users[channel].client.emit(message.type, message.data); //self.chatserver.users[channel].client.emit(message.type, message.data);
} else { } else {
if (message.type == "many") { if (message.toType == "many") {
//说明channel是房间名称,查续出房间中的人员uks,然后遍历后发送消息 //说明channel是房间名称,查续出房间中的人员uks,然后遍历后发送消息
let cs = await self.chatserver.rooms.clientsByRoom(channel) let cs = await self.chatserver.rooms.clientsByRoom(channel)
for (c of cs) { for (c of cs) {
......
...@@ -151,7 +151,7 @@ class MsgHandler { ...@@ -151,7 +151,7 @@ class MsgHandler {
content: msg.content, content: msg.content,
isAcceptedFrom: msg.isAcceptedFrom ? msg.isAcceptedFrom : false, isAcceptedFrom: msg.isAcceptedFrom ? msg.isAcceptedFrom : false,
isAcceptedTo: msg.isAcceptedTo ? msg.isAcceptedTo : false, isAcceptedTo: msg.isAcceptedTo ? msg.isAcceptedTo : false,
company_id: companyid companyid: companyid
}; };
msghistoryCtl.service.saveMsg(msgH).then((m) => { msghistoryCtl.service.saveMsg(msgH).then((m) => {
redisClient.publish(to, JSON.stringify(msg)); redisClient.publish(to, JSON.stringify(msg));
...@@ -224,10 +224,10 @@ class SocketServer { ...@@ -224,10 +224,10 @@ class SocketServer {
content: msg.content, content: msg.content,
isAcceptedFrom: msg.isAcceptedFrom ? msg.isAcceptedFrom : false, isAcceptedFrom: msg.isAcceptedFrom ? msg.isAcceptedFrom : false,
isAcceptedTo: msg.isAcceptedTo ? msg.isAcceptedTo : false, isAcceptedTo: msg.isAcceptedTo ? msg.isAcceptedTo : false,
company_id: companyid companyid: companyid
}; };
msghistoryCtl.service.saveMsg(msgH).then((m) => { msghistoryCtl.service.saveMsg(msgH).then((m) => {
redisClient.publish(to, JSON.stringify(msg)); redisClient.publish(to, JSON.stringify(msgH));
}).catch(e => { }).catch(e => {
console.log(e); console.log(e);
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment