【发布时间】:2015-06-21 22:47:03
【问题描述】:
socket = 'what';
//I do this when person clicks connect:
if (socket == 'what')
{
socket = io.connect();
}
else if (socket == null)
{
socket = io.connect();
socket = socket.socket.reconnect();
}
//I do other stuff with webrtc and socket.
//then when person clicks disconnect, I do:
socket.disconnect();
socket = null;
我不想编写所有代码,因为代码太多了,我尽量保持简单。基本上,单击断开连接后,套接字仍然断开连接。但是,如果我再次单击连接,套接字仍然保持断开连接,因为我 console.log 它并且它说套接字断开连接 = true 并且套接字连接 = 假。
为什么它仍然断开连接?如何在不刷新浏览器页面的情况下完全刷新整个套接字(只需获得一个全新的套接字)?我只希望它在断开连接时完全断开连接,并在重新连接时完全重新连接。而且它不起作用....
【问题讨论】:
标签: javascript node.js sockets socket.io client