isUserAlive = (room, user) =>
  new Promise((resolve, reject) => {
    let timeoutId = setTimeout(() => {
      timeoutId = null;
      room.removeSocket(user);
      reject();
    }, SOCKET_ALIVE_PONG_TIMEOUT);

    user.socket.on('pong', () => {
      if (timeoutId === null) return;

      clearTimeout(timeoutId);
      resolve();
    });

    log(
      `Checking if ${user.name} is alive. Someone with same name is trying to join`
    );
    user.socket.ping();
  })
Checks if a user's socket is active by sending a PING and
anticipating a PONG response within SOCKET_ALIVE_PONG_TIMEOUT
seconds from the user.

@param {string} room Room name
@param {Socket} user User socket to check if it is active
@returns {Promise} Promise that resolves if user is active otherwise rejects