|
@ -172,6 +172,33 @@ class WechatClient extends RedisModel {
|
|
|
log.warn("doctor is not in the same session");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static sendSocketMessageToDoctor(doctorId, message) {
|
|
|
let doctorClient = clientCache.findByIdAndType(doctorId,SOCKET_TYPES.DOCTOR);
|
|
|
if(!doctorClient){
|
|
|
log.warn("target doctor is not online!");
|
|
|
return;
|
|
|
}
|
|
|
let sendDoctorClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.DOCTOR);
|
|
|
if(!sendDoctorClient){
|
|
|
sendDoctorClient = clientCache.findByIdAndType(doctorId,SOCKET_TYPES.PATIENT);
|
|
|
}
|
|
|
if(sendDoctorClient&&sendDoctorClient.sessionId==doctorClient.sessionId){
|
|
|
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");
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 发送微信模板消息给居民
|
|
|
*
|