BOOL SessionLayout::_DisplayUnreadMsg()
{
	SessionMessage_List msgList;
	if (!ReceiveMsgManage::getInstance()->popMessagesBySId(m_sId, msgList) && msgList.empty())
	{
		//没有未读消息
		return FALSE;
	}

	for (auto MessageInfo : msgList)
	{
        if (MESSAGE_RENDERTYPE_SYSTEMTIPS != MessageInfo.msgRenderType)
        {
            DECRYPT_MSG(MessageInfo.content, MessageInfo.content);
        }
		_DisplayMsgToIE(MessageInfo);
	}

	//保存到历史消息中
	module::getDatabaseModule()->sqlBatchInsertMessage(msgList);
	//离线消息需要重置获取历史消息的msgid
	MessageEntity msgFront = msgList.front();
	module::getMessageModule()->setSessionTopMsgId(msgFront.sessionId, msgFront.msgId -1);
	
    //更新总未读计数
    module::getSessionModule()->asynNotifyObserver(module::KEY_SESSION_UPDATE_TOTAL_UNREADMSG_COUNT);

	//发送已读确认
	auto msgBack = msgList.back();
	_AsynSendReadAck(msgBack);
	return TRUE;
}
Пример #2
0
BOOL ReceiveMsgManage::popMessageBySId(const std::string& sId, MessageEntity& msg)
{
	CAutoLock lock(&m_lock);
	SessionMessage_List* listChatMsg = _getChatMsgListBySID(sId);
	if (listChatMsg && !listChatMsg->empty())
	{
		msg = listChatMsg->front();
		if (MSG_TYPE_AUDIO_P2P == msg.msgType && !msg.isReaded())//如果是语音未读消息,先存起来
		{
			AudioMessageMananger::getInstance()->pushAudioMessageBySId(sId, msg);
		}
		listChatMsg->pop_front();
		return TRUE;
	}

	return FALSE;
}