【发布时间】:2014-08-05 03:11:12
【问题描述】:
有谁知道 Socket.io 中内置了哪些事件?
例如:connection、disconnect、join 等
【问题讨论】:
有谁知道 Socket.io 中内置了哪些事件?
例如:connection、disconnect、join 等
【问题讨论】:
这是我在官方文档中找到的所有内容:
Client-side events for
socket.io object:
connect。连接成功时触发。connect_error。在连接错误时触发。Object 错误对象connect_timeout。在连接超时时触发。reconnect。成功重新连接后触发。Number重连尝试次数reconnect_attempt。尝试重新连接时触发。reconnecting。尝试重新连接时触发。Number重连尝试次数reconnect_error。在重新连接尝试错误时触发。Object 错误对象reconnect_failed。在reconnectionAttempts 内无法重新连接时触发
Client-side events for
socket object:
connect。连接时触发。error。连接错误时触发Object错误数据disconnect。断开连接时触发。reconnect。成功重新连接后触发。Number重连尝试次数reconnect_attempt。尝试重新连接时触发。reconnecting。尝试重新连接时触发。Number重连尝试次数reconnect_error。在重新连接尝试错误时触发。Object 错误对象reconnect_failed。在reconnectionAttempts 内无法重新连接时触发
connection/connect。在连接时触发。Socket 传入的套接字。对于当前版本 (1.3.4),reconnect_attempt 和 reconnecting
客户端事件是同义词。
【讨论】:
socket 事件。但是,很遗憾,我在文档和其他地方找不到服务器 socket 事件。
reconnect、reconnect_attempt、reconnecting、reconnect_error、reconnect_failed 事件,因为在每次重新连接时都会创建新的服务器端套接字。这就是我能说的。如果我发现更多信息,我会告诉你的。
disconnecting 可能很有用。