Skip to content

Commit

Permalink
Minor WebSocket API improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Apr 10, 2024
1 parent a1444c5 commit ed0a09f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 32 deletions.
14 changes: 14 additions & 0 deletions src/main/java/io/vertx/core/http/ClientWebSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ default Future<WebSocket> connect(String requestURI) {
return connect(new WebSocketConnectOptions().setURI(requestURI));
}

@Override
ClientWebSocket pause();

@Override
default ClientWebSocket resume() {
return (ClientWebSocket) WebSocket.super.resume();
}

@Override
ClientWebSocket fetch(long amount);

@Override
ClientWebSocket setWriteQueueMaxSize(int maxSize);

@Override
ClientWebSocket handler(Handler<Buffer> handler);

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/io/vertx/core/http/ServerWebSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public interface ServerWebSocket extends WebSocket {
ServerWebSocket pause();

@Override
ServerWebSocket resume();
default ServerWebSocket resume() {
return (ServerWebSocket) WebSocket.super.resume();
}

@Override
ServerWebSocket fetch(long amount);
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/io/vertx/core/http/WebSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public interface WebSocket extends WebSocketBase {
WebSocket pause();

@Override
WebSocket resume();
default WebSocket resume() {
return fetch(Long.MAX_VALUE);
}

@Override
WebSocket fetch(long amount);
Expand Down
27 changes: 3 additions & 24 deletions src/main/java/io/vertx/core/http/impl/ClientWebSocketImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,6 @@ public Future<WebSocket> connect(WebSocketConnectOptions options) {
});
}

// @Override
// public Future<WebSocket> connect(String host, String requestURI) {
// return connect(client.options.getDefaultPort(), host, requestURI);
// }
//
// @Override
// public Future<WebSocket> connect(String requestURI) {
// return connect(client.options.getDefaultPort(), client.options.getDefaultHost(), requestURI);
// }
//
// @Override
// public Future<WebSocket> connect(String url, MultiMap headers, WebsocketVersion version, List<String> subProtocols) {
// return connect(HttpClientImpl.webSocketConnectOptionsAbs(url, headers, version, subProtocols));
// }

@Override
public ClientWebSocket exceptionHandler(Handler<Throwable> handler) {
exceptionHandler = handler;
Expand All @@ -111,19 +96,13 @@ public ClientWebSocket handler(Handler<Buffer> handler) {
}

@Override
public WebSocket pause() {
public ClientWebSocket pause() {
delegate().pause();
return this;
}

@Override
public WebSocket resume() {
delegate().resume();
return this;
}

@Override
public WebSocket fetch(long amount) {
public ClientWebSocket fetch(long amount) {
delegate().fetch(amount);
return this;
}
Expand All @@ -139,7 +118,7 @@ public ClientWebSocket endHandler(Handler<Void> handler) {
}

@Override
public WebSocket setWriteQueueMaxSize(int maxSize) {
public ClientWebSocket setWriteQueueMaxSize(int maxSize) {
delegate().setWriteQueueMaxSize(maxSize);
return this;
}
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/io/vertx/core/http/impl/WebSocketImplBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -739,12 +739,6 @@ public S pause() {
return (S) this;
}

@Override
public S resume() {
pending.resume();
return (S) this;
}

@Override
public S fetch(long amount) {
pending.fetch(amount);
Expand Down

0 comments on commit ed0a09f

Please sign in to comment.