mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: server: fix websocket message handle
This commit is contained in:
1 parent
8ba14111db
commit
4f4e6f9377
2 files changed
+5
-7
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.12.0",
|
||||
"version": "3.12.1",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -388,13 +388,11 @@ export function Connection(
|
||||
if (h._prepare) await h._prepare(args);
|
||||
if (h.prepare) await h.prepare(args);
|
||||
if (h.message) {
|
||||
conn.on('data', (data) => {
|
||||
h.message(JSON.parse(data));
|
||||
});
|
||||
conn.onmessage = (e) => {
|
||||
h.message(JSON.parse(e.data.toString()));
|
||||
};
|
||||
}
|
||||
conn.on('close', async () => {
|
||||
if (h.cleanup) await h.cleanup(args);
|
||||
});
|
||||
conn.onclose = () => h.cleanup?.(args);
|
||||
} catch (e) {
|
||||
await h.onerror(e);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user