import { Server } from "socket.io";

let io;

export function initSocketServer(server) {
    if (!io) {
        io = new Server(server);

        io.on('connection', (socket) => {
            console.log('Client connected');

            socket.on('disconnect', () => {
                console.log('Client disconnected');
            });
        });
    }
}

export function notifyClients(event, data) {
    if (io) {
        io.emit(event, data);
    }
}