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

Allow sending binary data without ArrayBuffer (e. g. IE8) #36

Merged
merged 3 commits into from
Dec 10, 2014
Merged

Allow sending binary data without ArrayBuffer (e. g. IE8) #36

merged 3 commits into from
Dec 10, 2014

Conversation

wingedkiwi
Copy link

I am working with binary data in the browser and – as far as I can see – I can receive binary data which comes as an object { base64: true, data: base64Data }.

BUT there is no way to do the same to send binary data. Sending binary data strictly requires an ArrayBuffer which is not available in older browsers.

I propose to introduce the same concept for sending binary data as for receiving binary data.
Sending an object { base64: true, data: base64Data } should send the data with binary flag to the wire.
This would allow older browsers to work binary. No need to modify server code nor client code. Only the
engine.io-parser needs a small modification.

This PR would resolve #35.

It adds the proposed way to send binary data for old browsers, including test.
Personally tested on IE8. It should support all browsers that https://github.com/feross/buffer supports too.

Any chance to get this integrated? Personally it would make engine.io the best socket library available because of its comprehensive binary support.

Thanks.

@wingedkiwi wingedkiwi changed the title Patch Allow sending binary data without ArrayBuffer (e. g. IE8) Nov 20, 2014
@@ -102,6 +102,11 @@ exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) {
return encodeBlob(packet, supportsBinary, callback);
}

// might be an object with { base64: true, data: dataAsBase64String }
if (data && data.base64) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to check here for the number of keys not being any more than base64 and data

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any suggestion to do this without introducing incompatibilities to older browsers?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use something like https://github.com/ljharb/object-keys

@rauchg
Copy link
Contributor

rauchg commented Nov 20, 2014

+1 for next release

@rase- rase- added this to the 1.3.0 milestone Nov 22, 2014
@rase- rase- added the Feature label Nov 22, 2014
@wingedkiwi
Copy link
Author

Happy to see this will be integrated :-) Then I no longer need to manage my own forks.

@rauchg
Copy link
Contributor

rauchg commented Nov 25, 2014

It'll come in 1.3.0

rauchg added a commit that referenced this pull request Dec 10, 2014
Allow sending binary data without ArrayBuffer (e. g. IE8)
@rauchg rauchg merged commit e53e9f5 into socketio:master Dec 10, 2014
@rauchg
Copy link
Contributor

rauchg commented Dec 10, 2014

Thanks!

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

Successfully merging this pull request may close these issues.

Allow sending binary data without ArrayBuffer (e. g. IE8)
3 participants