add support for WebSocket UpgradeListeners for jetty WebSocketClient
Signed-off-by: lachan-roberts <lachlan@webtide.com>
This commit is contained in:
parent
39d122a9fb
commit
ddb75984d1
|
@ -50,6 +50,7 @@ import org.eclipse.jetty.websocket.common.SessionTracker;
|
|||
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
|
||||
|
@ -117,8 +118,24 @@ public class WebSocketClient extends ContainerLifeCycle implements WebSocketPoli
|
|||
* @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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue