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="../js/snackbar.js"></script>
<script src="../js/autolink.js"></script>
<script src="../js/chat.js"></script>
<script id="chatJS" src="../js/chat.js"></script>
</body>
</html>

View File

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