clear websocket when it closes

This commit is contained in:
Martina 2021-01-09 14:47:05 -08:00
parent 856e4c66e2
commit 1de7e53ac4
2 changed files with 3 additions and 1 deletions

View File

@ -23,7 +23,7 @@ const websocketSend = async (type, data) => {
if (!ws) { if (!ws) {
console.log("no websocket. creating now..."); console.log("no websocket. creating now...");
ws = Websocket.create(); ws = Websocket.create();
console.log(ws); console.log(ws ? "Successfully created websocket" : "Failed to create websocket");
} }
const encryptedData = await Utilities.encryptWithSecret( const encryptedData = await Utilities.encryptWithSecret(

View File

@ -33,10 +33,12 @@ export const create = () => {
}); });
ws.on("close", () => { ws.on("close", () => {
global.websocket = null;
console.log(global.websocket); console.log(global.websocket);
console.log("Websocket disconnected"); console.log("Websocket disconnected");
}); });
console.log("Websocket server started");
NodeLogging.log(`Websocket server started`); NodeLogging.log(`Websocket server started`);
global.websocket = ws; global.websocket = ws;