Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Meteor.status().status 报告“已连接”,如果我断开 PC(ethX 关闭)
它只有在我关闭流星服务器时才有效。
我如何通知客户端是否连接(或未连接)到服务器?
提前致谢!
它需要一段时间才能注意到,请记住 Web 浏览器不知道您的硬件活动(以太网断开连接、互联网突然中断等)。HTML5 有几个新的 API,但流星还没有使用这些 API,它们不能在所有浏览器下工作。
唯一的判断方法是尝试连接并观察连接错误/失败。
一旦错过心跳(不确定间隔是多少),或者您运行.call,.insert等并且没有来自服务器的回复,则状态将更改为断开连接。
.call
.insert