Move probe to WS class for reuse in the badge

This commit is contained in:
Arlo Breault 2019-09-26 11:38:58 -04:00
parent 685c3bd262
commit aa107862c5
2 changed files with 32 additions and 26 deletions

View file

@ -54,6 +54,20 @@ class WS {
return ws;
}
static probeWebsocket(addr) {
return new Promise((resolve, reject) => {
const ws = WS.makeWebsocket(addr);
ws.onopen = () => {
resolve();
ws.close();
};
ws.onerror = () => {
reject();
ws.close();
};
});
}
}
WS.WSS_ENABLED = true;