auto reconnect logging

This commit is contained in:
Martina 2021-01-09 16:07:31 -08:00
parent 1a390c8393
commit a9eb2f2875
2 changed files with 6 additions and 3 deletions

View File

@ -22,7 +22,9 @@ const websocketSend = async (type, data) => {
let ws = Websocket.get();
if (!ws) {
console.log("no websocket. creating now...");
//set a timeout so it won't proceed for a few seconds after creating the socket? or maybe an wait if possible
ws = Websocket.create();
//or maybe create it and then send back a failure event so they know to try again?
console.log(ws ? "Successfully created websocket" : "Failed to create websocket");
}

View File

@ -35,9 +35,10 @@ export const create = () => {
});
ws.on("close", () => {
global.websocket = null;
console.log(global.websocket);
setTimeout(create, 1000);
setTimeout(() => {
NodeLogging.log(`Auto reconnecting websocket`);
create();
}, 1000);
NodeLogging.log(`Websocket disconnected`);
});