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)
(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)
- relates to
-
JDK-8087113 Websocket API and implementation
- Closed