/** * Receives a Ping message. * * <p>A Ping message may be sent or received by either client or server. It may serve either as * a keepalive or as a means to verify that the remote endpoint is still responsive. * * <p>The message will consist of not more than {@code 125} bytes: {@code message.remaining() <= * 125}. * * <p>The {@code onPing} is invoked zero or more times in between {@code onOpen} and ({@code * onClose} or {@code onError}). * * <p>If an exception is thrown from this method or the returned {@code CompletionStage} * completes exceptionally, then {@link #onError(WebSocket, Throwable) onError} will be invoked * with this exception. * * @implNote * <p>Replies with a Pong message and requests one more message when the Pong has been sent. * @param webSocket the WebSocket * @param message the message * @return a CompletionStage that completes when the message processing is done; or {@code null} * if already done */ default CompletionStage<?> onPing(WebSocket webSocket, ByteBuffer message) { return webSocket.sendPong(message).thenRun(() -> webSocket.request(1)); }