const socketAuth = require("./middleware/authMiddleware");
const connectionHandler = require("./handlers/connectionHandler");
const inventoryHandler = require("./handlers/inventoryHandler");
const craftingHandler = require("./handlers/craftingHandler");
const adminHandler = require("./handlers/adminHandler");
const dungeonHandler = require("./handlers/dungeonHandler");
const chatHandler = require("./handlers/chatHandler");
const notificationHandler = require("./handlers/notificationHandler");
const socialHandler = require("./handlers/socialHandler");

const initSockets = (io) => {
  io.use(socketAuth);

  io.on("connection", (socket) => {
    connectionHandler(io, socket);
    inventoryHandler(io, socket);
    craftingHandler(io, socket);
    adminHandler(io, socket);
    dungeonHandler(io, socket);
    chatHandler(io, socket);
    socialHandler(io, socket);
    notificationHandler(io, socket);
  });
};

module.exports = initSockets;
