core: server: fix websocket message handle

This commit is contained in:
undefined committed 2022-05-03 21:32:10 +08:00
1 parent 8ba14111db
commit 4f4e6f9377
2 files changed
+5 -7

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "3.12.0",
"version": "3.12.1",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",
+4 -6
View File
@@ -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);
}