|
@ -156,11 +156,13 @@ class WechatClient extends RedisModel {
|
|
|
|
|
|
static sendReadDoctorByDoctorId(doctorId, message) {
|
|
|
let doctorClient = clientCache.findByIdAndType(doctorId,SOCKET_TYPES.DOCTOR);
|
|
|
// let pc_doctorClient = clientCache.findByIdAndType("pc_"+doctorId,SOCKET_TYPES.PC_DOCTOR);
|
|
|
if(!doctorClient){
|
|
|
log.warn("target doctor is not online!");
|
|
|
return;
|
|
|
}
|
|
|
let sendDoctorClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.DOCTOR);
|
|
|
// let pc_sendDoctorClient = clientCache.findByIdAndType("pc_"+message.sender_id,SOCKET_TYPES.PC_DOCTOR);
|
|
|
if(sendDoctorClient&&sendDoctorClient.sessionId==doctorClient.sessionId){
|
|
|
WechatClient.updateParticipantLastFetchTime(doctorClient.sessionId, doctorId, ObjectUtil.timestampToLong(message.timestamp));
|
|
|
sendDoctorClient.socket.emit('message', {
|
|
@ -176,21 +178,44 @@ class WechatClient extends RedisModel {
|
|
|
read:"one"
|
|
|
});
|
|
|
}else{
|
|
|
log.warn("doctor is not in the same session");
|
|
|
log.warn("doctor is not in the same session or not online");
|
|
|
}
|
|
|
//发送pc版医生端
|
|
|
// if(pc_doctorClient&&pc_sendDoctorClient&&pc_sendDoctorClient.sessionId==pc_doctorClient.sessionId){
|
|
|
// WechatClient.updateParticipantLastFetchTime(pc_doctorClient.sessionId, doctorId, ObjectUtil.timestampToLong(message.timestamp));
|
|
|
// pc_sendDoctorClient.socket.emit('message', {
|
|
|
// id: message.id,
|
|
|
// session_id: message.session_id,
|
|
|
// sender_id: message.sender_id,
|
|
|
// sender_name: message.sender_name,
|
|
|
// content_type: message.content_type,
|
|
|
// content: message.content,
|
|
|
// timestamp: ObjectUtil.timestampToLong(message.timestamp),
|
|
|
// type: message.content_type, // legacy support
|
|
|
// name: message.sender_name,
|
|
|
// read:"one"
|
|
|
// });
|
|
|
// }else{
|
|
|
// log.warn("doctor is not in the same session or not online");
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
static sendSocketMessageToDoctor(doctorId, message) {
|
|
|
|
|
|
let doctorClient = clientCache.findByIdAndType(doctorId,SOCKET_TYPES.DOCTOR);
|
|
|
// let pc_doctorClient = clientCache.findByIdAndType("pc_"+doctorId,SOCKET_TYPES.PC_DOCTOR);
|
|
|
if(!doctorClient){
|
|
|
log.warn("target doctor is not online!");
|
|
|
return;
|
|
|
}
|
|
|
let sendClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.DOCTOR);
|
|
|
if(!sendClient){
|
|
|
let sendClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.DOCTOR);//app医生发送的消息
|
|
|
// if(!sendClient){//pc医生发送的消息
|
|
|
// sendClient = clientCache.findByIdAndType("pc_"+message.sender_id,SOCKET_TYPES.PC_DOCTOR);
|
|
|
// }
|
|
|
if(!sendClient){//居民发送的消息
|
|
|
sendClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.PATIENT);
|
|
|
}
|
|
|
|
|
|
if(sendClient&&sendClient.sessionId==doctorClient.sessionId){
|
|
|
WechatClient.updateParticipantLastFetchTime(doctorClient.sessionId, doctorId, ObjectUtil.timestampToLong(message.timestamp));
|
|
|
doctorClient.socket.emit('message', {
|
|
@ -205,8 +230,26 @@ class WechatClient extends RedisModel {
|
|
|
name: message.sender_name,
|
|
|
});
|
|
|
}else{
|
|
|
log.warn("doctor is not in the same session");
|
|
|
log.warn("doctor is not in the same session or is not online");
|
|
|
}
|
|
|
|
|
|
//发送pc端
|
|
|
// if(pc_doctorClient&&sendClient&&sendClient.sessionId==pc_doctorClient.sessionId){
|
|
|
// WechatClient.updateParticipantLastFetchTime(pc_doctorClient.sessionId, doctorId, ObjectUtil.timestampToLong(message.timestamp));
|
|
|
// pc_doctorClient.socket.emit('message', {
|
|
|
// id: message.id,
|
|
|
// session_id: message.session_id,
|
|
|
// sender_id: message.sender_id,
|
|
|
// sender_name: message.sender_name,
|
|
|
// content_type: message.content_type,
|
|
|
// content: message.content,
|
|
|
// timestamp: ObjectUtil.timestampToLong(message.timestamp),
|
|
|
// type: message.content_type, // legacy support
|
|
|
// name: message.sender_name,
|
|
|
// });
|
|
|
// }else{
|
|
|
// log.warn("doctor is not in the same session or is not online");
|
|
|
// }
|
|
|
}
|
|
|
/**
|
|
|
* 发送微信模板消息给居民
|