SocketIO Chrome Inspector 框架 [英] SocketIO Chrome Inspector Frames

查看:26
本文介绍了SocketIO Chrome Inspector 框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在玩 Socket.IO 并在 Chrome 检查器中查看帧时遇到了一些问题.

I was playing around with Socket.IO and ran into some questions when viewing the frames in the chrome inspector.

每一帧内容旁边的数字是什么意思?

What do the numbers beside each frame's content mean?

推荐答案

那是 Engine.io 协议,其中您看到的数字是数据包编码:

That's the Engine.io protocol where the number you see is the packet encoding:

<packet type id>[<data>]

示例:

2probe

这些是不同的数据包类型:

And these are the different packet types:

0 打开

打开新传输时从服务器发送(重新检查)

Sent from the server when a new transport is opened (recheck)

1 次关闭

请求关闭此传输,但不关闭连接本身.

Request the close of this transport but does not shutdown the connection itself.

2 ping

由客户端发送.服务器应使用包含相同数据的 pong 数据包进行应答

Sent by the client. Server should answer with a pong packet containing the same data

示例 1. 客户端发送:2probe 2. 服务器发送:3probe

example 1. client sends: 2probe 2. server sends: 3probe

3 乒乓球

由服务器发送以响应 ping 数据包.

Sent by the server to respond to ping packets.

4 条消息

实际消息,客户端和服务器应该使用数据调用它们的回调.

actual message, client and server should call their callbacks with the data.

示例 1

服务器发送:4HelloWorld客户端接收并调用回调 socket.on('message', function (data) { console.log(data); });

server sends: 4HelloWorld client receives and calls callback socket.on('message', function (data) { console.log(data); });

示例 2

客户端发送:4HelloWorld服务器接收并调用回调 socket.on('message', function (data) { console.log(data); });

client sends: 4HelloWorld server receives and calls callback socket.on('message', function (data) { console.log(data); });

5 升级

engine.io 切换传输之前,它会测试服务器和客户端是否可以通过此传输进行通信.如果此测试成功,客户端会发送升级数据包,请求服务器刷新旧传输上的缓存并切换到新传输.

Before engine.io switches a transport, it tests, if server and client can communicate over this transport. If this test succeed, the client sends an upgrade packets which requests the server to flush its cache on the old transport and switch to the new transport.

6 noop

一个 noop 数据包.主要用于在收到传入的 websocket 连接时强制轮询周期.

A noop packet. Used primarily to force a poll cycle when an incoming websocket connection is received.

示例

客户端通过新的传输连接客户端发送 2probe服务器接收和发送 3probe客户端接收和发送 5服务器刷新并关闭旧传输并切换到新传输.

client connects through new transport client sends 2probe server receives and sends 3probe client receives and sends 5 server flushes and closes old transport and switches to new.

您可以在此处阅读完整文档

这篇关于SocketIO Chrome Inspector 框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆