mirror of
https://github.com/ianramzy/decentralized-video-chat.git
synced 2024-11-13 13:49:19 +08:00
disconnect websocket and refresh page on disconnect
This commit is contained in:
parent
510d11b457
commit
73edc600f2
6
package-lock.json
generated
6
package-lock.json
generated
@ -819,6 +819,12 @@
|
||||
"resolved": "https://registry.npmjs.org/pop-iterate/-/pop-iterate-1.0.1.tgz",
|
||||
"integrity": "sha1-zqz9q0q/NT16DyqqLB/Hs/lBO6M="
|
||||
},
|
||||
"prettier": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.2.tgz",
|
||||
"integrity": "sha512-5xJQIPT8BraI7ZnaDwSbu5zLrB6vvi8hVV58yHQ+QK64qrY40dULy0HSRlQ2/2IdzeBpjhDkqdcFBnFeDEMVdg==",
|
||||
"dev": true
|
||||
},
|
||||
"proxy-addr": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz",
|
||||
|
@ -15,5 +15,8 @@
|
||||
"heroku-ssl-redirect": "0.0.4",
|
||||
"socket.io": "^2.2.0",
|
||||
"twilio": "^3.34.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "2.0.2"
|
||||
}
|
||||
}
|
||||
|
@ -133,6 +133,36 @@ var VideoChat = {
|
||||
VideoChat.socket.on("recieveCaptions", (captions) =>
|
||||
recieveCaptions(captions)
|
||||
);
|
||||
VideoChat.peerConnection.onconnectionstatechange = function (event) {
|
||||
switch (VideoChat.peerConnection.connectionState) {
|
||||
case "connected":
|
||||
logIt("connected");
|
||||
// alert("connected");
|
||||
function onConnect() {
|
||||
VideoChat.socket.disconnect();
|
||||
// VideoChat.peerConnection = null;
|
||||
}
|
||||
setTimeout(onConnect, 100);
|
||||
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");
|
||||
break;
|
||||
case "closed":
|
||||
logIt("closed");
|
||||
// alert("closed");
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
callback();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user