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

Added Raw serialization type #823

Closed
wants to merge 1 commit into from

Conversation

muka
Copy link

@muka muka commented Apr 10, 2021

This PR introduce a raw serialization type which allow to bypass the binarypack serialization mechanism and delegate it to the user.

With this modification I have been able to exchange messages with a server-side port of peer.

Porting binarypack to other languages is challenging but using raw byte exchange or other serialization libraries (like proto buffer or avro) would be significantly easier.

I tried to implement test but seems on node side is not possible to go much further testing data connections

This mark also a progress in #759 for interoperability direction

Thank you

@AndySpider
Copy link

As far as I know, the json or binary serializations can be bypassed if user specifies a custom value to the serialization parameter (like a "raw" string). It's un-documented though...

@muka
Copy link
Author

muka commented Apr 12, 2021

Can you share an example? thanks

@AndySpider
Copy link

@muka It's quite simple, just set the serialization parameter to a self-defined value when connect, like below,

const peer = new Peer('myId', ...);
const dataConn = peer.connect('idToConnect', {
    serialization: 'abcdef'              // any string other than the official "binary" or "json" will result in raw serialization type
});

@muka
Copy link
Author

muka commented Apr 12, 2021

@AndySpider thank you, it was indeed that simple :)

I would suggest to add a Raw item to SerializationType that in practice does what I was proposing in this

@muka muka closed this Apr 12, 2021
@muka muka deleted the feature/serialization_raw branch April 12, 2021 03:51
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.

2 participants