-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Changes in ProtoBuf.js 2.2
Daniel Wirtz edited this page May 7, 2014
·
2 revisions
Upon request the convenience methods Message#encodeDelimited([bb])
and Message.decodeDelimited(bb)
have been added, which encode respectively decode a varint32 length-delimited message.
Because this is usually used to encode multiple messages into one ByteBuffer, Message.encode
no longer implicitly flips the destination ByteBuffer if it is explicitly specified:
var MyMessage = builder.build("MyMessage");
var myMessage = new MyMessage(...);
// If omitted, nothing has changed:
var bb = myMessage.encode(); // 2.0: flips, 2.2: flips
// If explicitly specified, it does not flip anymore so that
// multiple messages can easily be written into one ByteBuffer:
var bb = new ByteBuffer();
myMessage.encode[Delimited](bb); // 2.0: flips: 2.2: does not flip