/// Creates a new message entry. The initial reference count is 1. /// /// @param[in] msg the message represented /// @param[in] pData the binary encoding of the message - the pointer will be retained by the new object /// @param[in] cbData the length of the binary encoding CFudgeMsgInfo::CFudgeMsgInfo (FudgeMsg msg, void *pData, size_t cbData) { m_nRefCount = 1; m_msg = msg; FudgeMsg_retain (msg); m_pData = pData; m_cbData = cbData; }
FudgeStatus FudgeMsgEnvelope_create ( FudgeMsgEnvelope * envelopeptr, fudge_byte directives, fudge_byte schemaversion, fudge_i16 taxonomy, FudgeMsg message ) { FudgeStatus status; if ( ! ( *envelopeptr = FUDGEMEMORY_MALLOC( FudgeMsgEnvelope, sizeof ( struct FudgeMsgEnvelopeImpl ) ) ) ) return FUDGE_OUT_OF_MEMORY; if ( ( status = FudgeRefCount_create ( &( ( *envelopeptr )->refcount ) ) ) != FUDGE_OK ) goto release_and_fail; if ( ( status = FudgeMsg_retain ( message ) ) != FUDGE_OK ) goto release_and_fail; ( *envelopeptr )->directives = directives; ( *envelopeptr )->schemaversion = schemaversion; ( *envelopeptr )->taxonomy = taxonomy; ( *envelopeptr )->message = message; return FUDGE_OK; release_and_fail: FUDGEMEMORY_FREE( *envelopeptr ); return status; }
void SetStash (FudgeMsg msgStash) { m_oStashMutex.Enter (); if (m_msgStash) { LOGDEBUG (TEXT ("Discarding old stash message")); FudgeMsg_release (m_msgStash); } FudgeMsg_retain (msgStash); m_msgStash = msgStash; m_oStashMutex.Leave (); }
/// Creates a Fudge message from a binary encoding. /// /// @param[in] pData the encoded message data /// @param[in] cbData the length of the encoded data in bytes /// @return the message, or NULL if there is a problem static FudgeMsg _DecodeFudgeMsg (const void *pData, size_t cbData) { FudgeMsgEnvelope env; FudgeMsg msg = NULL; if (FudgeCodec_decodeMsg (&env, (fudge_byte*)pData, cbData) == FUDGE_OK) { msg = FudgeMsgEnvelope_getMessage (env); FudgeMsg_retain (msg); FudgeMsgEnvelope_release (env); } else { LOGWARN (TEXT ("Couldn't decode Fudge message")); } return msg; }
FudgeStatus FudgeMsg_addFieldMsg ( FudgeMsg message, const FudgeString name, const fudge_i16 * ordinal, FudgeMsg value ) { FudgeStatus status; FudgeFieldData data; if ( ! ( message && value ) ) return FUDGE_NULL_POINTER; if ( ( status = FudgeMsg_retain ( value ) ) != FUDGE_OK ) return status; data.message = value; if ( ( status = FudgeMsg_addFieldData ( message, FUDGE_TYPE_FUDGE_MSG, name, ordinal, &data, 0 ) ) != FUDGE_OK ) { FudgeMsg_release ( value ); return status; } return FUDGE_OK; }