From 5ee9c2b338be3f82953014ff4a93132bcc091212 Mon Sep 17 00:00:00 2001 From: Reto Brunner Date: Sun, 7 Apr 2024 14:17:32 +0200 Subject: [PATCH] type Server --- server/clientManager.ts | 2 +- server/server.ts | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/server/clientManager.ts b/server/clientManager.ts index baf3625c..fcda360b 100644 --- a/server/clientManager.ts +++ b/server/clientManager.ts @@ -10,7 +10,7 @@ import Config from "./config"; import {NetworkConfig} from "./models/network"; import WebPush from "./plugins/webpush"; import log from "./log"; -import {Server} from "socket.io"; +import {Server} from "./server"; class ClientManager { clients: Client[]; diff --git a/server/server.ts b/server/server.ts index cb6b4f0a..b0c6f9ce 100644 --- a/server/server.ts +++ b/server/server.ts @@ -3,7 +3,7 @@ import {Server as wsServer} from "ws"; import express, {NextFunction, Request, Response} from "express"; import fs from "fs"; import path from "path"; -import {Server, Socket as ioSocket} from "socket.io"; +import {Server as ioServer, Socket as ioSocket} from "socket.io"; import dns from "dns"; import colors from "chalk"; import net from "net"; @@ -52,6 +52,12 @@ type IndexTemplateConfiguration = ServerConfiguration & { }; type Socket = ioSocket; +export type Server = ioServer< + ClientToServerEvents, + ServerToClientEvents, + InterServerEvents, + SocketData +>; // A random number that will force clients to reload the page if it differs const serverHash = Math.floor(Date.now() * Math.random()); @@ -211,12 +217,7 @@ export default async function ( return; } - const sockets = new Server< - ClientToServerEvents, - ServerToClientEvents, - InterServerEvents, - SocketData - >(server, { + const sockets: Server = new ioServer(server, { wsEngine: wsServer, cookie: false, serveClient: false,