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; }
BOOL ReceiveMsgManage::popMessagesBySId(IN const std::string& sId, OUT SessionMessage_List& msgList, IN MSG_TYPE_STATUS status /*= MESSAGE_TYPE_NONE*/, IN const UINT32 msgId/* = 0*/) { CAutoLock lock(&m_lock); SessionMessage_List* listChatMsg = _getChatMsgListBySID(sId); if (listChatMsg && !listChatMsg->empty()) { SessionMessage_List::iterator it = listChatMsg->begin(); while (it != listChatMsg->end()) { if (MESSAGE_RENDERTYPE_AUDIO == it->msgRenderType && !it->isReaded()) { AudioMessageMananger::getInstance()->pushAudioMessageBySId(sId, *it); } if (MESSAGE_TYPE_NONE == status || it->msgStatusType == status) { if (0 == msgId)//获取该会话符合条件的所有消息 { msgList.push_back(*it); it = listChatMsg->erase(it); } else if (it->msgId <= msgId)//获取这个msgId之前的消息 { msgList.push_back(*it); it = listChatMsg->erase(it); } else { ++it; } } else { ++it; } } return TRUE; } return FALSE; }