testing websockets disconnecting

This commit is contained in:
Martina 2021-01-09 14:34:50 -08:00
parent 884d524564
commit 856e4c66e2
2 changed files with 9 additions and 2 deletions

View File

@ -19,7 +19,13 @@ const websocketSend = async (type, data) => {
return;
}
const ws = Websocket.get();
let ws = Websocket.get();
if (!ws) {
console.log("no websocket. creating now...");
ws = Websocket.create();
console.log(ws);
}
const encryptedData = await Utilities.encryptWithSecret(
JSON.stringify(data),
Environment.PUBSUB_SECRET

View File

@ -20,7 +20,7 @@ export const create = () => {
perMessageDeflate: false,
});
ws.on("ping", function() {
ws.on("ping", function () {
clearTimeout(this.pingTimeout);
this.pingTimeout = setTimeout(() => {
@ -33,6 +33,7 @@ export const create = () => {
});
ws.on("close", () => {
console.log(global.websocket);
console.log("Websocket disconnected");
});