Reconnect automatically
This commit is contained in:
parent
b11d5b51ed
commit
26b2bdc6e5
1 changed files with 42 additions and 36 deletions
6
index.js
6
index.js
|
@ -34,6 +34,7 @@ app.get("/v1/lanyard", (req, res) => {
|
||||||
// console.log("API is now listening on port 8080!")
|
// console.log("API is now listening on port 8080!")
|
||||||
// })
|
// })
|
||||||
|
|
||||||
|
function socketeer() {
|
||||||
var lanyard = new WebSocket('wss://api.lanyard.rest/socket')
|
var lanyard = new WebSocket('wss://api.lanyard.rest/socket')
|
||||||
|
|
||||||
function beat(dur) {
|
function beat(dur) {
|
||||||
|
@ -72,9 +73,14 @@ lanyard.addEventListener("message", async (res) => {
|
||||||
|
|
||||||
lanyard.on('close', () => {
|
lanyard.on('close', () => {
|
||||||
console.log("Disconnected")
|
console.log("Disconnected")
|
||||||
|
setTimeout(() => {
|
||||||
|
socketeer()
|
||||||
|
}, 60000)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// wsServer = new WebSocket.WebSocketServer({ port: 8090 })
|
// wsServer = new WebSocket.WebSocketServer({ port: 8090 })
|
||||||
|
|
||||||
wsServer = WebSocket.Server;
|
wsServer = WebSocket.Server;
|
||||||
let server = require('http').createServer()
|
let server = require('http').createServer()
|
||||||
wsServer = new wsServer({
|
wsServer = new wsServer({
|
||||||
|
|
Loading…
Reference in a new issue