switched to iceconnectionstate, full reload now, removed socket listener

This commit is contained in:
Ian Ramzy 2020-04-02 14:00:16 -04:00
parent 5e12f55327
commit 2c8ee8d921
2 changed files with 19 additions and 32 deletions

View File

@ -158,8 +158,9 @@ var VideoChat = {
VideoChat.socket.on("recieveCaptions", (captions) =>
recieveCaptions(captions)
);
VideoChat.peerConnection.onconnectionstatechange = function (event) {
switch (VideoChat.peerConnection.connectionState) {
VideoChat.peerConnection.oniceconnectionstatechange = function (event) {
switch (VideoChat.peerConnection.iceConnectionState) {
case "connected":
logIt("connected");
VideoChat.socket.disconnect();
@ -167,25 +168,28 @@ var VideoChat = {
case "disconnected":
case "failed":
logIt("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();
// dataChanel.close();
// logIt("Refreshing page...");
// function reloadScript(id) {
// var $el = $("#" + id);
// $("#" + id).replaceWith(
// '<script id="' +
// id +
// '" src="' +
// $el.prop("src") +
// '"></script>'
// );
// }
// reloadScript("chatJS");
// alert("reloding");
location.reload();
break;
case "closed":
logIt("closed");
break;
}
};
callback();
};
},

View File

@ -100,23 +100,6 @@ io.on("connection", function (socket) {
logIt("Received answer. Broadcasting...", room);
socket.broadcast.to(room).emit("answer", answer);
});
// Relay answers
socket.on("sendCaptions", function (captions, room) {
// logIt(captions, room);
socket.broadcast.to(room).emit("recieveCaptions", captions);
});
// Relay answers
socket.on("requestToggleCaptions", function (room) {
logIt("requesting captions", room);
socket.broadcast.to(room).emit("requestToggleCaptions");
});
// Relay chat messages
socket.on("chat message", function (msg, room) {
socket.broadcast.to(room).emit("chat message", msg);
});
});
var port = process.env.PORT || 3000;