From 4106d01037c94bde4199f16d015a1547170c82cb Mon Sep 17 00:00:00 2001 From: Ian Ramzy Date: Thu, 2 Apr 2020 12:26:13 -0400 Subject: [PATCH] refresh only chat.js on disconnect --- public/chat.html | 2 +- public/js/chat.js | 31 ++++++++++++++----------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/public/chat.html b/public/chat.html index 0efda99..f994b15 100644 --- a/public/chat.html +++ b/public/chat.html @@ -123,6 +123,6 @@ - + diff --git a/public/js/chat.js b/public/js/chat.js index 858b84f..7289ccc 100644 --- a/public/js/chat.js +++ b/public/js/chat.js @@ -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( + '' + ); + } + reloadScript("chatJS"); + // location.reload(); break; case "closed": logIt("closed"); - // alert("closed"); break; } }; - callback(); }; },