@Override public void serverConnecting(RPCContext context) { handshakes++; int expected = getExpectedHandshakeCount(); if(expected > 0 && handshakes > expected){ throw new IllegalStateException("Expected number of Protocol negotiation handshakes exceeded expected "+expected+" was "+handshakes); } // check that a given client protocol is only sent once String clientProtocol = context.getHandshakeRequest().clientProtocol; if (clientProtocol != null) { assertFalse(seenProtocols.contains(clientProtocol)); seenProtocols.add(clientProtocol); } }