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

#include <bdLobby/bdMessageStore/bdMessageTypes/bdTeamCustomMessage.h>

bdTeamCustomMessage::bdTeamCustomMessage(const bdUInt messageType)
: bdTeamNotificationMessage(messageType)
{
}

bdTeamCustomMessage::~bdTeamCustomMessage()
{
}

bdBool bdTeamCustomMessage::deserialize(bdBitBufferRef buffer)
{
	bdBool ok = bdTeamNotificationMessage::deserialize(buffer);
	
	bdUInt32 size = BD_MAXIMUM_CUSTOM_MSG_SIZE;
	bdUByte8 payloadBuffer[BD_MAXIMUM_CUSTOM_MSG_SIZE];
	ok = ok && buffer->readBlob(payloadBuffer, size);

	if(ok && (size > 0))
	{
		// fail safe
		ok = false;

		m_data = new bdByteBuffer(size);
		if(m_data.notNull())
		{
			ok = m_data->write(payloadBuffer, size);
		}		
	}

	return ok;
}
