Skip to content

Commit

Permalink
Reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey authored and Alexey committed Nov 30, 2020
1 parent 72f8c5a commit 6119507
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions LiveX/livex.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
(function (url) {
var socket = new WebSocket(url);
socket.onmessage = function (event) {
console.log("livex-onmessage:", event);
if (event.data == "@") {
window.location.reload();
function connect() {
var socket = new WebSocket(url);
socket.onmessage = function (event) {
console.log("livex-onmessage:", event);
if (event.data == "@") {
window.location.reload();
}
}
socket.onerror = function (event) {
console.log("livex-onerror:", event);
socket.close();
}
socket.onclose = function (event) {
console.log("livex-onclose:", event);
setTimeout(connect, 1000);
}
}
socket.onerror = function (event) {
console.log("livex-onerror:", event);
}
socket.onclose = function (event) {
console.log("livex-onclose:", event);
}
connect();
})

0 comments on commit 6119507

Please sign in to comment.