// DWBS ------------------------------------------------------------------ DWBS
//
// PLATFORM		: ALL
// PRODUCT		: BIT_DEMON
// VISIBILITY	: PUBLIC
//
// DWBS ------------------------------------------------------------------ DWBS

#include <bdLobby/bdMessageStore/bdGetMessagesResult.h>
#include <bdLobby/bdMessageStore/bdLobbyMessageFactory.h>

bdGetMessagesResult::bdGetMessagesResult()
{
}

bdGetMessagesResult::~bdGetMessagesResult()
{
	m_messages.clear();
}

bdBool bdGetMessagesResult::handleResult(const bdUInt numRows, 
										 bdBitBufferRef buffer)
{
	bdBool ok = true;

	bdUInt i;
	for (i=0; i<numRows; i++)
	{
		bdLobbyMessageRef newMessage;
		bdUInt msgType = 0;
		ok = ok && buffer->readUInt32(msgType);
		newMessage = bdLobbyMessageFactory::getInstance()->create(msgType);

		if (newMessage != BD_NULL)
		{
			ok = ok && newMessage->deserialize(buffer);

			m_messages.pushBack(*newMessage);
		}
	}

	return ok;
}
