mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-06-07 10:28:37 +00:00
19 lines
512 B
TypeScript
19 lines
512 B
TypeScript
import { WebSocketServer } from 'ws';
|
|
import { handleConnection } from './connectionManager';
|
|
import http from 'http';
|
|
import { getPort } from '../config';
|
|
import logger from '../utils/logger';
|
|
|
|
export const initServer = (
|
|
server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>,
|
|
) => {
|
|
const port = getPort();
|
|
const wss = new WebSocketServer({ server });
|
|
|
|
wss.on('connection', (ws) => {
|
|
handleConnection(ws);
|
|
});
|
|
|
|
logger.info(`WebSocket server started on port ${port}`);
|
|
};
|