// TMessage ctor from WONException
BadMsgException::BadMsgException(const BaseMessage& theMsgR, int theLine,
                                 const char* theFileP, const char* addTextP) throw() :
	WONException(WONCommon::ExBadTitanMessage, theLine, theFileP)
{
	WTRACE("BadMsgException::ctor(TMessage)");

	// Add header type info or header corrupt message
	if (theMsgR.GetDataLen() >= theMsgR.GetHeaderLength())
	{
		WDBG_LL("BadMsgException::ctor(TMessage) Add header info.");
		GetStream() << "MessageClass=" << (int)theMsgR.GetMessageClass()
		            << "  MessageType="  << theMsgR.GetMessageType()
		            << "  ServiceType=" << theMsgR.GetServiceType();
	}
	else
	{
		WDBG_LH("BadMsgException::ctor(TMessage) Corrupt header!");
		GetStream() << HDRCORRUPT_MSG;
	}

	// Add message length and data length
	WDBG_LL("BadMsgException::ctor(TMessage) Add length info.");
	GetStream() << "  DataLength="    << theMsgR.GetDataLen();

	// Add additional text if defined
	if (addTextP) GetStream() << "  " << addTextP;
}
Exemplo n.º 2
0
bool TMsgSocket::SendBaseMsg(BaseMessage& msg, long timeout, bool async, bool copyData, const CompletionContainer<const SendBaseMsgResult&>& completion)
{
	SendBaseMsgData* sendBaseMsgData = new SendBaseMsgData;
	if (!sendBaseMsgData)
	{
		completion.Complete(SendBaseMsgResult(this, &msg, false, false));
		return false;
	}

	sendBaseMsgData->msg = &msg;
	sendBaseMsgData->completion = completion;

	try {
		msg.Pack();
	}
	catch (...)
	{
		delete sendBaseMsgData;
		completion.Complete(SendBaseMsgResult(this, &msg, false, false));
		return false;
	}

	return SendRawMsgEx(msg.GetDataLen(), msg.GetDataPtr(), timeout, async, copyData, DoneSendBaseMsg, sendBaseMsgData);
}