code: function isSocketConnected(socket) {
         return socket && (
              (socket.socket && socket.socket.connected) || socket.connected
          );
      }
docs: This function checks if a socket is actually connected.
  @private
  @param {Object} socket a socket.io socket.
  @return true if the socket exists and is connected, false otherwise.