{"size": 608, "ext": "js", "max_stars_repo_path": "utilities/socket.js", "max_stars_repo_name": "ghanem-mhd/studious-enigma", "max_stars_repo_stars_event_min_datetime": "2021-03-19T12:47:16.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-05T14:36:50.000Z", "max_issues_repo_path": "utilities/socket.js", "max_issues_repo_name": "ghanem-mhd/master-thesis-implementation", "max_issues_repo_issues_event_min_datetime": "2020-07-07T16:03:12.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-07T16:03:18.000Z", "max_forks_repo_path": "utilities/socket.js", "max_forks_repo_name": "ghanem-mhd/studious-enigma", "max_forks_repo_forks_event_min_datetime": "2021-03-29T10:06:35.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-10T21:54:32.000Z"}
{"max_stars_count": 5, "max_issues_count": 2, "max_forks_count": 2, "avg_line_length": 21.7142857143, "max_line_length": 57, "alphanum_fraction": 0.5493421053}
const Logger = require("./logger");

let io;

module.exports = {
  init: function (server) {
    io = require("socket.io").listen(server);
    io.origins("*:*");
    io.on("connection", (socket) => {
      var sessionID = socket.id;
      Logger.info(`${sessionID} connected on socket io`);
      socket.join("stream_log");
      socket.join("machines_state");
      socket.join("data_from_mqtt");
      socket.on("disconnect", () => {
        Logger.info(`${sessionID} disconnect`);
      });
    });
    return io;
  },
  getIO: function () {
    if (!io) {
      return null;
    }
    return io;
  },
};
