mirror of
https://github.com/ianramzy/decentralized-video-chat.git
synced 2025-02-21 23:45:06 +08:00
switched to iceconnectionstate, full reload now, removed socket listener
This commit is contained in:
parent
5e12f55327
commit
2c8ee8d921
@ -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();
|
||||
};
|
||||
},
|
||||
|
17
server.js
17
server.js
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user