Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
788 views
in Technique[技术] by (71.8m points)

websocket - What do these numbers mean in socket.io payload?

When I am using native websocket API I can see just a payload in my chrome console for sockts: enter image description here

But when I use socket.io with their emit event, I can see some strange numbers before my actual payload. I do understand that colors mean that you either send or received the data, but what does the numbers like 42, 3, 2, 430, 420, 5 mean.

Is there a place I can get a full list of these numbers with descriptions?

enter image description here

The code which generates it is kind of big, so I just post small snippets.

Client side always look like this:

socket.emit('joinC', room, function(color){ ... });

Server side looks like this:

io.sockets.in(room).emit('moveS', {...});

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...