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); +}; +