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;我不想写所有的代码,因为代码太多了,我试着让它尽可能的简单。基本上,socket在我单击disconnect后仍处于断开状态。但是如果我再次单击连接,套接字仍然保持断开连接状态,因为我对其执行了console.log操作,并显示套接字已断开连接= true和socket connected = false。
为什么它一直处于断开状态?如何在不刷新浏览器页面的情况下完全刷新整个套接字(只获得一个全新的套接字)?我只想让它在断开连接时完全断开,并在重新连接时完全重新连接。但它不能工作...
发布于 2015-04-16 03:45:03
遇到了同样的问题。有一个秘密选项force new connection
io.connect(url, { 'force new connection' : true })您也可以在1.0中使用forceNew。
更多信息请点击此处:
https://stackoverflow.com/questions/29659297
复制相似问题