Esempio n. 1
0
void ReceiveMsgManage::removeAllMessage()
{
	CAutoLock lock(&m_lock);
	//记录下程序退出时所有的消息列表,并且记录下来,这个会成为离线消息
	SessionMessageMap::iterator iterMap = m_mapSessionMsg.begin();
	LOG__(ERR, _T("MessageMananger unread message trace begin:"));
	for (; iterMap != m_mapSessionMsg.end(); ++iterMap)
	{
		SessionMessage_List msgList;
		if (popMessagesBySId(iterMap->first, msgList))
		{
			SessionMessage_List::iterator iter = msgList.begin();
			for (; iter != msgList.end(); ++iter)
			{
				MessageEntity& msg = *iter;
				CString csUId = util::stringToCString(msg.talkerSid);
				CString csCnt = util::stringToCString(msg.content, CP_UTF8);
				CTime time(msg.msgTime);
				CString csTime = time.Format(_T("%Y-%m-%d %H:%M:%S"));
				LOG__(DEBG, _T("time:%s id:%s,content:%s"), csTime, csUId, csCnt);
			}
		}
	}
	LOG__(DEBG, _T("MessageMananger unread message trace end"));
	m_mapSessionMsg.clear();
}
Esempio n. 2
0
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;
}