-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
Hi,
I have a Request
struct with the following schema:
struct Request {
timestamp @0: UInt64;
payload @1: AnyPointer;
}
The payload
can either be a capnp.Data
struct filled from a Node.js Buffer, or another user-defined struct (let's say a Todo
struct for example). How am I supposed to create a message with such payload?
I tried the following:
const msg = new capnp.Message();
const req = msg.initRoot(Request);
req.setTimestamp(capnp.Uint64.fromNumber(0));
// With a capnp.Data struct:
const payload = capnp.Struct.initStructAt(0, capnp.Data, req);
payload.copyBuffer(Buffer.from("coucou"));
req.setPayload(payload);
// or with a Todo struct:
const payload = capnp.Struct.initStrutAt(0, Todo, req);
payload.setText("Masterize capnp-ts");
payload.setDone(false);
res.setPayload(payload);
The payload is transmitted but the timestamp
field seems corrupted when I set the payload. So, what is the correct way to fill this AnyPointer payload
field?
Metadata
Metadata
Assignees
Labels
No labels