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

Packet.encode() omits trailing comma for namespaces #671

Closed
oback opened this issue Apr 12, 2021 · 1 comment
Closed

Packet.encode() omits trailing comma for namespaces #671

oback opened this issue Apr 12, 2021 · 1 comment

Comments

@oback
Copy link

oback commented Apr 12, 2021

Hi,

In Packet.encode() needs_comma is ignored if self.id and data are both None. If a namespace is used and there is no data, the encoded packet might look something like 1/namespace, without a trailing comma.

However, the socket.io-protocol readme defines the comma as part of the message:

<packet type>[<# of binary attachments>-][<namespace>,][<acknowledgment id>][JSON-stringified payload without binary]

This is further backed up by the examples, i.e. in the DISCONNECT example: 1/admin,. The same behaviour can be seen in socket.io.js encodeAsString(), where the comma is always appended (if the namespace is not empty and not /).

It seems like a small change that would simplify packet.py, but I don't know whether other parts of the code depend on the current behaviour.

@miguelgrinberg
Copy link
Owner

Oh wow, yeah, I missed that little detail. You are correct, the implement is simpler! 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

No branches or pull requests

2 participants