Skip to content

fix: Payload encoding example with binary - #48

Merged
darrachequesne merged 1 commit into
socketio:v3from
eXhumer:v3
Jul 1, 2024
Merged

fix: Payload encoding example with binary#48
darrachequesne merged 1 commit into
socketio:v3from
eXhumer:v3

Conversation

@eXhumer

@eXhumer eXhumer commented Jun 27, 2024

Copy link
Copy Markdown

I noticed that only the protocol 4 had typing support and I wanted to implement the protocol 3 client myself with typescript and was testing all things needed for a fully featured protocol 3 client. During this time, I noticed that the example of the payload with binary message, with binary output, is incorrectly documented as it is missing the type byte in the Buffer output. Running the example with engine.io-parser@2.2.1 (last supported parser for protocol 3) to test the actual output.

const parser = require('engine.io-parser');

parser.encodePayload([
  {
    type: 'message',
    data: '€',
  },
  {
    type: 'message',
    data: Buffer.from([1, 2, 3, 4]),
  },
], false, console.log);

On the console, the following gets printed

<Buffer 00 04 ff 34 e2 82 ac 01 05 ff 04 01 02 03 04>

In the protocol document, the example shows an output of

buffer <00 04 ff 34 e2 82 ac 01 04 ff 01 02 03 04>

This commit aims to fix this discrepancy in the example.

Signed-off-by: eXhumer <exhumer@exhumer.cc>
@darrachequesne
darrachequesne merged commit 05468d1 into socketio:v3 Jul 1, 2024
@darrachequesne

Copy link
Copy Markdown
Member

@eXhumer good catch, thanks a lot 👍

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