refresh only chat.js on disconnect

This commit is contained in:
Ian Ramzy 2020-04-02 12:26:13 -04:00
parent 73edc600f2
commit 4106d01037
2 changed files with 15 additions and 18 deletions

View File

@ -123,6 +123,6 @@
<script src="/socket.io/socket.io.js"></script> <script src="/socket.io/socket.io.js"></script>
<script src="../js/snackbar.js"></script> <script src="../js/snackbar.js"></script>
<script src="../js/autolink.js"></script> <script src="../js/autolink.js"></script>
<script src="../js/chat.js"></script> <script id="chatJS" src="../js/chat.js"></script>
</body> </body>
</html> </html>

View File

@ -137,33 +137,30 @@ var VideoChat = {
switch (VideoChat.peerConnection.connectionState) { switch (VideoChat.peerConnection.connectionState) {
case "connected": case "connected":
logIt("connected"); logIt("connected");
// alert("connected"); VideoChat.socket.disconnect();
function onConnect() {
VideoChat.socket.disconnect();
// VideoChat.peerConnection = null;
}
setTimeout(onConnect, 100);
break; break;
case "disconnected": case "disconnected":
case "failed": case "failed":
logIt("failed/disconnected"); logIt("failed/disconnected");
logIt(VideoChat); logIt("Refreshing page...");
// VideoChat.socket = io(); function reloadScript(id) {
// VideoChat.socket.on("candidate", VideoChat.onCandidate); var $el = $("#" + id);
// VideoChat.socket.on("answer", VideoChat.onAnswer); $("#" + id).replaceWith(
'<script id="' +
location.reload(); id +
'" src="' +
// startUp(); $el.prop("src") +
// alert("failed/disconnected"); '"></script>'
);
}
reloadScript("chatJS");
// location.reload();
break; break;
case "closed": case "closed":
logIt("closed"); logIt("closed");
// alert("closed");
break; break;
} }
}; };
callback(); callback();
}; };
}, },