What do these numbers mean in socket.io payload?

I know you asked a while ago, but the information remains for those who are researching.

I did an analysis with reverse engineering in version 2.3.0 (socket.io) and 3.4.2 (engine.io) and got the following:

The first number is the type of communication for engine.io, using the enumerator:

Key Value
0 “open”
1 “close”
2 “ping”
3 “pong”
4 “message”
5 “upgrade”
6 “noop”

The second number is the type of action for socket.io, using the enumerator

Key Value
0 “CONNECT”
1 “DISCONNECT”
2 “EVENT”
3 “ACK”
4 “ERROR”
5 “BINARY_EVENT”
6 “BINARY_ACK”

There are other optional information that can be passed on, such as namespace and ID, but I will not go into that part.

After these codes he expects a Json Array, where index 0 is the name of the event and index 1 is the argument.

So the instruction 42["moveS",{"from":"g1", "to", "f3"}] is a message for engine.io (4), is an event for socket.io (2), which will emit the “moveS” action passing JSON {"from": "g1", "to", "f3"} as a parameter(Actually JSON.Parse({"from": "g1", "to", "f3"})).

Hope this helps. =D

Leave a Comment