Hi

I have an input byte buffer with N messages. There are 2 cases: this byte 
buffer is zero-byte packed or not.
I read messages like this:
capnp::PackedMessageReader packedReader(cpnpReader.getAdapter(), 
capnp::ReaderOptions(), cpnpReader.getArray()); (where the adapter is an 
adapter for InputStream on the top of the received packet from UDP/Mcast, 
the array is an unpacked output buffer).
or with capnp::FlatArrayMessageReader if the message isn't packed.

I'm trying to save some received messages in the way that they will be 
movable, unpacked and at the same time ready to send.
I get a reader as:
auto anymessage = packedReader.getRoot<capnp::AnyStruct>();
then I can copy it to a bytebuffer that can be moved or stored:
capnp::copyToUnchecked(anymessage, arrayPtr);

The copied buffer is 8 byte less. I assume it is lacking the WirePointer.
1)Can I somehow save it with WirePointer at all? 
2)How to reuse the saved buffer without the WirePointer as a ready message 
for 
MallocMessageBuilder? 

I also tried this way:
capnp::AnyPointer::Reader reader = 
capnp::readMessageUnchecked<capnp::AnyPointer>(reinterpret_cast<const 
capnp::word*>(storedBuffer.data()));
m_builder.setRoot(kj::fwd<capnp::AnyPointer::Reader>(reader));

But the builder writes 0. So, I did something wrong.

Thanks for your help.

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/capnproto/a6951785-d283-4460-a3e5-9ef94a2efffen%40googlegroups.com.

Reply via email to