ui: allow quick rejudge

This commit is contained in:
undefined committed 2023-01-11 00:54:59 +08:00
1 parent 78925f0507
commit 0bf2c8362a
4 files changed
+19 -4

No files matched your search

@@ -1,7 +1,8 @@
import ReconnectingWebSocket from 'reconnecting-websocket';
export default class Sock {
constructor(url) {
private sock: ReconnectingWebSocket;
constructor(public url: string) {
const i = new URL(url, window.location.href);
if (i.host !== window.location.host) i.searchParams.append('sid', document.cookie.split('sid=')[1].split(';')[0]);
i.protocol = i.protocol.replace('http', 'ws');
@@ -24,6 +25,10 @@ export default class Sock {
};
}
onmessage: (message: MessageEvent<any>) => void;
onclose: (code: number, reason: string) => void;
onopen: (sock: ReconnectingWebSocket) => void;
send(data) {
this.sock.send(data);
}