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);
|
||||
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?.();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user