Skip to content

Commit

Permalink
Merge pull request #3414 from lachlan-roberts/jetty-10.0.x-UpgradeLis…
Browse files Browse the repository at this point in the history
…tener

add support for WebSocket UpgradeListeners in WebSocketClient
  • Loading branch information
gregw authored Mar 4, 2019
2 parents 715bac2 + ddb7598 commit ec28eb6
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.eclipse.jetty.websocket.common.WebSocketContainer;
import org.eclipse.jetty.websocket.common.WebSocketSessionListener;
import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry;
import org.eclipse.jetty.websocket.core.client.UpgradeListener;
import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient;

public class WebSocketClient extends ContainerLifeCycle implements WebSocketPolicy, WebSocketContainer
Expand Down Expand Up @@ -117,8 +118,24 @@ public CompletableFuture<Session> connect(Object websocket, URI toUri) throws IO
* @throws IOException if unable to connect
*/
public CompletableFuture<Session> connect(Object websocket, URI toUri, UpgradeRequest request) throws IOException
{
return connect(websocket, toUri, request, null);
}

/**
* Connect to remote websocket endpoint
*
* @param websocket the websocket object
* @param toUri the websocket uri to connect to
* @param request the upgrade request information
* @param listener the upgrade listener
* @return the future for the session, available on success of connect
* @throws IOException if unable to connect
*/
public CompletableFuture<Session> connect(Object websocket, URI toUri, UpgradeRequest request, UpgradeListener listener) throws IOException
{
JettyClientUpgradeRequest upgradeRequest = new JettyClientUpgradeRequest(this, coreClient, request, toUri, websocket);
upgradeRequest.addListener(listener);
coreClient.connect(upgradeRequest);
return upgradeRequest.getFutureSession();
}
Expand Down

0 comments on commit ec28eb6

Please sign in to comment.