Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8159053

Improve onPing/onClose behavior

XMLWordPrintable

    • Verified

      onPing/onClose should be more robust and friendly while fully-compliant with the protocol

      (see the originating discussion here: http://mail.openjdk.java.net/pipermail/net-dev/2016-June/009875.html)

      1. Change `sendClose(CloseCode, CharSequence)` to `sendClose(int, CharSequence)`
      2. Remove `CloseCode`
      3. Make both `sendClose` methods idempotent
      4. Change `default void onClose(WebSocket webSocket, Optional<CloseCode> code, String reason) { }` to
      `default CompletionStage<?> onClose(WebSocket webSocket, int statusCode, String reason) { return null; }`
      5. Change `default CompletionStage<?> onPing(WebSocket webSocket, ByteBuffer message) {
                  return webSocket.sendPong(message).thenRun(() -> webSocket.request(1));
              }
      ` to `default CompletionStage<?> onPing(WebSocket webSocket, ByteBuffer message) {
                  return null;
              }`
      6. Specify one of the (onClose|onError) is always invoked. e.g. onClose(1006)

            prappo Pavel Rappo
            prappo Pavel Rappo
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: