I want to redirect the client to some page on socket disconnection, Is it possible and how ?
我想将客户端重定向到套接字断开的某个页面,是否可能以及如何?
I want this to handle when there are abrupt disconnections like server got crashed or internet disconnectivity etc.
我希望这可以在服务器崩溃或互联网断开连接等突然断开时进行处理。
1 个解决方案
#1
0
socket.io
fires a disconnect event on disconnection. Add this to client side:
socket.io在断开连接时触发断开连接事件。将此添加到客户端:
socket.on('disconnect', function () {
alert('Server disconnected! Check your net connection');
window.location = "/unsupported.html"; //page you want to redirect
});
#1
0
socket.io
fires a disconnect event on disconnection. Add this to client side:
socket.io在断开连接时触发断开连接事件。将此添加到客户端:
socket.on('disconnect', function () {
alert('Server disconnected! Check your net connection');
window.location = "/unsupported.html"; //page you want to redirect
});