How to encode / decode? Create RespMsg objects from Buffer?

nblp
nblp Newcomer

Once we log RSSL messages to a file using confilg parameter
Connections\Name\traceMsgToFile = True

Or manually writing a message to file through buffer
respMsg.getEncodedBuffer()

How to create the original objects (RespMsg, in this case) from these buffers / Files?
I want to recreate original messages for playback / replaying / testing etc..

Tagged:

Best Answer

  • warat.boonyanit
    Answer ✓

    Hi @nblp

    You can use setEncodedBuffer() to create the response message from the buffer you got from getEncodedBuffer().

    So, in your recorder app you can save the encoded buffer:

    const rfa::common::Msg& msg = event.getMsg();
    rfa::common::Buffer tempBuffer = msg.getEncodedBuffer();
    //Save tempBuffer.c_buf() and tempBuffer.size()

    Then when you want to playback:

    //Load saved tempBuffer.c_buf() and tempBuffer.size() to _str and _size
    rfa::common::Buffer tempBuffer;
    tempBuffer.setFrom(_str, _size);

    RespMsg respMsg;
    respMsg.setEncodedBuffer(tempBuffer);

    Playing back from the RFA trace file is trickier.

    The API does not have any function that helps you read the XML trace file. You have to parse the XML trace file and construct the message yourself.