ugorji / go

idiomatic codec and rpc lib for msgpack, cbor, json, etc. msgpack.org[Go]
MIT License
1.85k stars 295 forks source link

feed with bytes possible? (e.g. how to work with msgpack streams?) #332

Closed lifeofguenter closed 4 years ago

lifeofguenter commented 4 years ago

in python you can do something like this:

unpacker = Unpacker()
while True:
    buf = sock.recv(1024**2)
    if not buf:
        break
    unpacker.feed(buf)
    for o in unpacker:
        process(o)

in c, you can do something similar: https://github.com/msgpack/msgpack-c/blob/master/example/c/lib_buffer_unpack.c#L71

ruby also has something similar.

How do I do it with this package though? E.g. I am receiving a constant stream of msgpack over the wire - how can I "feed" it into the decoder and loop through the results?

lifeofguenter commented 4 years ago

resolved :)