fix(build): tighten TypeScript compatibility and update project build configuration
This commit is contained in:
@@ -11,8 +11,8 @@ import { logger } from './smartsocket.logging.js';
|
||||
*/
|
||||
export class SocketServer {
|
||||
private smartsocket: Smartsocket;
|
||||
private httpServer: pluginsTyped.http.Server | pluginsTyped.https.Server;
|
||||
private wsServer: pluginsTyped.ws.WebSocketServer;
|
||||
private httpServer: pluginsTyped.http.Server | pluginsTyped.https.Server | null = null;
|
||||
private wsServer: pluginsTyped.ws.WebSocketServer | null = null;
|
||||
|
||||
/**
|
||||
* whether httpServer is standalone (created by us)
|
||||
@@ -38,17 +38,19 @@ export class SocketServer {
|
||||
const httpModule = await this.smartsocket.smartenv.getSafeNodeModule('http');
|
||||
const wsModule = await this.smartsocket.smartenv.getSafeNodeModule('ws');
|
||||
|
||||
this.httpServer = httpModule.createServer();
|
||||
const httpServer = httpModule.createServer();
|
||||
this.httpServer = httpServer;
|
||||
this.standaloneServer = true;
|
||||
|
||||
// Create WebSocket server attached to HTTP server
|
||||
this.wsServer = new wsModule.WebSocketServer({ server: this.httpServer });
|
||||
const wsServer = new wsModule.WebSocketServer({ server: httpServer });
|
||||
this.wsServer = wsServer;
|
||||
|
||||
this.wsServer.on('connection', (ws: pluginsTyped.ws.WebSocket) => {
|
||||
wsServer.on('connection', (ws: pluginsTyped.ws.WebSocket) => {
|
||||
this.smartsocket.handleNewConnection(ws);
|
||||
});
|
||||
|
||||
this.httpServer.listen(this.smartsocket.options.port, () => {
|
||||
httpServer.listen(this.smartsocket.options.port, () => {
|
||||
logger.log(
|
||||
'success',
|
||||
`Server started in standalone mode on port ${this.smartsocket.options.port}`
|
||||
|
||||
Reference in New Issue
Block a user