mcollina / msgpack5

A msgpack v5 implementation for node.js, with extension points / msgpack.org[Node]
MIT License
492 stars 76 forks source link

Buffer decode #51

Closed nitsugahcram closed 7 years ago

nitsugahcram commented 7 years ago

Hi, I am receiving a Buffer from net that is encoded with msgpack, but when I tried to decode allways decode first filled.

const msgpack = require('msgpack5')();
var _temp = msgpack.encode(1)
var a = Buffer.from(_temp)
_temp = msgpack.encode("Hi this my test");
a = Buffer.concat([a, _temp], a.length + _temp.length)
<Buffer 01 a4 48 6f 6c 61>
 msgpack.decode(a)
1

How Can I decode all data? Thanks

mcollina commented 7 years ago

That will not work. You need to take care of the message boundaries yourself, e.g. do not concat.

nitsugahcram commented 7 years ago

Could you give a hit, to not concat?

mcollina commented 7 years ago

Send an array, or add an header with the length of the message Il giorno ven 11 nov 2016 alle 19:44 Agustin March notifications@github.com ha scritto:

Could you give a hit, to not concat?

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/mcollina/msgpack5/issues/51#issuecomment-260026175, or mute the thread https://github.com/notifications/unsubscribe-auth/AADL47w2q-VBkUpYPhKLkuGxQyIf_un_ks5q9LebgaJpZM4KwAN1 .

nitsugahcram commented 7 years ago

thanks, the point others mspack has the next, that retrieve the next field..., just to mention, I could not send the header since this pack is used other system in c, java, python and not require this...