code: protected String selectSubprotocol(String requestedSubprotocols) {
          if (requestedSubprotocols == null || subprotocols.length == 0) {
              return null;
          }
  
          String[] requestedSubprotocolArray = requestedSubprotocols.split(",");
          for (String p: requestedSubprotocolArray) {
              String requestedSubprotocol = p.trim();
  
              for (String supportedSubprotocol: subprotocols) {
                  if (SUB_PROTOCOL_WILDCARD.equals(supportedSubprotocol)
                          || requestedSubprotocol.equals(supportedSubprotocol)) {
                      selectedSubprotocol = requestedSubprotocol;
                      return requestedSubprotocol;
                  }
              }
          }
  
          // No match found
          return null;
      }
docs: Selects the first matching supported sub protocol
  
  @param requestedSubprotocols
  CSV of protocols to be supported. e.g. "chat, superchat"
  @return First matching supported sub protocol. Null if not found.