From ba62599fb9b06088cdffc2c65e66ab0c1c92983f Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 1 Jun 2024 00:23:12 +0530 Subject: [PATCH] feat: --- server/src/socket-connection/connection.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 server/src/socket-connection/connection.ts diff --git a/server/src/socket-connection/connection.ts b/server/src/socket-connection/connection.ts new file mode 100644 index 00000000..672e2b54 --- /dev/null +++ b/server/src/socket-connection/connection.ts @@ -0,0 +1,16 @@ +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); +}; +