// Decodes a diameter message coming from a datablock
void decodeDataBlock(const anna::DataBlock &db/*, unsigned int & detectedApplicationId*/) throw() {
try {
- G_codecMsg.setEngine(NULL); // perhaps we will need another codec engine ...
+ G_codecMsg.clear();
G_codecMsg.decode(db);
} catch(RuntimeException &ex) {
_exit(ex.asString());
* may occur. If you add elements (vendors, avps, messages) is not a problem.
*
* IMPORTANT NOTES:
- * 1) if you want to reuse the message, as a recommendation, you should set engine to
- * NULL or use #clear. In that way, next operation will adjust automatically the needed
- * engine because it would not be configured in such stage.
- * 2) if you want to pre-configure the engine you will need to set the engine to NULL
- * previously and then you could change to the new one without warning/ignoring.
- * 3) if you have dedicated message objects for each interface (application id), then
+ * 1) if you want to reuse the message, as a recommendation, you should #clear the
+ * message. In that way, next operation will adjust automatically the needed engine.
+ * 2) if you have dedicated message objects for each interface (application id), then
* you could set the corresponding engine on constructor (or setEngine), and forget
* about #clear. The needed cleanup will be done automatically from decoding and xml
* loading procedures, and initialized engine will be kept along message operations.
//------------------------------------------------------------------------------
void Message::setEngine(Engine *engine) throw() {
- if (a_engine && engine && (engine != a_engine)) {
+ if (!engine) {
+ LOGWARNING(anna::Logger::warning("Ignored: you must assign a valid codec engine. If you want to set NULL engine, clear the message", ANNA_FILE_LOCATION));
+ return;
+ }
+
+ if (a_engine && (engine != a_engine)) {
LOGWARNING(anna::Logger::warning("Ignored: it is not a good practice to change the codec engine once assigned. Clear the message first to set the engine again.", ANNA_FILE_LOCATION));
return;
}