mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +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);
|
const i = new URL(url, window.location.href);
|
||||||
i.protocol = i.protocol.replace('http', 'ws');
|
i.protocol = i.protocol.replace('http', 'ws');
|
||||||
this.url = i.toString();
|
this.url = i.toString();
|
||||||
this.closed = false;
|
|
||||||
this.sock = new ReconnectingWebSocket(this.url);
|
this.sock = new ReconnectingWebSocket(this.url);
|
||||||
this.sock.onopen = () => {
|
this.sock.onopen = () => {
|
||||||
console.log('Connected');
|
console.log('Connected');
|
||||||
@@ -13,7 +12,7 @@ export default class Sock {
|
|||||||
};
|
};
|
||||||
this.sock.onclose = ({ code, reason }) => {
|
this.sock.onclose = ({ code, reason }) => {
|
||||||
console.warn('Connection closed, ', code, reason);
|
console.warn('Connection closed, ', code, reason);
|
||||||
if (code >= 4000) this.closed = true;
|
if (code >= 4000) this.close();
|
||||||
this.onclose?.(code, reason);
|
this.onclose?.(code, reason);
|
||||||
};
|
};
|
||||||
this.sock.onmessage = (message) => {
|
this.sock.onmessage = (message) => {
|
||||||
@@ -29,7 +28,6 @@ export default class Sock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.closed = true;
|
|
||||||
this.sock?.close?.();
|
this.sock?.close?.();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.37.1",
|
"version": "4.37.2",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
Reference in new issue
Block a user