code: protected static String selectSubprotocol(String requestedSubprotocols, String[] supportedSubProtocols) {
          if (requestedSubprotocols == null || supportedSubProtocols.length == 0) {
              return null;
          }
  
          String[] requestedSubprotocolArray = requestedSubprotocols.split(",");
  
          for (String p: requestedSubprotocolArray) {
              String requestedSubprotocol = p.trim();
  
              for (String supportedSubprotocol: supportedSubProtocols) {
                  if (WebSocketServerHandshaker.SUB_PROTOCOL_WILDCARD.equals(supportedSubprotocol)
                      || requestedSubprotocol.equals(supportedSubprotocol)) {
                      return requestedSubprotocol;
                  }
              }
          }
  
          // No match found
          return null;
      }
docs: <b>This is copied from {@link WebSocketServerHandshaker}</b>
  
  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.