Files
parcer/server/src/socket-connection/connection.ts
karishmas6 ba62599fb9 feat:
2024-06-01 00:23:12 +05:30

17 lines
472 B
TypeScript

import {Namespace, Socket} from 'socket.io';
import logger from "../logger";
export const createSocketConnection = (
io: Namespace,
callback: (socket: Socket) => void,
) => {
const onConnection = async (socket: Socket) => {
logger.log('info',"Client connected " + socket.id);
socket.on('disconnect', () => logger.log('info', "Client disconnected " + socket.id));
callback(socket);
}
io.on('connection', onConnection);
};