socketio / socket.io-protocol

Socket.IO Protocol specification
https://socket.io
510 stars 60 forks source link

Socket.IO framing protocol, I do not understand. #11

Closed mudlee closed 8 years ago

mudlee commented 9 years ago

I use socket.io with xhr-polling. I have to manipulate the content, but I cannot understand one part of the protocol. If I send a broadcast message (event), I see that the message starts with 42. 4 means it's an event, 2 means it's a message (engine.io). But, if I use xhr-polling, instead of websocket, I see some unicode characters at the start of the packet, such as: \u0000\u0003\u0002\u0004�42[...PACKET...]

What do these unicode characters mean? What is that question before 42? I don't see any related documentations, but I do see that the message when it's an xhr-polling transport is binary encoded. BUT, how, and in what structure? I tried to figure out with this: http://unicode-table.com/en/ But I've not found any good answer :(

thetrompf commented 9 years ago

The 4 part comes from the engine.io-protocol (abstract transport layer) which means message and the 2 part comes from the socket.io-protocol (specific transport layer) which is the message type and means event, internally referenced as MESSAGE_EVENT.

rauchg commented 8 years ago

I'm closing this in favor of #14, let's continue the discussion there.

tamj0rd2 commented 6 years ago

So can the 42 be ignored?

thetrompf commented 6 years ago

What do you mean ignored? It's part of the protocol. It is not a part of your data, if that's what you mean.