mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
ui: fix connection close
This commit is contained in:
1 parent
fdcf06c373
commit
60aa0e1611
2 files changed
+2
-4
No files matched your search
@@ -5,7 +5,6 @@ export default class Sock {
|
||||
const i = new URL(url, window.location.href);
|
||||
i.protocol = i.protocol.replace('http', 'ws');
|
||||
this.url = i.toString();
|
||||
this.closed = false;
|
||||
this.sock = new ReconnectingWebSocket(this.url);
|
||||
this.sock.onopen = () => {
|
||||
console.log('Connected');
|
||||
@@ -13,7 +12,7 @@ export default class Sock {
|
||||
};
|
||||
this.sock.onclose = ({ code, reason }) => {
|
||||
console.warn('Connection closed, ', code, reason);
|
||||
if (code >= 4000) this.closed = true;
|
||||
if (code >= 4000) this.close();
|
||||
this.onclose?.(code, reason);
|
||||
};
|
||||
this.sock.onmessage = (message) => {
|
||||
@@ -29,7 +28,6 @@ export default class Sock {
|
||||
}
|
||||
|
||||
close() {
|
||||
this.closed = true;
|
||||
this.sock?.close?.();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.37.1",
|
||||
"version": "4.37.2",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "hydro.js",
|
||||
|
||||
Reference in new issue
Block a user