示例#1
0
// ***************************************************************************
void	CClientChatManager::processChatString( NLMISC::CBitMemStream& bms, IChatDisplayer &chatDisplayer)
{
	// before displaying anything, must ensure dynamic channels are up to date
	// NB: only processChatString() have to do this. Other methods cannot be in dyn_chat mode
	updateDynamicChatChannels(chatDisplayer);

	// serial
	CChatMsg chatMsg;
	bms.serial( chatMsg );
	CChatGroup::TGroupType	type = static_cast<CChatGroup::TGroupType>(chatMsg.ChatMode);
	ucstring	senderStr;

	bool complete = true;
	complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(chatMsg.SenderNameId, senderStr);

	if (type == CChatGroup::dyn_chat)
	{
		// retrieve the DBIndex from the dynamic chat id
		sint32 dbIndex = ChatMngr.getDynamicChannelDbIndexFromId(chatMsg.DynChatChanID);
		// if the client database is not yet up to date, put the chat message in buffer
		if (dbIndex < 0)
			complete = false;
	}

	// if !complete, wait
	if (!complete)
	{
		_ChatBuffer.push_back(CChatMsgNode(chatMsg, false));
		//nldebug("<impulseChat> Received CHAT, put in buffer : waiting association");
		return;
	}

	// display
	ucstring	ucstr;
	buildChatSentence(chatMsg.CompressedIndex, senderStr, chatMsg.Content, type, ucstr);
	chatDisplayer.displayChat(chatMsg.CompressedIndex, ucstr, chatMsg.Content, type, chatMsg.DynChatChanID, senderStr);
}
示例#2
0
// ***************************************************************************
void CClientChatManager::flushBuffer(IChatDisplayer &chatDisplayer)
{
	// before displaying anything, must ensure dynamic channels are up to date
	updateDynamicChatChannels(chatDisplayer);

	// **** Process waiting messages
	{
		list<CChatMsgNode>::iterator itMsg;
		for( itMsg = _ChatBuffer.begin(); itMsg != _ChatBuffer.end(); )
		{
			CChatGroup::TGroupType	type = static_cast<CChatGroup::TGroupType>(itMsg->ChatMode);
			ucstring sender, content;

			// all strings received?
			bool complete = true;
			if (itMsg->SenderNameId != 0)
				complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(itMsg->SenderNameId, sender);
			if(itMsg->UsePhraseId)
				complete &= STRING_MANAGER::CStringManagerClient::instance()->getDynString(itMsg->PhraseId, content);
			else
				content= itMsg->Content;

			if (type == CChatGroup::dyn_chat)
			{
				// retrieve the DBIndex from the dynamic chat id
				sint32 dbIndex = ChatMngr.getDynamicChannelDbIndexFromId(itMsg->DynChatChanID);
				// if the client database is not yet up to date, leave the chat message in buffer
				if (dbIndex < 0)
					complete = false;
			}

			// if complete, process
			if (complete)
			{
				ucstring ucstr;
				if (itMsg->SenderNameId == 0)
				{
					ucstr = content;
				}
				else
				{
					if(itMsg->DisplayAsTell)
						buildTellSentence(sender, content, ucstr);
					else
						buildChatSentence(itMsg->CompressedIndex, sender, content, type, ucstr);
				}

				// display
				if(itMsg->DisplayAsTell)
					chatDisplayer.displayTell(/*itMsg->CompressedIndex, */ucstr, sender);
				else
					chatDisplayer.displayChat(itMsg->CompressedIndex, ucstr, content, type, itMsg->DynChatChanID, sender);

				list<CChatMsgNode>::iterator itTmp = itMsg++;
				_ChatBuffer.erase( itTmp );
			}
			else
			{
				++itMsg;
			}
		}
	}
} // flushBuffer //