switch to ultimate-ws
This commit is contained in:
parent
f048945ece
commit
30e6e61c81
4 changed files with 28 additions and 18 deletions
|
@ -27,7 +27,6 @@ const messagesOut = metrics.addMetric(new Counter("multiprobe_msg_out"));
|
|||
dataIn.setHelpText("Total messages sent by the server");
|
||||
|
||||
import { createReader, createWriter, Endian } from "bufferstuff";
|
||||
import { WebSocketServer } from "ws";
|
||||
import Fastify from "fastify";
|
||||
import FastifyFormBody from "@fastify/formbody";
|
||||
import FastifyCookie from "@fastify/cookie";
|
||||
|
@ -55,6 +54,8 @@ import BadgeCache from "./objects/BadgeCache";
|
|||
import ScriptParameters from "./interfaces/ScriptParameters";
|
||||
import { BadgeUnlockResult } from "./enums/BadgeUnlockResult";
|
||||
|
||||
const { WebSocketServer } = require("ultimate-ws");
|
||||
|
||||
Console.customHeader(`MultiProbe server started at ${new Date()}`);
|
||||
|
||||
const users = new FunkyArray<string, RemoteUser>();
|
||||
|
@ -196,7 +197,7 @@ async function updateConnectionMetrics() {
|
|||
|
||||
const keepalivePacket = createWriter(Endian.LE, 1).writeByte(MessageType.KeepAlive).toBuffer();
|
||||
|
||||
websocketServer.on("connection", (socket) => {
|
||||
websocketServer.on("connection", (socket: any) => {
|
||||
const myUUID = crypto.randomUUID();
|
||||
let user:RemoteUser;
|
||||
|
||||
|
@ -247,7 +248,7 @@ websocketServer.on("connection", (socket) => {
|
|||
socket.on("close", closeOrError);
|
||||
socket.on("error", closeOrError);
|
||||
|
||||
socket.on("message", async (data) => {
|
||||
socket.on("message", async (data: any) => {
|
||||
const reader = createReader(Endian.LE, data as Buffer);
|
||||
dataIn.add(reader.length);
|
||||
messagesIn.add(1);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { createWriter, Endian } from "bufferstuff";
|
||||
import IMetric from "simple-prom/lib/interfaces/IMetric";
|
||||
import { WebSocket } from "ws";
|
||||
import { MessageType } from "../enums/MessageType";
|
||||
|
||||
export default class RemoteUser {
|
||||
|
|
35
server/package-lock.json
generated
35
server/package-lock.json
generated
|
@ -19,12 +19,11 @@
|
|||
"hsconsole": "^1.0.2",
|
||||
"mysql2": "^3.11.3",
|
||||
"simple-prom": "^1.0.1",
|
||||
"ws": "^8.16.0"
|
||||
"ultimate-ws": "^1.0.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/ejs": "^3.1.5",
|
||||
"@types/node": "^22.7.5",
|
||||
"@types/ws": "^8.5.12",
|
||||
"@vercel/ncc": "^0.38.2",
|
||||
"check-outdated": "^2.12.0",
|
||||
"nodemon": "^3.1.7",
|
||||
|
@ -288,16 +287,6 @@
|
|||
"undici-types": "~6.19.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/ws": {
|
||||
"version": "8.5.12",
|
||||
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.12.tgz",
|
||||
"integrity": "sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@vercel/ncc": {
|
||||
"version": "0.38.2",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.2.tgz",
|
||||
|
@ -3349,6 +3338,12 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/tseep": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/tseep/-/tseep-1.3.1.tgz",
|
||||
"integrity": "sha512-ZPtfk1tQnZVyr7BPtbJ93qaAh2lZuIOpTMjhrYa4XctT8xe7t4SAW9LIxrySDuYMsfNNayE51E/WNGrNVgVicQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/typed-array-buffer": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.2.tgz",
|
||||
|
@ -3436,6 +3431,17 @@
|
|||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/ultimate-ws": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/ultimate-ws/-/ultimate-ws-1.0.8.tgz",
|
||||
"integrity": "sha512-pk/PM+G6IK3l1BdgXXHdOuFul0/hyyi3AluNdgYjaXap/u47wRRJDE6YCPks0wgcHkb9iOTu9AiHFkH1ezXkOw==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"tseep": "^1.3.1",
|
||||
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.48.0",
|
||||
"ws": "^8.18.0"
|
||||
}
|
||||
},
|
||||
"node_modules/unbox-primitive": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
|
||||
|
@ -3464,6 +3470,11 @@
|
|||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/uWebSockets.js": {
|
||||
"version": "20.48.0",
|
||||
"resolved": "git+ssh://git@github.com/uNetworking/uWebSockets.js.git#51ae1d1fd92dff77cbbdc7c431021f85578da1a6",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/v8-compile-cache-lib": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
|
||||
|
|
|
@ -22,12 +22,11 @@
|
|||
"hsconsole": "^1.0.2",
|
||||
"mysql2": "^3.11.3",
|
||||
"simple-prom": "^1.0.1",
|
||||
"ws": "^8.16.0"
|
||||
"ultimate-ws": "^1.0.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/ejs": "^3.1.5",
|
||||
"@types/node": "^22.7.5",
|
||||
"@types/ws": "^8.5.12",
|
||||
"@vercel/ncc": "^0.38.2",
|
||||
"check-outdated": "^2.12.0",
|
||||
"nodemon": "^3.1.7",
|
||||
|
|
Loading…
Reference in a new issue