1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
Message EmsPublisher::CreateMessage(const void *payload, size_t size, MessageProperty **ppProperties)
{
EmsPublisher::Message msg;
CHECKED( EMS::tibemsBytesMsg_Create(&msg) );
CHECKED( EMS::tibemsBytesMsg_SetBytes(msg, payload, static_cast<EMS::tibems_uint>(size)));
// If there are any message properties, set them here
if (ppProperties)
{
while (*ppProperties)
{
MessageProperty *pProperty = *ppProperties++;
switch(pProperty->Value->Type())
{
case(variant::INT):
CHECKED( EMS::tibemsMsg_SetIntProperty(msg, pProperty->Name, pProperty->Value->Int()) );
break;
case(variant::LONG):
CHECKED( EMS::tibemsMsg_SetLongProperty(msg, pProperty->Name, pProperty->Value->Long()) );
break;
case(variant::DOUBLE):
CHECKED( EMS::tibemsMsg_SetDoubleProperty(msg, pProperty->Name, pProperty->Value->Double()) );
break;
case(variant::STRING):
CHECKED( EMS::tibemsMsg_SetStringProperty(msg, pProperty->Name, pProperty->Value->String().c_str()) );
break;
case(variant::BOOL):
CHECKED( EMS::tibemsMsg_SetBooleanProperty(msg, pProperty->Name, pProperty->Value->Bool() ? EMS::TIBEMS_TRUE : EMS::TIBEMS_FALSE ) );
break;
case(variant::VNULL):
case(variant::EMPTY):
// Message properties can't be NULL - do nothing.
break;
}
}
}
return msg;
}
|