code: function addListeners(socket, serverSpec) {
          var apiBase = serverSpec.signallingApiBase;
          var disposeFunction = disposeOfSocket(apiBase);
          var registerFunction = register(socket);
  
          // Register if we connect
          socket.on("connect", registerFunction);
  
          // Dispose if we disconnect/fail to connect/error
          socket.io.on("connect_error", disposeFunction);
          socket.on("error", disposeFunction);
          socket.on("disconnect", disposeFunction);
  
          /**
           * Emit offers/answers when they're received
           */
          socket.on("answer", emitAnswer);
          socket.on("offer", emitOffer);
          socket.on("candidates", emitCandidates);
      }
docs: Add listeners for a socket
  
  @param socket
  @param serverSpec