Issue #3298 - Refactor of upgrade request class names
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
f5751618bd
commit
b4bd5980aa
|
@ -18,20 +18,21 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.javax.client;
|
||||
|
||||
import org.eclipse.jetty.websocket.javax.common.UpgradeRequest;
|
||||
|
||||
import java.net.URI;
|
||||
import java.security.Principal;
|
||||
|
||||
import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.javax.common.UpgradeRequest;
|
||||
|
||||
/**
|
||||
* Representing the Jetty {@link org.eclipse.jetty.client.HttpClient}'s {@link org.eclipse.jetty.client.HttpRequest}
|
||||
* in the {@link UpgradeRequest} interface.
|
||||
*/
|
||||
public class DelegatedClientUpgradeRequest implements UpgradeRequest
|
||||
public class DelegatedJavaxClientUpgradeRequest implements UpgradeRequest
|
||||
{
|
||||
private final org.eclipse.jetty.websocket.core.client.UpgradeRequest delegate;
|
||||
private final ClientUpgradeRequest delegate;
|
||||
|
||||
public DelegatedClientUpgradeRequest(org.eclipse.jetty.websocket.core.client.UpgradeRequest delegate)
|
||||
public DelegatedJavaxClientUpgradeRequest(ClientUpgradeRequest delegate)
|
||||
{
|
||||
this.delegate = delegate;
|
||||
}
|
|
@ -18,24 +18,24 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.javax.client;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jetty.client.HttpResponse;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.websocket.core.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.javax.common.UpgradeResponse;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Representing the Jetty {@link org.eclipse.jetty.client.HttpClient}'s {@link HttpResponse}
|
||||
* in the {@link UpgradeResponse} interface.
|
||||
*/
|
||||
public class DelegatedClientUpgradeResponse implements UpgradeResponse
|
||||
public class DelegatedJavaxClientUpgradeResponse implements UpgradeResponse
|
||||
{
|
||||
private HttpResponse delegate;
|
||||
|
||||
public DelegatedClientUpgradeResponse(HttpResponse response)
|
||||
public DelegatedJavaxClientUpgradeResponse(HttpResponse response)
|
||||
{
|
||||
this.delegate = response;
|
||||
}
|
|
@ -18,24 +18,26 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.javax.client;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.websocket.Session;
|
||||
|
||||
import org.eclipse.jetty.client.HttpResponse;
|
||||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||
import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient;
|
||||
import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandler;
|
||||
import org.eclipse.jetty.websocket.javax.common.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.javax.common.UpgradeResponse;
|
||||
|
||||
import javax.websocket.Session;
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ClientUpgradeRequestImpl extends org.eclipse.jetty.websocket.core.client.UpgradeRequest
|
||||
public class JavaxClientUpgradeRequest extends ClientUpgradeRequest
|
||||
{
|
||||
private final JavaxWebSocketClientContainer containerContext;
|
||||
private final Object websocketPojo;
|
||||
private final CompletableFuture<Session> futureJavaxSession;
|
||||
|
||||
public ClientUpgradeRequestImpl(JavaxWebSocketClientContainer clientContainer, WebSocketCoreClient coreClient, URI requestURI, Object websocketPojo)
|
||||
public JavaxClientUpgradeRequest(JavaxWebSocketClientContainer clientContainer, WebSocketCoreClient coreClient, URI requestURI, Object websocketPojo)
|
||||
{
|
||||
super(coreClient, requestURI);
|
||||
this.containerContext = clientContainer;
|
||||
|
@ -53,8 +55,8 @@ public class ClientUpgradeRequestImpl extends org.eclipse.jetty.websocket.core.c
|
|||
@Override
|
||||
public FrameHandler getFrameHandler(WebSocketCoreClient coreClient, HttpResponse response)
|
||||
{
|
||||
UpgradeRequest upgradeRequest = new DelegatedClientUpgradeRequest(this);
|
||||
UpgradeResponse upgradeResponse = new DelegatedClientUpgradeResponse(response);
|
||||
UpgradeRequest upgradeRequest = new DelegatedJavaxClientUpgradeRequest(this);
|
||||
UpgradeResponse upgradeResponse = new DelegatedJavaxClientUpgradeResponse(response);
|
||||
|
||||
JavaxWebSocketFrameHandler frameHandler = containerContext.newFrameHandler(websocketPojo, upgradeRequest, upgradeResponse, futureJavaxSession);
|
||||
|
|
@ -125,7 +125,7 @@ public class JavaxWebSocketClientContainer extends JavaxWebSocketContainer imple
|
|||
* @param upgradeRequest the upgrade request information
|
||||
* @return the future for the session, available on success of connect
|
||||
*/
|
||||
private CompletableFuture<Session> connect(ClientUpgradeRequestImpl upgradeRequest)
|
||||
private CompletableFuture<Session> connect(JavaxClientUpgradeRequest upgradeRequest)
|
||||
{
|
||||
CompletableFuture<Session> fut = upgradeRequest.getFutureSession();
|
||||
try
|
||||
|
@ -145,7 +145,7 @@ public class JavaxWebSocketClientContainer extends JavaxWebSocketContainer imple
|
|||
Objects.requireNonNull(configuredEndpoint, "WebSocket configured endpoint cannot be null");
|
||||
Objects.requireNonNull(destURI, "Destination URI cannot be null");
|
||||
|
||||
ClientUpgradeRequestImpl upgradeRequest = new ClientUpgradeRequestImpl(this, getWebSocketCoreClient(), destURI, configuredEndpoint);
|
||||
JavaxClientUpgradeRequest upgradeRequest = new JavaxClientUpgradeRequest(this, getWebSocketCoreClient(), destURI, configuredEndpoint);
|
||||
|
||||
EndpointConfig config = configuredEndpoint.getConfig();
|
||||
if (config != null && config instanceof ClientEndpointConfig)
|
||||
|
|
|
@ -18,19 +18,20 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.javax.common;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry;
|
||||
|
||||
import javax.websocket.Extension;
|
||||
import javax.websocket.Session;
|
||||
import javax.websocket.WebSocketContainer;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.websocket.Extension;
|
||||
import javax.websocket.Session;
|
||||
import javax.websocket.WebSocketContainer;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry;
|
||||
|
||||
public abstract class JavaxWebSocketContainer extends ContainerLifeCycle implements javax.websocket.WebSocketContainer
|
||||
{
|
||||
private long defaultAsyncSendTimeout = -1;
|
||||
|
@ -105,7 +106,7 @@ public abstract class JavaxWebSocketContainer extends ContainerLifeCycle impleme
|
|||
public JavaxWebSocketFrameHandler newFrameHandler(Object websocketPojo, UpgradeRequest upgradeRequest, UpgradeResponse upgradeResponse,
|
||||
CompletableFuture<Session> futureSession)
|
||||
{
|
||||
return getFrameHandlerFactory().newJavaxFrameHandler(websocketPojo, upgradeRequest, upgradeResponse, futureSession);
|
||||
return getFrameHandlerFactory().newJavaxWebSocketFrameHandler(websocketPojo, upgradeRequest, upgradeResponse, futureSession);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,6 +18,32 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.javax.common;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.websocket.CloseReason;
|
||||
import javax.websocket.Decoder;
|
||||
import javax.websocket.EndpointConfig;
|
||||
import javax.websocket.OnClose;
|
||||
import javax.websocket.OnError;
|
||||
import javax.websocket.OnMessage;
|
||||
import javax.websocket.OnOpen;
|
||||
import javax.websocket.PongMessage;
|
||||
import javax.websocket.Session;
|
||||
|
||||
import org.eclipse.jetty.http.pathmap.UriTemplatePathSpec;
|
||||
import org.eclipse.jetty.websocket.javax.common.decoders.AvailableDecoders;
|
||||
import org.eclipse.jetty.websocket.javax.common.messages.ByteArrayMessageSink;
|
||||
|
@ -37,31 +63,6 @@ import org.eclipse.jetty.websocket.javax.common.util.InvalidSignatureException;
|
|||
import org.eclipse.jetty.websocket.javax.common.util.InvokerUtils;
|
||||
import org.eclipse.jetty.websocket.javax.common.util.ReflectUtils;
|
||||
|
||||
import javax.websocket.CloseReason;
|
||||
import javax.websocket.Decoder;
|
||||
import javax.websocket.EndpointConfig;
|
||||
import javax.websocket.OnClose;
|
||||
import javax.websocket.OnError;
|
||||
import javax.websocket.OnMessage;
|
||||
import javax.websocket.OnOpen;
|
||||
import javax.websocket.PongMessage;
|
||||
import javax.websocket.Session;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerMetadata.MessageMetadata;
|
||||
|
||||
|
@ -107,8 +108,9 @@ public abstract class JavaxWebSocketFrameHandlerFactory
|
|||
|
||||
public abstract JavaxWebSocketFrameHandlerMetadata createMetadata(Class<?> endpointClass, EndpointConfig endpointConfig);
|
||||
|
||||
public JavaxWebSocketFrameHandler newJavaxFrameHandler(Object endpointInstance, UpgradeRequest upgradeRequest, UpgradeResponse upgradeResponse,
|
||||
CompletableFuture<Session> futureSession)
|
||||
public JavaxWebSocketFrameHandler newJavaxWebSocketFrameHandler(Object endpointInstance, UpgradeRequest upgradeRequest,
|
||||
UpgradeResponse upgradeResponse,
|
||||
CompletableFuture<Session> futureSession)
|
||||
{
|
||||
Object endpoint;
|
||||
EndpointConfig config;
|
||||
|
|
|
@ -69,7 +69,7 @@ public abstract class AbstractJavaxWebSocketFrameHandlerTest
|
|||
UpgradeRequest upgradeRequest = new UpgradeRequestAdapter();
|
||||
UpgradeResponse upgradeResponse = new UpgradeResponseAdapter();
|
||||
|
||||
JavaxWebSocketFrameHandler localEndpoint = factory.newJavaxFrameHandler(endpoint,
|
||||
JavaxWebSocketFrameHandler localEndpoint = factory.newJavaxWebSocketFrameHandler(endpoint,
|
||||
upgradeRequest, upgradeResponse, new CompletableFuture<>());
|
||||
|
||||
return localEndpoint;
|
||||
|
|
|
@ -18,23 +18,24 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.javax.server;
|
||||
|
||||
import org.eclipse.jetty.http.pathmap.UriTemplatePathSpec;
|
||||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||
import org.eclipse.jetty.websocket.javax.server.internal.PathParamIdentifier;
|
||||
import org.eclipse.jetty.websocket.javax.server.internal.UpgradeRequestAdapter;
|
||||
import org.eclipse.jetty.websocket.javax.server.internal.UpgradeResponseAdapter;
|
||||
import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketContainer;
|
||||
import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerFactory;
|
||||
import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerMetadata;
|
||||
import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.servlet.FrameHandlerFactory;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.websocket.Endpoint;
|
||||
import javax.websocket.EndpointConfig;
|
||||
import javax.websocket.Session;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.eclipse.jetty.http.pathmap.UriTemplatePathSpec;
|
||||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||
import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketContainer;
|
||||
import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerFactory;
|
||||
import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerMetadata;
|
||||
import org.eclipse.jetty.websocket.javax.server.internal.DelegatedJavaxServletUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.javax.server.internal.PathParamIdentifier;
|
||||
import org.eclipse.jetty.websocket.javax.server.internal.UpgradeResponseAdapter;
|
||||
import org.eclipse.jetty.websocket.servlet.FrameHandlerFactory;
|
||||
import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse;
|
||||
|
||||
public class JavaxWebSocketServerFrameHandlerFactory extends JavaxWebSocketFrameHandlerFactory implements FrameHandlerFactory
|
||||
{
|
||||
|
@ -68,6 +69,6 @@ public class JavaxWebSocketServerFrameHandlerFactory extends JavaxWebSocketFrame
|
|||
public FrameHandler newFrameHandler(Object websocketPojo, ServletUpgradeRequest upgradeRequest, ServletUpgradeResponse upgradeResponse)
|
||||
{
|
||||
CompletableFuture<Session> completableFuture = new CompletableFuture<>();
|
||||
return newJavaxFrameHandler(websocketPojo, new UpgradeRequestAdapter(upgradeRequest), new UpgradeResponseAdapter(upgradeResponse), completableFuture);
|
||||
return newJavaxWebSocketFrameHandler(websocketPojo, new DelegatedJavaxServletUpgradeRequest(upgradeRequest), new UpgradeResponseAdapter(upgradeResponse), completableFuture);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,17 +18,17 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.javax.server.internal;
|
||||
|
||||
import org.eclipse.jetty.websocket.javax.common.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
|
||||
|
||||
import java.net.URI;
|
||||
import java.security.Principal;
|
||||
|
||||
public class UpgradeRequestAdapter implements UpgradeRequest
|
||||
import org.eclipse.jetty.websocket.javax.common.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
|
||||
|
||||
public class DelegatedJavaxServletUpgradeRequest implements UpgradeRequest
|
||||
{
|
||||
private final ServletUpgradeRequest servletRequest;
|
||||
|
||||
public UpgradeRequestAdapter(ServletUpgradeRequest servletRequest)
|
||||
public DelegatedJavaxServletUpgradeRequest(ServletUpgradeRequest servletRequest)
|
||||
{
|
||||
this.servletRequest = servletRequest;
|
||||
}
|
|
@ -38,7 +38,7 @@ import org.eclipse.jetty.websocket.core.Behavior;
|
|||
import org.eclipse.jetty.websocket.core.CloseStatus;
|
||||
import org.eclipse.jetty.websocket.core.Frame;
|
||||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||
import org.eclipse.jetty.websocket.core.client.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient;
|
||||
import org.eclipse.jetty.websocket.core.internal.Generator;
|
||||
|
||||
|
@ -184,7 +184,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab
|
|||
}
|
||||
}
|
||||
|
||||
public static class RawUpgradeRequest extends UpgradeRequest
|
||||
public static class RawUpgradeRequest extends ClientUpgradeRequest
|
||||
{
|
||||
private final CompletableFuture<FrameCapture> futureCapture;
|
||||
private EndPoint endPoint;
|
||||
|
|
|
@ -84,7 +84,7 @@ public class SessionAddMessageHandlerTest
|
|||
|
||||
JavaxWebSocketFrameHandlerFactory frameHandlerFactory = new JavaxWebSocketClientFrameHandlerFactory(container);
|
||||
CompletableFuture<Session> futureSession = new CompletableFuture<>();
|
||||
frameHandler = frameHandlerFactory.newJavaxFrameHandler(ei, handshakeRequest, handshakeResponse, futureSession);
|
||||
frameHandler = frameHandlerFactory.newJavaxWebSocketFrameHandler(ei, handshakeRequest, handshakeResponse, futureSession);
|
||||
frameHandler.onOpen(new FrameHandler.CoreSession.Empty(), Callback.NOOP);
|
||||
|
||||
// Session
|
||||
|
|
|
@ -18,37 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.javax.tests.server;
|
||||
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.core.Frame;
|
||||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||
import org.eclipse.jetty.websocket.core.OpCode;
|
||||
import org.eclipse.jetty.websocket.core.client.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient;
|
||||
import org.eclipse.jetty.websocket.javax.server.internal.JavaxWebSocketCreator;
|
||||
import org.eclipse.jetty.websocket.javax.tests.LocalServer;
|
||||
import org.eclipse.jetty.websocket.javax.tests.Timeouts;
|
||||
import org.eclipse.jetty.websocket.javax.tests.framehandlers.FrameHandlerTracker;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.websocket.DecodeException;
|
||||
import javax.websocket.Decoder;
|
||||
import javax.websocket.EndpointConfig;
|
||||
import javax.websocket.Extension;
|
||||
import javax.websocket.HandshakeResponse;
|
||||
import javax.websocket.OnMessage;
|
||||
import javax.websocket.Session;
|
||||
import javax.websocket.server.HandshakeRequest;
|
||||
import javax.websocket.server.ServerContainer;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import javax.websocket.server.ServerEndpointConfig;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.net.InetSocketAddress;
|
||||
|
@ -69,6 +38,38 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.websocket.DecodeException;
|
||||
import javax.websocket.Decoder;
|
||||
import javax.websocket.EndpointConfig;
|
||||
import javax.websocket.Extension;
|
||||
import javax.websocket.HandshakeResponse;
|
||||
import javax.websocket.OnMessage;
|
||||
import javax.websocket.Session;
|
||||
import javax.websocket.server.HandshakeRequest;
|
||||
import javax.websocket.server.ServerContainer;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import javax.websocket.server.ServerEndpointConfig;
|
||||
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.core.Frame;
|
||||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||
import org.eclipse.jetty.websocket.core.OpCode;
|
||||
import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient;
|
||||
import org.eclipse.jetty.websocket.javax.server.internal.JavaxWebSocketCreator;
|
||||
import org.eclipse.jetty.websocket.javax.tests.LocalServer;
|
||||
import org.eclipse.jetty.websocket.javax.tests.Timeouts;
|
||||
import org.eclipse.jetty.websocket.javax.tests.framehandlers.FrameHandlerTracker;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
|
@ -430,7 +431,7 @@ public class ConfiguratorTest
|
|||
URI wsUri = server.getWsUri().resolve("/capture-request-headers");
|
||||
|
||||
FrameHandlerTracker clientSocket = new FrameHandlerTracker();
|
||||
UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket);
|
||||
ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket);
|
||||
upgradeRequest.addExtensions("identity");
|
||||
Future<FrameHandler.CoreSession> clientConnectFuture = client.connect(upgradeRequest);
|
||||
|
||||
|
@ -454,7 +455,7 @@ public class ConfiguratorTest
|
|||
URI wsUri = server.getWsUri().resolve("/no-extensions");
|
||||
|
||||
FrameHandlerTracker clientSocket = new FrameHandlerTracker();
|
||||
UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket);
|
||||
ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket);
|
||||
upgradeRequest.addExtensions("identity");
|
||||
Future<FrameHandler.CoreSession> clientConnectFuture = client.connect(upgradeRequest);
|
||||
|
||||
|
@ -478,7 +479,7 @@ public class ConfiguratorTest
|
|||
URI wsUri = server.getWsUri().resolve("/capture-request-headers");
|
||||
|
||||
FrameHandlerTracker clientSocket = new FrameHandlerTracker();
|
||||
UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket);
|
||||
ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket);
|
||||
upgradeRequest.header("X-Dummy", "Bogus");
|
||||
Future<FrameHandler.CoreSession> clientConnectFuture = client.connect(upgradeRequest);
|
||||
|
||||
|
@ -503,7 +504,7 @@ public class ConfiguratorTest
|
|||
|
||||
// First Request
|
||||
FrameHandlerTracker clientSocket = new FrameHandlerTracker();
|
||||
UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket);
|
||||
ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket);
|
||||
Future<FrameHandler.CoreSession> clientConnectFuture = client.connect(upgradeRequest);
|
||||
|
||||
FrameHandler.CoreSession channel = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS);
|
||||
|
@ -522,7 +523,7 @@ public class ConfiguratorTest
|
|||
|
||||
// Second request
|
||||
clientSocket = new FrameHandlerTracker();
|
||||
upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket);
|
||||
upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket);
|
||||
clientConnectFuture = client.connect(upgradeRequest);
|
||||
|
||||
channel = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS);
|
||||
|
@ -550,7 +551,7 @@ public class ConfiguratorTest
|
|||
URI wsUri = server.getWsUri().resolve("/addr");
|
||||
|
||||
FrameHandlerTracker clientSocket = new FrameHandlerTracker();
|
||||
UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket);
|
||||
ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket);
|
||||
Future<FrameHandler.CoreSession> clientConnectFuture = client.connect(upgradeRequest);
|
||||
|
||||
FrameHandler.CoreSession channel = clientConnectFuture.get(Timeouts.CONNECT_MS, TimeUnit.MILLISECONDS);
|
||||
|
@ -591,7 +592,7 @@ public class ConfiguratorTest
|
|||
ProtocolsConfigurator.seenProtocols.set(null);
|
||||
|
||||
FrameHandlerTracker clientSocket = new FrameHandlerTracker();
|
||||
UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket);
|
||||
ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket);
|
||||
upgradeRequest.setSubProtocols("status");
|
||||
Future<FrameHandler.CoreSession> clientConnectFuture = client.connect(upgradeRequest);
|
||||
|
||||
|
@ -610,7 +611,7 @@ public class ConfiguratorTest
|
|||
ProtocolsConfigurator.seenProtocols.set(null);
|
||||
|
||||
FrameHandlerTracker clientSocket = new FrameHandlerTracker();
|
||||
UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket);
|
||||
ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket);
|
||||
upgradeRequest.setSubProtocols("echo", "chat", "status");
|
||||
Future<FrameHandler.CoreSession> clientConnectFuture = client.connect(upgradeRequest);
|
||||
|
||||
|
@ -629,7 +630,7 @@ public class ConfiguratorTest
|
|||
ProtocolsConfigurator.seenProtocols.set(null);
|
||||
|
||||
FrameHandlerTracker clientSocket = new FrameHandlerTracker();
|
||||
UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket);
|
||||
ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket);
|
||||
upgradeRequest.header("sec-websocket-protocol", "echo, chat, status");
|
||||
Future<FrameHandler.CoreSession> clientConnectFuture = client.connect(upgradeRequest);
|
||||
|
||||
|
@ -648,7 +649,7 @@ public class ConfiguratorTest
|
|||
ProtocolsConfigurator.seenProtocols.set(null);
|
||||
|
||||
FrameHandlerTracker clientSocket = new FrameHandlerTracker();
|
||||
UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket);
|
||||
ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket);
|
||||
// header name is not to spec (case wise)
|
||||
upgradeRequest.header("Sec-Websocket-Protocol", "echo, chat, status");
|
||||
Future<FrameHandler.CoreSession> clientConnectFuture = client.connect(upgradeRequest);
|
||||
|
@ -682,7 +683,7 @@ public class ConfiguratorTest
|
|||
URI wsUri = server.getWsUri().resolve("/timedecoder");
|
||||
|
||||
FrameHandlerTracker clientSocket = new FrameHandlerTracker();
|
||||
UpgradeRequest upgradeRequest = UpgradeRequest.from(client, wsUri, clientSocket);
|
||||
ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, wsUri, clientSocket);
|
||||
upgradeRequest.setSubProtocols("gmt");
|
||||
Future<FrameHandler.CoreSession> clientConnectFuture = client.connect(upgradeRequest);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.eclipse.jetty.websocket.api.UpgradeRequest;
|
|||
import org.eclipse.jetty.websocket.api.UpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketBehavior;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
import org.eclipse.jetty.websocket.client.impl.ClientUpgradeRequestImpl;
|
||||
import org.eclipse.jetty.websocket.client.impl.JettyClientUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandler;
|
||||
import org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandlerFactory;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry;
|
||||
|
@ -107,7 +107,7 @@ public class WebSocketClient extends ContainerLifeCycle implements WebSocketPoli
|
|||
*/
|
||||
public CompletableFuture<Session> connect(Object websocket, URI toUri, UpgradeRequest request) throws IOException
|
||||
{
|
||||
ClientUpgradeRequestImpl upgradeRequest = new ClientUpgradeRequestImpl(this, coreClient, request, toUri, websocket);
|
||||
JettyClientUpgradeRequest upgradeRequest = new JettyClientUpgradeRequest(this, coreClient, request, toUri, websocket);
|
||||
coreClient.connect(upgradeRequest);
|
||||
return upgradeRequest.getFutureSession();
|
||||
}
|
||||
|
|
|
@ -18,14 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.client.impl;
|
||||
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.util.MultiMap;
|
||||
import org.eclipse.jetty.util.UrlEncoded;
|
||||
import org.eclipse.jetty.websocket.api.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
|
||||
import java.net.HttpCookie;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.URI;
|
||||
|
@ -35,19 +27,28 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.util.MultiMap;
|
||||
import org.eclipse.jetty.util.UrlEncoded;
|
||||
import org.eclipse.jetty.websocket.api.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
/**
|
||||
* Representing the Jetty {@link org.eclipse.jetty.client.HttpClient}'s {@link org.eclipse.jetty.client.HttpRequest}
|
||||
* in the {@link UpgradeRequest} interface.
|
||||
*/
|
||||
public class DelegatedClientUpgradeRequest implements UpgradeRequest
|
||||
public class DelegatedJettyClientUpgradeRequest implements UpgradeRequest
|
||||
{
|
||||
private final org.eclipse.jetty.websocket.core.client.UpgradeRequest delegate;
|
||||
private final ClientUpgradeRequest delegate;
|
||||
private SocketAddress localSocketAddress;
|
||||
private SocketAddress remoteSocketAddress;
|
||||
|
||||
public DelegatedClientUpgradeRequest(org.eclipse.jetty.websocket.core.client.UpgradeRequest delegate)
|
||||
public DelegatedJettyClientUpgradeRequest(ClientUpgradeRequest delegate)
|
||||
{
|
||||
this.delegate = delegate;
|
||||
}
|
|
@ -18,11 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.client.impl;
|
||||
|
||||
import org.eclipse.jetty.client.HttpResponse;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.websocket.api.UpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -30,15 +25,20 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jetty.client.HttpResponse;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.websocket.api.UpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
|
||||
/**
|
||||
* Representing the Jetty {@link org.eclipse.jetty.client.HttpClient}'s {@link org.eclipse.jetty.client.HttpResponse}
|
||||
* in the {@link UpgradeResponse} interface.
|
||||
*/
|
||||
public class DelegatedClientUpgradeResponse implements UpgradeResponse
|
||||
public class DelegatedJettyClientUpgradeResponse implements UpgradeResponse
|
||||
{
|
||||
private HttpResponse delegate;
|
||||
|
||||
public DelegatedClientUpgradeResponse(HttpResponse response)
|
||||
public DelegatedJettyClientUpgradeResponse(HttpResponse response)
|
||||
{
|
||||
this.delegate = response;
|
||||
}
|
|
@ -18,34 +18,35 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.client.impl;
|
||||
|
||||
import java.net.HttpCookie;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.eclipse.jetty.client.HttpResponse;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
import org.eclipse.jetty.websocket.api.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.api.UpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.client.WebSocketClient;
|
||||
import org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandler;
|
||||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||
import org.eclipse.jetty.websocket.core.client.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient;
|
||||
|
||||
import java.net.HttpCookie;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ClientUpgradeRequestImpl extends UpgradeRequest
|
||||
public class JettyClientUpgradeRequest extends ClientUpgradeRequest
|
||||
{
|
||||
private final WebSocketClient containerContext;
|
||||
private final Object websocketPojo;
|
||||
private final CompletableFuture<Session> onOpenFuture;
|
||||
private final CompletableFuture<Session> futureSession;
|
||||
private final DelegatedClientUpgradeRequest handshakeRequest;
|
||||
private final DelegatedJettyClientUpgradeRequest handshakeRequest;
|
||||
|
||||
public ClientUpgradeRequestImpl(WebSocketClient clientContainer, WebSocketCoreClient coreClient, org.eclipse.jetty.websocket.api.UpgradeRequest request,
|
||||
URI requestURI, Object websocketPojo)
|
||||
public JettyClientUpgradeRequest(WebSocketClient clientContainer, WebSocketCoreClient coreClient, UpgradeRequest request,
|
||||
URI requestURI, Object websocketPojo)
|
||||
{
|
||||
super(coreClient, requestURI);
|
||||
this.containerContext = clientContainer;
|
||||
|
@ -89,7 +90,7 @@ public class ClientUpgradeRequestImpl extends UpgradeRequest
|
|||
version(HttpVersion.fromString(request.getHttpVersion()));
|
||||
}
|
||||
|
||||
handshakeRequest = new DelegatedClientUpgradeRequest(this);
|
||||
handshakeRequest = new DelegatedJettyClientUpgradeRequest(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,7 +109,7 @@ public class ClientUpgradeRequestImpl extends UpgradeRequest
|
|||
@Override
|
||||
public FrameHandler getFrameHandler(WebSocketCoreClient coreClient, HttpResponse response)
|
||||
{
|
||||
UpgradeResponse upgradeResponse = new DelegatedClientUpgradeResponse(response);
|
||||
UpgradeResponse upgradeResponse = new DelegatedJettyClientUpgradeResponse(response);
|
||||
|
||||
JettyWebSocketFrameHandler frameHandler = containerContext.newFrameHandler(websocketPojo,
|
||||
handshakeRequest, upgradeResponse, onOpenFuture);
|
|
@ -29,7 +29,7 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
|
|||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandlerFactory;
|
||||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||
import org.eclipse.jetty.websocket.server.internal.UpgradeRequestAdapter;
|
||||
import org.eclipse.jetty.websocket.server.internal.DelegatedJettyServletUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.server.internal.UpgradeResponseAdapter;
|
||||
import org.eclipse.jetty.websocket.servlet.FrameHandlerFactory;
|
||||
import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
|
||||
|
@ -67,7 +67,7 @@ public class JettyServerFrameHandlerFactory
|
|||
@Override
|
||||
public FrameHandler newFrameHandler(Object websocketPojo, ServletUpgradeRequest upgradeRequest, ServletUpgradeResponse upgradeResponse)
|
||||
{
|
||||
return super.newJettyFrameHandler(websocketPojo, new UpgradeRequestAdapter(upgradeRequest), new UpgradeResponseAdapter(upgradeResponse),
|
||||
return super.newJettyFrameHandler(websocketPojo, new DelegatedJettyServletUpgradeRequest(upgradeRequest), new UpgradeResponseAdapter(upgradeResponse),
|
||||
new CompletableFuture<>());
|
||||
}
|
||||
|
||||
|
|
|
@ -18,10 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.server.internal;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
|
||||
|
||||
import java.net.HttpCookie;
|
||||
import java.net.URI;
|
||||
import java.security.Principal;
|
||||
|
@ -29,11 +25,15 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class UpgradeRequestAdapter implements UpgradeRequest
|
||||
import org.eclipse.jetty.websocket.api.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
|
||||
|
||||
public class DelegatedJettyServletUpgradeRequest implements UpgradeRequest
|
||||
{
|
||||
private final ServletUpgradeRequest servletRequest;
|
||||
|
||||
public UpgradeRequestAdapter(ServletUpgradeRequest servletRequest)
|
||||
public DelegatedJettyServletUpgradeRequest(ServletUpgradeRequest servletRequest)
|
||||
{
|
||||
this.servletRequest = servletRequest;
|
||||
}
|
|
@ -27,7 +27,7 @@ import java.util.Map;
|
|||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.websocket.core.client.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.core.server.Negotiation;
|
||||
|
||||
/**
|
||||
|
@ -42,8 +42,8 @@ import org.eclipse.jetty.websocket.core.server.Negotiation;
|
|||
* <li>On the server, the application layer must provide a {@link org.eclipse.jetty.websocket.core.server.WebSocketNegotiator} instance
|
||||
* to negotiate and accept websocket connections, which will return the FrameHandler instance to use from
|
||||
* {@link org.eclipse.jetty.websocket.core.server.WebSocketNegotiator#negotiate(Negotiation)}.</li>
|
||||
* <li>On the client, the application returns the FrameHandler instance to user from the {@link UpgradeRequest}
|
||||
* instance that it passes to the {@link org.eclipse.jetty.websocket.core.client.WebSocketCoreClient#connect(UpgradeRequest)} method/</li>
|
||||
* <li>On the client, the application returns the FrameHandler instance to user from the {@link ClientUpgradeRequest}
|
||||
* instance that it passes to the {@link org.eclipse.jetty.websocket.core.client.WebSocketCoreClient#connect(ClientUpgradeRequest)} method/</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Once instantiated the FrameHandler follows is used as follows:
|
||||
|
|
|
@ -64,11 +64,11 @@ import org.eclipse.jetty.websocket.core.internal.WebSocketChannel;
|
|||
import org.eclipse.jetty.websocket.core.internal.WebSocketConnection;
|
||||
import org.eclipse.jetty.websocket.core.internal.WebSocketCore;
|
||||
|
||||
public abstract class UpgradeRequest extends HttpRequest implements Response.CompleteListener, HttpConnectionUpgrader
|
||||
public abstract class ClientUpgradeRequest extends HttpRequest implements Response.CompleteListener, HttpConnectionUpgrader
|
||||
{
|
||||
public static UpgradeRequest from(WebSocketCoreClient webSocketClient, URI requestURI, FrameHandler frameHandler)
|
||||
public static ClientUpgradeRequest from(WebSocketCoreClient webSocketClient, URI requestURI, FrameHandler frameHandler)
|
||||
{
|
||||
return new UpgradeRequest(webSocketClient, requestURI)
|
||||
return new ClientUpgradeRequest(webSocketClient, requestURI)
|
||||
{
|
||||
@Override
|
||||
public FrameHandler getFrameHandler(WebSocketCoreClient coreClient, HttpResponse response)
|
||||
|
@ -78,7 +78,7 @@ public abstract class UpgradeRequest extends HttpRequest implements Response.Com
|
|||
};
|
||||
}
|
||||
|
||||
private static final Logger LOG = Log.getLogger(UpgradeRequest.class);
|
||||
private static final Logger LOG = Log.getLogger(ClientUpgradeRequest.class);
|
||||
protected final CompletableFuture<FrameHandler.CoreSession> futureCoreSession;
|
||||
private final WebSocketCoreClient wsClient;
|
||||
private List<UpgradeListener> upgradeListeners = new ArrayList<>();
|
||||
|
@ -91,7 +91,7 @@ public abstract class UpgradeRequest extends HttpRequest implements Response.Com
|
|||
*/
|
||||
private List<String> subProtocols = new ArrayList<>();
|
||||
|
||||
public UpgradeRequest(WebSocketCoreClient webSocketClient, URI requestURI)
|
||||
public ClientUpgradeRequest(WebSocketCoreClient webSocketClient, URI requestURI)
|
||||
{
|
||||
super(webSocketClient.getHttpClient(), new HttpConversation(), requestURI);
|
||||
|
|
@ -83,11 +83,11 @@ public class WebSocketCoreClient extends ContainerLifeCycle implements FrameHand
|
|||
|
||||
public CompletableFuture<FrameHandler.CoreSession> connect(FrameHandler frameHandler, URI wsUri) throws IOException
|
||||
{
|
||||
UpgradeRequest request = UpgradeRequest.from(this, wsUri, frameHandler);
|
||||
ClientUpgradeRequest request = ClientUpgradeRequest.from(this, wsUri, frameHandler);
|
||||
return connect(request);
|
||||
}
|
||||
|
||||
public CompletableFuture<FrameHandler.CoreSession> connect(UpgradeRequest request) throws IOException
|
||||
public CompletableFuture<FrameHandler.CoreSession> connect(ClientUpgradeRequest request) throws IOException
|
||||
{
|
||||
if (!isStarted())
|
||||
{
|
||||
|
|
|
@ -18,13 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.core.chat;
|
||||
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.core.MessageHandler;
|
||||
import org.eclipse.jetty.websocket.core.client.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URI;
|
||||
|
@ -34,6 +27,13 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.core.MessageHandler;
|
||||
import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient;
|
||||
|
||||
public class ChatWebSocketClient
|
||||
{
|
||||
private static Logger LOG = Log.getLogger(ChatWebSocketClient.class);
|
||||
|
@ -51,7 +51,7 @@ public class ChatWebSocketClient
|
|||
|
||||
URI wsUri = baseWebsocketUri.resolve("/chat");
|
||||
handler = MessageHandler.from(this::onText, null);
|
||||
UpgradeRequest request = UpgradeRequest.from(client, wsUri, handler);
|
||||
ClientUpgradeRequest request = ClientUpgradeRequest.from(client, wsUri, handler);
|
||||
request.setSubProtocols("chat");
|
||||
client.connect(request).get(5, TimeUnit.SECONDS);
|
||||
handler.sendText("[" + name + ": has joined the room]", Callback.NOOP, false);
|
||||
|
|
|
@ -179,7 +179,7 @@ public class WebSocketClientServerTest
|
|||
|
||||
public void start() throws Exception
|
||||
{
|
||||
UpgradeRequest request = UpgradeRequest.from(client, baseWebSocketUri.resolve("/test"), handler);
|
||||
ClientUpgradeRequest request = ClientUpgradeRequest.from(client, baseWebSocketUri.resolve("/test"), handler);
|
||||
request.setSubProtocols("test");
|
||||
this.client.start();
|
||||
Future<FrameHandler.CoreSession> response = client.connect(request);
|
||||
|
|
Loading…
Reference in New Issue