Browse Source

成员变化的时候时间更新为空问题处理

8 years ago
parent
commit
45de619a32

+ 5 - 4
src/server/models/client/wechat.client.js

@ -176,16 +176,17 @@ class WechatClient extends RedisModel {
    }
    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);
        let sendClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.DOCTOR);
        if(!sendClient){
            sendClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.PATIENT);
        }
        if(sendDoctorClient&&sendDoctorClient.sessionId==doctorClient.sessionId){
        if(sendClient&&sendClient.sessionId==doctorClient.sessionId){
            WechatClient.updateParticipantLastFetchTime(doctorClient.sessionId, doctorId, ObjectUtil.timestampToLong(message.timestamp));
            doctorClient.socket.emit('message', {
                id: message.id,

+ 4 - 7
src/server/models/sessions/participants.js

@ -31,7 +31,6 @@ class Participants extends RedisModel {
                ModelUtil.emitError(self.eventEmitter, "Get session participants error", err);
                return;
            }
            ModelUtil.emitOK(self.eventEmitter, participants);
        });
    }
@ -101,12 +100,10 @@ class Participants extends RedisModel {
        participantsArray.forEach(function (item) {
            let tokens = item.split(":");
            if(tokens[1]!=2){
                userSessions[RedisModel.makeRedisKey(REDIS_KEYS.UserSessions, tokens[0])] = [createDate.getTime(), sessionId];
                sessionParticipants.push(createDate.getTime());
                sessionParticipants.push(tokens[0]);
                sessionParticipantsRoles.push(tokens[0], tokens[1]);
            }
            userSessions[RedisModel.makeRedisKey(REDIS_KEYS.UserSessions, tokens[0])] = [createDate.getTime(), sessionId];
            sessionParticipants.push(createDate.getTime());
            sessionParticipants.push(tokens[0]);
            sessionParticipantsRoles.push(tokens[0], tokens[1]);
        });
        // 向会话成员、会话成员角色集合中添加数据
        let sessionParticipantsKey = RedisModel.makeRedisKey(REDIS_KEYS.SessionParticipants, sessionId);