Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about socket communication #23

Closed
hoon0612 opened this issue May 16, 2013 · 4 comments
Closed

Question about socket communication #23

hoon0612 opened this issue May 16, 2013 · 4 comments

Comments

@hoon0612
Copy link

Hi. I have a question

I'm trying to use ProtoBuf.js for socket communication

Dgram socket only accepts Buffer object.

So I used toBuffer() method followed by encode() method to convert

However, I don't know reversal process.

I tried many methods but could not get original json object

Thanks a lot for your work

@dcodeIO
Copy link
Member

dcodeIO commented May 16, 2013

I just updated ByteBuffer.js to allow wrapping of node.js Buffer objects. Please try it out (BB v1.3.4) and let me know if it fixes your issue. You will need to run npm update once.

@ghost ghost assigned dcodeIO May 16, 2013
@hoon0612
Copy link
Author

Thanks a lot decodeIO.

However, It still doesn't work.

/usr/local/share/npm/lib/node_modules/bytebuffer/ByteBuffer.js:59
this.view = this.array != null ? new DataView(this.array) : null;
^
RangeError: byteOffset out of range.
at new ByteBuffer (/usr/local/share/npm/lib/node_modules/bytebuffer/ByteBuffer.js:59:63)

@dcodeIO
Copy link
Member

dcodeIO commented May 16, 2013

Can you provide me with a more detailed test case? At least the following BB test case works:

    "wrap(Buffer)": function(test) {
        var b = new Buffer("abc", "utf8");
        var bb = ByteBuffer.wrap(b);
        test.equal(bb.toHex(), "<61 62 63>");
        test.done();
    },

@hoon0612
Copy link
Author

Oh I'm sorry. I used constructor of ByteBuffer. ( e.g. new ByteBuffer( buf ) )

Now it works with wrap method.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants