mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
ui: allow quick rejudge
This commit is contained in:
1 parent
78925f0507
commit
0bf2c8362a
4 files changed
+19
-4
No files matched your search
+6
-1
@@ -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);
|
||||
}
|
||||
Reference in new issue
Block a user