{"size": 568, "ext": "js", "max_stars_repo_path": "api/socket.io/validMail.js", "max_stars_repo_name": "fcampara/valid-mail", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "api/socket.io/validMail.js", "max_issues_repo_name": "fcampara/valid-mail", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "api/socket.io/validMail.js", "max_forks_repo_name": "fcampara/valid-mail", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.8181818182, "max_line_length": 83, "alphanum_fraction": 0.5176056338}
let connectedUsers = []
module.exports = {
  start: (io) => {
    io.of('/validMail').on('connect', (socket) => {
      socket.on('setUser', ({uid, name}) => {
        connectedUsers.push({
          uid: uid,
          name: name,
          socketId: socket.id
        })
      })
      socket.on('disconnect', () => {
        const index = connectedUsers.findIndex(user => user.socketId === socket.id)
        if (index > -1) connectedUsers.splice(index, 1)
      })
    })
  },
  getUserById: (id) => {
    return connectedUsers.find(user => user.uid === id)
  }
}
