prefer the field and variable name of coreSession instead of session
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
491ff5eb93
commit
f4990dd0f5
|
@ -51,7 +51,7 @@ public abstract class AbstractJavaxWebSocketFrameHandlerTest
|
||||||
protected AvailableDecoders decoders;
|
protected AvailableDecoders decoders;
|
||||||
protected Map<String, String> uriParams;
|
protected Map<String, String> uriParams;
|
||||||
protected EndpointConfig endpointConfig;
|
protected EndpointConfig endpointConfig;
|
||||||
protected FrameHandler.CoreSession session = new FrameHandler.CoreSession.Empty();
|
protected FrameHandler.CoreSession coreSession = new FrameHandler.CoreSession.Empty();
|
||||||
|
|
||||||
public AbstractJavaxWebSocketFrameHandlerTest()
|
public AbstractJavaxWebSocketFrameHandlerTest()
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class JavaxWebSocketFrameHandler_OnCloseTest extends AbstractJavaxWebSock
|
||||||
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
|
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
|
||||||
|
|
||||||
// These invocations are the same for all tests
|
// These invocations are the same for all tests
|
||||||
localEndpoint.onOpen(session, Callback.NOOP);
|
localEndpoint.onOpen(coreSession, Callback.NOOP);
|
||||||
CloseStatus status = new CloseStatus(CloseStatus.NORMAL, "Normal");
|
CloseStatus status = new CloseStatus(CloseStatus.NORMAL, "Normal");
|
||||||
Frame closeFrame = status.toFrame();
|
Frame closeFrame = status.toFrame();
|
||||||
localEndpoint.onFrame(closeFrame, Callback.from(() ->
|
localEndpoint.onFrame(closeFrame, Callback.from(() ->
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class JavaxWebSocketFrameHandler_OnErrorTest extends AbstractJavaxWebSock
|
||||||
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
|
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
|
||||||
|
|
||||||
// These invocations are the same for all tests
|
// These invocations are the same for all tests
|
||||||
localEndpoint.onOpen(session, Callback.NOOP);
|
localEndpoint.onOpen(coreSession, Callback.NOOP);
|
||||||
localEndpoint.onError(new RuntimeException("From Testcase"), Callback.NOOP);
|
localEndpoint.onError(new RuntimeException("From Testcase"), Callback.NOOP);
|
||||||
String event = socket.events.poll(1, TimeUnit.SECONDS);
|
String event = socket.events.poll(1, TimeUnit.SECONDS);
|
||||||
assertThat("Event", event, eventMatcher);
|
assertThat("Event", event, eventMatcher);
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class JavaxWebSocketFrameHandler_OnMessage_BinaryStreamTest extends Abstr
|
||||||
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
|
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
|
||||||
|
|
||||||
// This invocation is the same for all tests
|
// This invocation is the same for all tests
|
||||||
localEndpoint.onOpen(session, Callback.NOOP);
|
localEndpoint.onOpen(coreSession, Callback.NOOP);
|
||||||
|
|
||||||
func.apply(localEndpoint);
|
func.apply(localEndpoint);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class JavaxWebSocketFrameHandler_OnMessage_BinaryTest extends AbstractJav
|
||||||
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
|
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
|
||||||
|
|
||||||
// This invocation is the same for all tests
|
// This invocation is the same for all tests
|
||||||
localEndpoint.onOpen(session, Callback.NOOP);
|
localEndpoint.onOpen(coreSession, Callback.NOOP);
|
||||||
|
|
||||||
assertThat("Has Binary Metadata", localEndpoint.getBinaryMetadata(), notNullValue());
|
assertThat("Has Binary Metadata", localEndpoint.getBinaryMetadata(), notNullValue());
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class JavaxWebSocketFrameHandler_OnMessage_TextStreamTest extends Abstrac
|
||||||
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
|
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
|
||||||
|
|
||||||
// This invocation is the same for all tests
|
// This invocation is the same for all tests
|
||||||
localEndpoint.onOpen(session, Callback.NOOP);
|
localEndpoint.onOpen(coreSession, Callback.NOOP);
|
||||||
|
|
||||||
func.apply(localEndpoint);
|
func.apply(localEndpoint);
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class JavaxWebSocketFrameHandler_OnMessage_TextTest extends AbstractJavax
|
||||||
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
|
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
|
||||||
|
|
||||||
// This invocation is the same for all tests
|
// This invocation is the same for all tests
|
||||||
localEndpoint.onOpen(session, Callback.NOOP);
|
localEndpoint.onOpen(coreSession, Callback.NOOP);
|
||||||
|
|
||||||
ByteBuffer payload = BufferUtil.toBuffer(msg, StandardCharsets.UTF_8);
|
ByteBuffer payload = BufferUtil.toBuffer(msg, StandardCharsets.UTF_8);
|
||||||
localEndpoint.onFrame(new Frame(OpCode.TEXT).setPayload(payload).setFin(true), Callback.NOOP);
|
localEndpoint.onFrame(new Frame(OpCode.TEXT).setPayload(payload).setFin(true), Callback.NOOP);
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class JavaxWebSocketFrameHandler_OnOpenTest extends AbstractJavaxWebSocke
|
||||||
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
|
JavaxWebSocketFrameHandler localEndpoint = newJavaxFrameHandler(socket);
|
||||||
|
|
||||||
// This invocation is the same for all tests
|
// This invocation is the same for all tests
|
||||||
localEndpoint.onOpen(session, Callback.NOOP);
|
localEndpoint.onOpen(coreSession, Callback.NOOP);
|
||||||
String event = socket.events.poll(1, TimeUnit.SECONDS);
|
String event = socket.events.poll(1, TimeUnit.SECONDS);
|
||||||
assertThat("Event", event, eventMatcher);
|
assertThat("Event", event, eventMatcher);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,11 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.websocket.javax.tests;
|
package org.eclipse.jetty.websocket.javax.tests;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
import org.eclipse.jetty.io.ByteBufferPool;
|
import org.eclipse.jetty.io.ByteBufferPool;
|
||||||
import org.eclipse.jetty.io.MappedByteBufferPool;
|
import org.eclipse.jetty.io.MappedByteBufferPool;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
|
@ -35,11 +40,6 @@ import org.eclipse.jetty.websocket.core.server.WebSocketUpgradeHandler;
|
||||||
import org.eclipse.jetty.websocket.javax.tests.framehandlers.FrameEcho;
|
import org.eclipse.jetty.websocket.javax.tests.framehandlers.FrameEcho;
|
||||||
import org.eclipse.jetty.websocket.javax.tests.framehandlers.WholeMessageEcho;
|
import org.eclipse.jetty.websocket.javax.tests.framehandlers.WholeMessageEcho;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public class CoreServer extends ContainerLifeCycle
|
public class CoreServer extends ContainerLifeCycle
|
||||||
{
|
{
|
||||||
private Server server;
|
private Server server;
|
||||||
|
@ -121,7 +121,7 @@ public class CoreServer extends ContainerLifeCycle
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(FrameHandler.CoreSession session)
|
public void customize(FrameHandler.CoreSession coreSession)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ public class CoreServer extends ContainerLifeCycle
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(FrameHandler.CoreSession session)
|
public void customize(FrameHandler.CoreSession coreSession)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab
|
||||||
{
|
{
|
||||||
try (SharedBlockingCallback.Blocker blocker = sharedBlockingCallback.acquire())
|
try (SharedBlockingCallback.Blocker blocker = sharedBlockingCallback.acquire())
|
||||||
{
|
{
|
||||||
frameCapture.session.sendFrame(f, blocker, false);
|
frameCapture.coreSession.sendFrame(f, blocker, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab
|
||||||
{
|
{
|
||||||
try (SharedBlockingCallback.Blocker blocker = sharedBlockingCallback.acquire())
|
try (SharedBlockingCallback.Blocker blocker = sharedBlockingCallback.acquire())
|
||||||
{
|
{
|
||||||
frameCapture.session.sendFrame(f, blocker, false);
|
frameCapture.coreSession.sendFrame(f, blocker, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab
|
||||||
private final BlockingQueue<Frame> receivedFrames = new LinkedBlockingQueue<>();
|
private final BlockingQueue<Frame> receivedFrames = new LinkedBlockingQueue<>();
|
||||||
private final EndPoint endPoint;
|
private final EndPoint endPoint;
|
||||||
private final SharedBlockingCallback blockingCallback = new SharedBlockingCallback();
|
private final SharedBlockingCallback blockingCallback = new SharedBlockingCallback();
|
||||||
private CoreSession session;
|
private CoreSession coreSession;
|
||||||
|
|
||||||
public FrameCapture(EndPoint endPoint)
|
public FrameCapture(EndPoint endPoint)
|
||||||
{
|
{
|
||||||
|
@ -233,7 +233,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab
|
||||||
@Override
|
@Override
|
||||||
public void onOpen(CoreSession coreSession, Callback callback)
|
public void onOpen(CoreSession coreSession, Callback callback)
|
||||||
{
|
{
|
||||||
this.session = coreSession;
|
this.coreSession = coreSession;
|
||||||
callback.succeeded();
|
callback.succeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public abstract class AbstractExtension implements Extension
|
||||||
private ExtensionConfig config;
|
private ExtensionConfig config;
|
||||||
private OutgoingFrames nextOutgoing;
|
private OutgoingFrames nextOutgoing;
|
||||||
private IncomingFrames nextIncoming;
|
private IncomingFrames nextIncoming;
|
||||||
private WebSocketCoreSession session;
|
private WebSocketCoreSession coreSession;
|
||||||
|
|
||||||
public AbstractExtension()
|
public AbstractExtension()
|
||||||
{
|
{
|
||||||
|
@ -141,14 +141,14 @@ public abstract class AbstractExtension implements Extension
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setWebSocketCoreSession(WebSocketCoreSession webSocketCoreSession)
|
public void setWebSocketCoreSession(WebSocketCoreSession coreSession)
|
||||||
{
|
{
|
||||||
session = webSocketCoreSession;
|
this.coreSession = coreSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WebSocketCoreSession getWebSocketCoreSession()
|
protected WebSocketCoreSession getWebSocketCoreSession()
|
||||||
{
|
{
|
||||||
return session;
|
return coreSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -91,7 +91,7 @@ public interface Extension extends IncomingFrames, OutgoingFrames
|
||||||
/**
|
/**
|
||||||
* Set the {@link WebSocketCoreSession} for this Extension
|
* Set the {@link WebSocketCoreSession} for this Extension
|
||||||
*
|
*
|
||||||
* @param webSocketCoreSession
|
* @param coreSession
|
||||||
*/
|
*/
|
||||||
void setWebSocketCoreSession(WebSocketCoreSession webSocketCoreSession);
|
void setWebSocketCoreSession(WebSocketCoreSession coreSession);
|
||||||
}
|
}
|
||||||
|
|
|
@ -516,7 +516,7 @@ public interface FrameHandler extends IncomingFrames
|
||||||
|
|
||||||
interface Customizer
|
interface Customizer
|
||||||
{
|
{
|
||||||
void customize(CoreSession session);
|
void customize(CoreSession coreSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConfigurationCustomizer implements Customizer, Configuration
|
class ConfigurationCustomizer implements Customizer, Configuration
|
||||||
|
@ -627,24 +627,24 @@ public interface FrameHandler extends IncomingFrames
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(CoreSession session)
|
public void customize(CoreSession coreSession)
|
||||||
{
|
{
|
||||||
if (idleTimeout !=null)
|
if (idleTimeout !=null)
|
||||||
session.setIdleTimeout(idleTimeout);
|
coreSession.setIdleTimeout(idleTimeout);
|
||||||
if (writeTimeout!=null)
|
if (writeTimeout!=null)
|
||||||
session.setWriteTimeout(idleTimeout);
|
coreSession.setWriteTimeout(idleTimeout);
|
||||||
if (autoFragment!=null)
|
if (autoFragment!=null)
|
||||||
session.setAutoFragment(autoFragment);
|
coreSession.setAutoFragment(autoFragment);
|
||||||
if (maxFrameSize!=null)
|
if (maxFrameSize!=null)
|
||||||
session.setMaxFrameSize(maxFrameSize);
|
coreSession.setMaxFrameSize(maxFrameSize);
|
||||||
if (inputBufferSize!=null)
|
if (inputBufferSize!=null)
|
||||||
session.setInputBufferSize(inputBufferSize);
|
coreSession.setInputBufferSize(inputBufferSize);
|
||||||
if (outputBufferSize!=null)
|
if (outputBufferSize!=null)
|
||||||
session.setOutputBufferSize(outputBufferSize);
|
coreSession.setOutputBufferSize(outputBufferSize);
|
||||||
if (maxBinaryMessageSize!=null)
|
if (maxBinaryMessageSize!=null)
|
||||||
session.setMaxBinaryMessageSize(maxBinaryMessageSize);
|
coreSession.setMaxBinaryMessageSize(maxBinaryMessageSize);
|
||||||
if (maxTextMessageSize!=null)
|
if (maxTextMessageSize!=null)
|
||||||
session.setMaxTextMessageSize(maxTextMessageSize);
|
coreSession.setMaxTextMessageSize(maxTextMessageSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -347,15 +347,15 @@ public abstract class ClientUpgradeRequest extends HttpRequest implements Respon
|
||||||
extensionStack,
|
extensionStack,
|
||||||
WebSocketConstants.SPEC_VERSION_STRING);
|
WebSocketConstants.SPEC_VERSION_STRING);
|
||||||
|
|
||||||
WebSocketCoreSession wsSession = newWebSocketCoreSession(frameHandler, negotiated);
|
WebSocketCoreSession coreSession = newWebSocketCoreSession(frameHandler, negotiated);
|
||||||
wsClient.customize(wsSession);
|
wsClient.customize(coreSession);
|
||||||
|
|
||||||
WebSocketConnection wsConnection = newWebSocketConnection(endp, httpClient.getExecutor(), httpClient.getScheduler(), httpClient.getByteBufferPool(), wsSession);
|
WebSocketConnection wsConnection = newWebSocketConnection(endp, httpClient.getExecutor(), httpClient.getScheduler(), httpClient.getByteBufferPool(), coreSession);
|
||||||
|
|
||||||
for (Connection.Listener listener : wsClient.getBeans(Connection.Listener.class))
|
for (Connection.Listener listener : wsClient.getBeans(Connection.Listener.class))
|
||||||
wsConnection.addListener(listener);
|
wsConnection.addListener(listener);
|
||||||
|
|
||||||
wsSession.setWebSocketConnection(wsConnection);
|
coreSession.setWebSocketConnection(wsConnection);
|
||||||
|
|
||||||
notifyUpgradeListeners((listener) -> listener.onHandshakeResponse(this, response));
|
notifyUpgradeListeners((listener) -> listener.onHandshakeResponse(this, response));
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ public abstract class ClientUpgradeRequest extends HttpRequest implements Respon
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
endp.upgrade(wsConnection);
|
endp.upgrade(wsConnection);
|
||||||
futureCoreSession.complete(wsSession);
|
futureCoreSession.complete(coreSession);
|
||||||
}
|
}
|
||||||
catch (Throwable t)
|
catch (Throwable t)
|
||||||
{
|
{
|
||||||
|
@ -380,9 +380,9 @@ public abstract class ClientUpgradeRequest extends HttpRequest implements Respon
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WebSocketConnection newWebSocketConnection(EndPoint endp, Executor executor, Scheduler scheduler, ByteBufferPool byteBufferPool, WebSocketCoreSession wsCoreSession)
|
protected WebSocketConnection newWebSocketConnection(EndPoint endp, Executor executor, Scheduler scheduler, ByteBufferPool byteBufferPool, WebSocketCoreSession coreSession)
|
||||||
{
|
{
|
||||||
return new WebSocketConnection(endp, executor, scheduler, byteBufferPool, wsCoreSession);
|
return new WebSocketConnection(endp, executor, scheduler, byteBufferPool, coreSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WebSocketCoreSession newWebSocketCoreSession(FrameHandler handler, Negotiated negotiated)
|
protected WebSocketCoreSession newWebSocketCoreSession(FrameHandler handler, Negotiated negotiated)
|
||||||
|
|
|
@ -72,10 +72,10 @@ public class WebSocketCoreClient extends ContainerLifeCycle implements FrameHand
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(FrameHandler.CoreSession session)
|
public void customize(FrameHandler.CoreSession coreSession)
|
||||||
{
|
{
|
||||||
if (customizer != null)
|
if (customizer != null)
|
||||||
customizer.customize(session);
|
customizer.customize(coreSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<FrameHandler.CoreSession> connect(FrameHandler frameHandler, URI wsUri) throws IOException
|
public CompletableFuture<FrameHandler.CoreSession> connect(FrameHandler frameHandler, URI wsUri) throws IOException
|
||||||
|
|
|
@ -243,7 +243,7 @@ public class ExtensionStack implements IncomingFrames, OutgoingFrames, Dumpable
|
||||||
outgoing.sendFrame(frame, callback, batch);
|
outgoing.sendFrame(frame, callback, batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize(IncomingFrames incoming, OutgoingFrames outgoing, WebSocketCoreSession webSocketCoreSession)
|
public void initialize(IncomingFrames incoming, OutgoingFrames outgoing, WebSocketCoreSession coreSession)
|
||||||
{
|
{
|
||||||
if (extensions == null)
|
if (extensions == null)
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
|
@ -259,7 +259,7 @@ public class ExtensionStack implements IncomingFrames, OutgoingFrames, Dumpable
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Extension extension : extensions)
|
for (Extension extension : extensions)
|
||||||
extension.setWebSocketCoreSession(webSocketCoreSession);
|
extension.setWebSocketCoreSession(coreSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
|
||||||
private final ByteBufferPool bufferPool;
|
private final ByteBufferPool bufferPool;
|
||||||
private final Generator generator;
|
private final Generator generator;
|
||||||
private final Parser parser;
|
private final Parser parser;
|
||||||
private final WebSocketCoreSession session;
|
private final WebSocketCoreSession coreSession;
|
||||||
|
|
||||||
private final Flusher flusher;
|
private final Flusher flusher;
|
||||||
private final Random random;
|
private final Random random;
|
||||||
|
@ -110,7 +110,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
|
||||||
|
|
||||||
this.bufferPool = bufferPool;
|
this.bufferPool = bufferPool;
|
||||||
|
|
||||||
this.session = coreSession;
|
this.coreSession = coreSession;
|
||||||
|
|
||||||
this.generator = new Generator(bufferPool);
|
this.generator = new Generator(bufferPool);
|
||||||
this.parser = new Parser(bufferPool, coreSession.isAutoFragment())
|
this.parser = new Parser(bufferPool, coreSession.isAutoFragment())
|
||||||
|
@ -128,7 +128,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
|
||||||
this.flusher = new Flusher(scheduler, coreSession.getOutputBufferSize(), generator, endp);
|
this.flusher = new Flusher(scheduler, coreSession.getOutputBufferSize(), generator, endp);
|
||||||
this.setInputBufferSize(coreSession.getInputBufferSize());
|
this.setInputBufferSize(coreSession.getInputBufferSize());
|
||||||
|
|
||||||
this.random = this.session.getBehavior() == Behavior.CLIENT?new Random(endp.hashCode()):null;
|
this.random = this.coreSession.getBehavior() == Behavior.CLIENT?new Random(endp.hashCode()):null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -173,8 +173,8 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("onClose() of physical connection");
|
LOG.debug("onClose() of physical connection");
|
||||||
|
|
||||||
if (!session.isClosed())
|
if (!coreSession.isClosed())
|
||||||
session.onEof();
|
coreSession.onEof();
|
||||||
flusher.onClose(cause);
|
flusher.onClose(cause);
|
||||||
super.onClose(cause);
|
super.onClose(cause);
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
|
||||||
LOG.debug("onIdleExpired()");
|
LOG.debug("onIdleExpired()");
|
||||||
|
|
||||||
// treat as a handler error because socket is still open
|
// treat as a handler error because socket is still open
|
||||||
session.processHandlerError(new WebSocketTimeoutException("Connection Idle Timeout"),Callback.NOOP);
|
coreSession.processHandlerError(new WebSocketTimeoutException("Connection Idle Timeout"),Callback.NOOP);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
|
||||||
LOG.debug("onReadTimeout()");
|
LOG.debug("onReadTimeout()");
|
||||||
|
|
||||||
// treat as a handler error because socket is still open
|
// treat as a handler error because socket is still open
|
||||||
session.processHandlerError(new WebSocketTimeoutException("Timeout on Read", timeout),Callback.NOOP);
|
coreSession.processHandlerError(new WebSocketTimeoutException("Timeout on Read", timeout),Callback.NOOP);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
|
||||||
if (referenced != null)
|
if (referenced != null)
|
||||||
referenced.retain();
|
referenced.retain();
|
||||||
|
|
||||||
session.onFrame(frame, new Callback()
|
coreSession.onFrame(frame, new Callback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void succeeded()
|
public void succeeded()
|
||||||
|
@ -228,7 +228,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
|
||||||
if (referenced != null)
|
if (referenced != null)
|
||||||
referenced.release();
|
referenced.release();
|
||||||
|
|
||||||
if (!session.isDemanding())
|
if (!coreSession.isDemanding())
|
||||||
demand(1);
|
demand(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
|
||||||
referenced.release();
|
referenced.release();
|
||||||
|
|
||||||
// notify session & endpoint
|
// notify session & endpoint
|
||||||
session.processHandlerError(cause,NOOP);
|
coreSession.processHandlerError(cause,NOOP);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
|
||||||
if (filled < 0)
|
if (filled < 0)
|
||||||
{
|
{
|
||||||
releaseNetworkBuffer();
|
releaseNetworkBuffer();
|
||||||
session.onEof();
|
coreSession.onEof();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,7 +454,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
|
||||||
LOG.warn(t.toString());
|
LOG.warn(t.toString());
|
||||||
BufferUtil.clear(networkBuffer.getBuffer());
|
BufferUtil.clear(networkBuffer.getBuffer());
|
||||||
releaseNetworkBuffer();
|
releaseNetworkBuffer();
|
||||||
session.processConnectionError(t,Callback.NOOP);
|
coreSession.processConnectionError(t,Callback.NOOP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,7 +496,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
|
||||||
|
|
||||||
// Open Session
|
// Open Session
|
||||||
super.onOpen();
|
super.onOpen();
|
||||||
session.onOpen();
|
coreSession.onOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -527,7 +527,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
|
||||||
return String.format("%s@%x[%s,p=%s,f=%s,g=%s]",
|
return String.format("%s@%x[%s,p=%s,f=%s,g=%s]",
|
||||||
getClass().getSimpleName(),
|
getClass().getSimpleName(),
|
||||||
hashCode(),
|
hashCode(),
|
||||||
session.getBehavior(),
|
coreSession.getBehavior(),
|
||||||
parser,
|
parser,
|
||||||
flusher,
|
flusher,
|
||||||
generator);
|
generator);
|
||||||
|
@ -586,7 +586,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
|
||||||
*/
|
*/
|
||||||
void enqueueFrame(Frame frame, Callback callback, boolean batch)
|
void enqueueFrame(Frame frame, Callback callback, boolean batch)
|
||||||
{
|
{
|
||||||
if (session.getBehavior() == Behavior.CLIENT)
|
if (coreSession.getBehavior() == Behavior.CLIENT)
|
||||||
{
|
{
|
||||||
byte[] mask = new byte[4];
|
byte[] mask = new byte[4];
|
||||||
random.nextBytes(mask);
|
random.nextBytes(mask);
|
||||||
|
@ -607,7 +607,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio
|
||||||
@Override
|
@Override
|
||||||
public void onCompleteFailure(Throwable x)
|
public void onCompleteFailure(Throwable x)
|
||||||
{
|
{
|
||||||
session.processConnectionError(x, NOOP);
|
coreSession.processConnectionError(x, NOOP);
|
||||||
super.onCompleteFailure(x);
|
super.onCompleteFailure(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,9 +101,9 @@ public abstract class CompressExtension extends AbstractExtension
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setWebSocketCoreSession(WebSocketCoreSession webSocketCoreSession)
|
public void setWebSocketCoreSession(WebSocketCoreSession coreSession)
|
||||||
{
|
{
|
||||||
super.setWebSocketCoreSession(webSocketCoreSession);
|
super.setWebSocketCoreSession(coreSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Deflater getDeflater()
|
public Deflater getDeflater()
|
||||||
|
|
|
@ -18,14 +18,14 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.websocket.core.server;
|
package org.eclipse.jetty.websocket.core.server;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
import org.eclipse.jetty.io.ByteBufferPool;
|
import org.eclipse.jetty.io.ByteBufferPool;
|
||||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||||
import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry;
|
import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public interface WebSocketNegotiator extends FrameHandler.Customizer
|
public interface WebSocketNegotiator extends FrameHandler.Customizer
|
||||||
{
|
{
|
||||||
FrameHandler negotiate(Negotiation negotiation) throws IOException;
|
FrameHandler negotiate(Negotiation negotiation) throws IOException;
|
||||||
|
@ -102,10 +102,10 @@ public interface WebSocketNegotiator extends FrameHandler.Customizer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(FrameHandler.CoreSession session)
|
public void customize(FrameHandler.CoreSession coreSession)
|
||||||
{
|
{
|
||||||
if (customizer != null)
|
if (customizer != null)
|
||||||
customizer.customize(session);
|
customizer.customize(coreSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -193,16 +193,16 @@ public final class RFC6455Handshaker implements Handshaker
|
||||||
WebSocketConstants.SPEC_VERSION_STRING);
|
WebSocketConstants.SPEC_VERSION_STRING);
|
||||||
|
|
||||||
// Create the Session
|
// Create the Session
|
||||||
WebSocketCoreSession session = newWebSocketCoreSession(handler, negotiated);
|
WebSocketCoreSession coreSession = newWebSocketCoreSession(handler, negotiated);
|
||||||
if (defaultCustomizer!=null)
|
if (defaultCustomizer!=null)
|
||||||
defaultCustomizer.customize(session);
|
defaultCustomizer.customize(coreSession);
|
||||||
negotiator.customize(session);
|
negotiator.customize(coreSession);
|
||||||
|
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("session {}", session);
|
LOG.debug("session {}", coreSession);
|
||||||
|
|
||||||
// Create a connection
|
// Create a connection
|
||||||
WebSocketConnection connection = newWebSocketConnection(httpChannel.getEndPoint(), connector.getExecutor(), connector.getScheduler(), connector.getByteBufferPool(), session);
|
WebSocketConnection connection = newWebSocketConnection(httpChannel.getEndPoint(), connector.getExecutor(), connector.getScheduler(), connector.getByteBufferPool(), coreSession);
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("connection {}", connection);
|
LOG.debug("connection {}", connection);
|
||||||
if (connection == null)
|
if (connection == null)
|
||||||
|
@ -211,7 +211,7 @@ public final class RFC6455Handshaker implements Handshaker
|
||||||
for (Connection.Listener listener : connector.getBeans(Connection.Listener.class))
|
for (Connection.Listener listener : connector.getBeans(Connection.Listener.class))
|
||||||
connection.addListener(listener);
|
connection.addListener(listener);
|
||||||
|
|
||||||
session.setWebSocketConnection(connection);
|
coreSession.setWebSocketConnection(connection);
|
||||||
|
|
||||||
// send upgrade response
|
// send upgrade response
|
||||||
Response baseResponse = baseRequest.getResponse();
|
Response baseResponse = baseRequest.getResponse();
|
||||||
|
@ -231,7 +231,7 @@ public final class RFC6455Handshaker implements Handshaker
|
||||||
|
|
||||||
// upgrade
|
// upgrade
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("upgrade connection={} session={}", connection, session);
|
LOG.debug("upgrade connection={} session={}", connection, coreSession);
|
||||||
|
|
||||||
baseRequest.setAttribute(HttpConnection.UPGRADE_CONNECTION_ATTRIBUTE, connection);
|
baseRequest.setAttribute(HttpConnection.UPGRADE_CONNECTION_ATTRIBUTE, connection);
|
||||||
return true;
|
return true;
|
||||||
|
@ -242,9 +242,9 @@ public final class RFC6455Handshaker implements Handshaker
|
||||||
return new WebSocketCoreSession(handler, Behavior.SERVER, negotiated);
|
return new WebSocketCoreSession(handler, Behavior.SERVER, negotiated);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WebSocketConnection newWebSocketConnection(EndPoint endPoint, Executor executor, Scheduler scheduler, ByteBufferPool byteBufferPool, WebSocketCoreSession wsCoreSession)
|
protected WebSocketConnection newWebSocketConnection(EndPoint endPoint, Executor executor, Scheduler scheduler, ByteBufferPool byteBufferPool, WebSocketCoreSession coreSession)
|
||||||
{
|
{
|
||||||
return new WebSocketConnection(endPoint, executor, scheduler, byteBufferPool, wsCoreSession);
|
return new WebSocketConnection(endPoint, executor, scheduler, byteBufferPool, coreSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getSendServerVersion(Connector connector)
|
private boolean getSendServerVersion(Connector connector)
|
||||||
|
|
|
@ -41,17 +41,17 @@ public class AbstractTestFrameHandler implements SynchronousFrameHandler
|
||||||
private byte partial = OpCode.UNDEFINED;
|
private byte partial = OpCode.UNDEFINED;
|
||||||
private Utf8StringBuilder utf8;
|
private Utf8StringBuilder utf8;
|
||||||
private ByteBuffer byteBuffer;
|
private ByteBuffer byteBuffer;
|
||||||
private FrameHandler.CoreSession session;
|
private FrameHandler.CoreSession coreSession;
|
||||||
|
|
||||||
public FrameHandler.CoreSession getCoreSession()
|
public FrameHandler.CoreSession getCoreSession()
|
||||||
{
|
{
|
||||||
return session;
|
return coreSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOpen(CoreSession coreSession)
|
public void onOpen(CoreSession coreSession)
|
||||||
{
|
{
|
||||||
this.session = coreSession;
|
this.coreSession = coreSession;
|
||||||
onOpen();
|
onOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ public class AbstractTestFrameHandler implements SynchronousFrameHandler
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
session.sendFrame(new Frame(PONG).setPayload(pongBuf), callback, false);
|
coreSession.sendFrame(new Frame(PONG).setPayload(pongBuf), callback, false);
|
||||||
}
|
}
|
||||||
catch (Throwable t)
|
catch (Throwable t)
|
||||||
{
|
{
|
||||||
|
@ -338,7 +338,7 @@ public class AbstractTestFrameHandler implements SynchronousFrameHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
if (respond > 0)
|
if (respond > 0)
|
||||||
session.close(respond, reason, callback);
|
coreSession.close(respond, reason, callback);
|
||||||
else
|
else
|
||||||
callback.succeeded();
|
callback.succeeded();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
public class GeneratorFrameFlagsTest
|
public class GeneratorFrameFlagsTest
|
||||||
{
|
{
|
||||||
private static ByteBufferPool bufferPool = new MappedByteBufferPool();
|
private static ByteBufferPool bufferPool = new MappedByteBufferPool();
|
||||||
private WebSocketCoreSession session;
|
private WebSocketCoreSession coreSession;
|
||||||
|
|
||||||
public static Stream<Arguments> data()
|
public static Stream<Arguments> data()
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,7 @@ public class GeneratorFrameFlagsTest
|
||||||
{
|
{
|
||||||
ExtensionStack exStack = new ExtensionStack(new WebSocketExtensionRegistry(), Behavior.SERVER);
|
ExtensionStack exStack = new ExtensionStack(new WebSocketExtensionRegistry(), Behavior.SERVER);
|
||||||
exStack.negotiate(new DecoratedObjectFactory(), bufferPool, new LinkedList<>(), new LinkedList<>());
|
exStack.negotiate(new DecoratedObjectFactory(), bufferPool, new LinkedList<>(), new LinkedList<>());
|
||||||
this.session = new WebSocketCoreSession(new AbstractTestFrameHandler(), Behavior.CLIENT, Negotiated.from(exStack));
|
this.coreSession = new WebSocketCoreSession(new AbstractTestFrameHandler(), Behavior.CLIENT, Negotiated.from(exStack));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
|
@ -76,6 +76,6 @@ public class GeneratorFrameFlagsTest
|
||||||
|
|
||||||
ByteBuffer buffer = ByteBuffer.allocate(100);
|
ByteBuffer buffer = ByteBuffer.allocate(100);
|
||||||
new Generator(bufferPool).generateWholeFrame(invalidFrame, buffer);
|
new Generator(bufferPool).generateWholeFrame(invalidFrame, buffer);
|
||||||
assertThrows(ProtocolException.class, () -> session.assertValidOutgoing(invalidFrame));
|
assertThrows(ProtocolException.class, () -> coreSession.assertValidOutgoing(invalidFrame));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class GeneratorTest
|
||||||
private static final Logger LOG = Log.getLogger(Helper.class);
|
private static final Logger LOG = Log.getLogger(Helper.class);
|
||||||
|
|
||||||
private static Generator generator = new Generator(new MappedByteBufferPool());
|
private static Generator generator = new Generator(new MappedByteBufferPool());
|
||||||
private static WebSocketCoreSession session = newWebSocketCoreSession(Behavior.SERVER);
|
private static WebSocketCoreSession coreSession = newWebSocketCoreSession(Behavior.SERVER);
|
||||||
|
|
||||||
private static WebSocketCoreSession newWebSocketCoreSession(Behavior behavior)
|
private static WebSocketCoreSession newWebSocketCoreSession(Behavior behavior)
|
||||||
{
|
{
|
||||||
|
@ -410,7 +410,7 @@ public class GeneratorTest
|
||||||
BufferUtil.flipToFlush(bb, 0);
|
BufferUtil.flipToFlush(bb, 0);
|
||||||
|
|
||||||
closeFrame.setPayload(bb);
|
closeFrame.setPayload(bb);
|
||||||
assertThrows(ProtocolException.class, () -> session.assertValidOutgoing(closeFrame));
|
assertThrows(ProtocolException.class, () -> coreSession.assertValidOutgoing(closeFrame));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -651,7 +651,7 @@ public class GeneratorTest
|
||||||
|
|
||||||
Frame pingFrame = new Frame(OpCode.PING);
|
Frame pingFrame = new Frame(OpCode.PING);
|
||||||
pingFrame.setPayload(ByteBuffer.wrap(bytes));
|
pingFrame.setPayload(ByteBuffer.wrap(bytes));
|
||||||
assertThrows(WebSocketException.class, () -> session.assertValidOutgoing(pingFrame));
|
assertThrows(WebSocketException.class, () -> coreSession.assertValidOutgoing(pingFrame));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -665,7 +665,7 @@ public class GeneratorTest
|
||||||
|
|
||||||
Frame pongFrame = new Frame(OpCode.PONG);
|
Frame pongFrame = new Frame(OpCode.PONG);
|
||||||
pongFrame.setPayload(ByteBuffer.wrap(bytes));
|
pongFrame.setPayload(ByteBuffer.wrap(bytes));
|
||||||
assertThrows(WebSocketException.class, () -> session.assertValidOutgoing(pongFrame));
|
assertThrows(WebSocketException.class, () -> coreSession.assertValidOutgoing(pongFrame));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class MessageHandlerTest
|
||||||
|
|
||||||
boolean demanding;
|
boolean demanding;
|
||||||
int demand;
|
int demand;
|
||||||
CoreSession session;
|
CoreSession coreSession;
|
||||||
List<String> textMessages = new ArrayList<>();
|
List<String> textMessages = new ArrayList<>();
|
||||||
List<ByteBuffer> binaryMessages = new ArrayList<>();
|
List<ByteBuffer> binaryMessages = new ArrayList<>();
|
||||||
List<Callback> callbacks = new ArrayList<>();
|
List<Callback> callbacks = new ArrayList<>();
|
||||||
|
@ -63,7 +63,7 @@ public class MessageHandlerTest
|
||||||
demanding = false;
|
demanding = false;
|
||||||
demand = 0;
|
demand = 0;
|
||||||
|
|
||||||
session = new CoreSession.Empty()
|
coreSession = new CoreSession.Empty()
|
||||||
{
|
{
|
||||||
private ByteBufferPool byteBufferPool = new MappedByteBufferPool();
|
private ByteBufferPool byteBufferPool = new MappedByteBufferPool();
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ public class MessageHandlerTest
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handler.onOpen(session, NOOP);
|
handler.onOpen(coreSession, NOOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -349,7 +349,7 @@ public class MessageHandlerTest
|
||||||
FutureCallback callback;
|
FutureCallback callback;
|
||||||
|
|
||||||
handler.setMaxTextMessageSize(4);
|
handler.setMaxTextMessageSize(4);
|
||||||
handler.onOpen(session, NOOP);
|
handler.onOpen(coreSession, NOOP);
|
||||||
|
|
||||||
callback = new FutureCallback();
|
callback = new FutureCallback();
|
||||||
handler.onFrame(new Frame(OpCode.TEXT, true, "Testing"), callback);
|
handler.onFrame(new Frame(OpCode.TEXT, true, "Testing"), callback);
|
||||||
|
@ -368,7 +368,7 @@ public class MessageHandlerTest
|
||||||
FutureCallback callback;
|
FutureCallback callback;
|
||||||
|
|
||||||
handler.setMaxTextMessageSize(4);
|
handler.setMaxTextMessageSize(4);
|
||||||
handler.onOpen(session, NOOP);
|
handler.onOpen(coreSession, NOOP);
|
||||||
|
|
||||||
callback = new FutureCallback();
|
callback = new FutureCallback();
|
||||||
handler.onFrame(new Frame(OpCode.TEXT, false, "123"), callback);
|
handler.onFrame(new Frame(OpCode.TEXT, false, "123"), callback);
|
||||||
|
@ -569,7 +569,7 @@ public class MessageHandlerTest
|
||||||
FutureCallback callback;
|
FutureCallback callback;
|
||||||
|
|
||||||
handler.setMaxBinaryMessageSize(4);
|
handler.setMaxBinaryMessageSize(4);
|
||||||
handler.onOpen(session, NOOP);
|
handler.onOpen(coreSession, NOOP);
|
||||||
|
|
||||||
callback = new FutureCallback();
|
callback = new FutureCallback();
|
||||||
handler.onFrame(new Frame(OpCode.BINARY, true, "Testing"), callback);
|
handler.onFrame(new Frame(OpCode.BINARY, true, "Testing"), callback);
|
||||||
|
@ -588,7 +588,7 @@ public class MessageHandlerTest
|
||||||
FutureCallback callback;
|
FutureCallback callback;
|
||||||
|
|
||||||
handler.setMaxBinaryMessageSize(4);
|
handler.setMaxBinaryMessageSize(4);
|
||||||
handler.onOpen(session, NOOP);
|
handler.onOpen(coreSession, NOOP);
|
||||||
|
|
||||||
callback = new FutureCallback();
|
callback = new FutureCallback();
|
||||||
handler.onFrame(new Frame(OpCode.BINARY, false, "123"), callback);
|
handler.onFrame(new Frame(OpCode.BINARY, false, "123"), callback);
|
||||||
|
@ -652,7 +652,7 @@ public class MessageHandlerTest
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handler.onOpen(session, NOOP);
|
handler.onOpen(coreSession, NOOP);
|
||||||
|
|
||||||
FutureCallback callback;
|
FutureCallback callback;
|
||||||
|
|
||||||
|
@ -680,7 +680,7 @@ public class MessageHandlerTest
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handler.onOpen(session, NOOP);
|
handler.onOpen(coreSession, NOOP);
|
||||||
|
|
||||||
FutureCallback callback;
|
FutureCallback callback;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ import static org.hamcrest.Matchers.is;
|
||||||
public class ParserCapture
|
public class ParserCapture
|
||||||
{
|
{
|
||||||
private final Parser parser;
|
private final Parser parser;
|
||||||
private final WebSocketCoreSession session;
|
private final WebSocketCoreSession coreSession;
|
||||||
public BlockingQueue<Frame> framesQueue = new LinkedBlockingDeque<>();
|
public BlockingQueue<Frame> framesQueue = new LinkedBlockingDeque<>();
|
||||||
public boolean closed = false;
|
public boolean closed = false;
|
||||||
public boolean copy;
|
public boolean copy;
|
||||||
|
@ -60,7 +60,7 @@ public class ParserCapture
|
||||||
ByteBufferPool bufferPool = new MappedByteBufferPool();
|
ByteBufferPool bufferPool = new MappedByteBufferPool();
|
||||||
ExtensionStack exStack = new ExtensionStack(new WebSocketExtensionRegistry(), Behavior.SERVER);
|
ExtensionStack exStack = new ExtensionStack(new WebSocketExtensionRegistry(), Behavior.SERVER);
|
||||||
exStack.negotiate(new DecoratedObjectFactory(), bufferPool, new LinkedList<>(), new LinkedList<>());
|
exStack.negotiate(new DecoratedObjectFactory(), bufferPool, new LinkedList<>(), new LinkedList<>());
|
||||||
this.session = new WebSocketCoreSession(new AbstractTestFrameHandler(), behavior, Negotiated.from(exStack));
|
this.coreSession = new WebSocketCoreSession(new AbstractTestFrameHandler(), behavior, Negotiated.from(exStack));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void parse(ByteBuffer buffer)
|
public void parse(ByteBuffer buffer)
|
||||||
|
@ -71,7 +71,7 @@ public class ParserCapture
|
||||||
if (frame == null)
|
if (frame == null)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
session.assertValidIncoming(frame);
|
coreSession.assertValidIncoming(frame);
|
||||||
|
|
||||||
if (!onFrame(frame))
|
if (!onFrame(frame))
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class TestFrameHandler implements SynchronousFrameHandler
|
||||||
{
|
{
|
||||||
private static Logger LOG = Log.getLogger(TestFrameHandler.class);
|
private static Logger LOG = Log.getLogger(TestFrameHandler.class);
|
||||||
|
|
||||||
protected CoreSession session;
|
protected CoreSession coreSession;
|
||||||
public BlockingQueue<Frame> receivedFrames = new BlockingArrayQueue<>();
|
public BlockingQueue<Frame> receivedFrames = new BlockingArrayQueue<>();
|
||||||
protected Throwable failure;
|
protected Throwable failure;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public class TestFrameHandler implements SynchronousFrameHandler
|
||||||
|
|
||||||
public CoreSession getCoreSession()
|
public CoreSession getCoreSession()
|
||||||
{
|
{
|
||||||
return session;
|
return coreSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockingQueue<Frame> getFrames()
|
public BlockingQueue<Frame> getFrames()
|
||||||
|
@ -58,7 +58,7 @@ public class TestFrameHandler implements SynchronousFrameHandler
|
||||||
public void onOpen(CoreSession coreSession)
|
public void onOpen(CoreSession coreSession)
|
||||||
{
|
{
|
||||||
LOG.info("onOpen {}", coreSession);
|
LOG.info("onOpen {}", coreSession);
|
||||||
this.session = coreSession;
|
this.coreSession = coreSession;
|
||||||
open.countDown();
|
open.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class TestWebSocketNegotiator implements WebSocketNegotiator
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(FrameHandler.CoreSession session)
|
public void customize(FrameHandler.CoreSession coreSession)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -413,7 +413,7 @@ public class WebSocketCloseTest extends WebSocketTester
|
||||||
|
|
||||||
static class DemandingTestFrameHandler implements SynchronousFrameHandler
|
static class DemandingTestFrameHandler implements SynchronousFrameHandler
|
||||||
{
|
{
|
||||||
private CoreSession session;
|
private CoreSession coreSession;
|
||||||
String state;
|
String state;
|
||||||
|
|
||||||
protected BlockingQueue<Frame> receivedFrames = new BlockingArrayQueue<>();
|
protected BlockingQueue<Frame> receivedFrames = new BlockingArrayQueue<>();
|
||||||
|
@ -425,7 +425,7 @@ public class WebSocketCloseTest extends WebSocketTester
|
||||||
|
|
||||||
public CoreSession getCoreSession()
|
public CoreSession getCoreSession()
|
||||||
{
|
{
|
||||||
return session;
|
return coreSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockingQueue<Frame> getFrames()
|
public BlockingQueue<Frame> getFrames()
|
||||||
|
@ -437,8 +437,8 @@ public class WebSocketCloseTest extends WebSocketTester
|
||||||
public void onOpen(CoreSession coreSession)
|
public void onOpen(CoreSession coreSession)
|
||||||
{
|
{
|
||||||
LOG.debug("onOpen {}", coreSession);
|
LOG.debug("onOpen {}", coreSession);
|
||||||
session = coreSession;
|
this.coreSession = coreSession;
|
||||||
state = session.toString();
|
state = this.coreSession.toString();
|
||||||
opened.countDown();
|
opened.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ public class WebSocketCloseTest extends WebSocketTester
|
||||||
public void onFrame(Frame frame, Callback callback)
|
public void onFrame(Frame frame, Callback callback)
|
||||||
{
|
{
|
||||||
LOG.debug("onFrame: " + BufferUtil.toDetailString(frame.getPayload()));
|
LOG.debug("onFrame: " + BufferUtil.toDetailString(frame.getPayload()));
|
||||||
state = session.toString();
|
state = coreSession.toString();
|
||||||
receivedCallback.offer(callback);
|
receivedCallback.offer(callback);
|
||||||
receivedFrames.offer(Frame.copy(frame));
|
receivedFrames.offer(Frame.copy(frame));
|
||||||
|
|
||||||
|
@ -458,7 +458,7 @@ public class WebSocketCloseTest extends WebSocketTester
|
||||||
public void onClosed(CloseStatus closeStatus)
|
public void onClosed(CloseStatus closeStatus)
|
||||||
{
|
{
|
||||||
LOG.debug("onClosed {}", closeStatus);
|
LOG.debug("onClosed {}", closeStatus);
|
||||||
state = session.toString();
|
state = coreSession.toString();
|
||||||
this.closeStatus = closeStatus;
|
this.closeStatus = closeStatus;
|
||||||
closed.countDown();
|
closed.countDown();
|
||||||
}
|
}
|
||||||
|
@ -468,7 +468,7 @@ public class WebSocketCloseTest extends WebSocketTester
|
||||||
{
|
{
|
||||||
LOG.debug("onError {} ", cause);
|
LOG.debug("onError {} ", cause);
|
||||||
error = cause;
|
error = cause;
|
||||||
state = session.toString();
|
state = coreSession.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -484,7 +484,7 @@ public class WebSocketCloseTest extends WebSocketTester
|
||||||
frame.setPayload(text);
|
frame.setPayload(text);
|
||||||
|
|
||||||
getCoreSession().sendFrame(frame, NOOP, false);
|
getCoreSession().sendFrame(frame, NOOP, false);
|
||||||
state = session.toString();
|
state = coreSession.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,12 +158,12 @@ public class WebSocketOpenTest extends WebSocketTester
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
FrameHandler.CoreSession session = sx.exchange(null);
|
FrameHandler.CoreSession coreSession = sx.exchange(null);
|
||||||
Callback onOpenCallback = cx.exchange(null);
|
Callback onOpenCallback = cx.exchange(null);
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
|
|
||||||
// Can send while onOpen is active
|
// Can send while onOpen is active
|
||||||
WebSocketOpenTest.TestFrameHandler.sendText(session,"Hello", NOOP);
|
WebSocketOpenTest.TestFrameHandler.sendText(coreSession,"Hello", NOOP);
|
||||||
Parser.ParsedFrame frame = receiveFrame(client.getInputStream());
|
Parser.ParsedFrame frame = receiveFrame(client.getInputStream());
|
||||||
assertThat(frame.getPayloadAsUTF8(),is("Hello"));
|
assertThat(frame.getPayloadAsUTF8(),is("Hello"));
|
||||||
|
|
||||||
|
@ -172,16 +172,16 @@ public class WebSocketOpenTest extends WebSocketTester
|
||||||
assertFalse(serverHandler.onClosed.await(1, TimeUnit.SECONDS));
|
assertFalse(serverHandler.onClosed.await(1, TimeUnit.SECONDS));
|
||||||
|
|
||||||
// Can't demand until open
|
// Can't demand until open
|
||||||
assertThrows(Throwable.class, () -> session.demand(1));
|
assertThrows(Throwable.class, () -> coreSession.demand(1));
|
||||||
client.getOutputStream().write(RawFrameBuilder.buildClose(new CloseStatus(CloseStatus.NORMAL), true));
|
client.getOutputStream().write(RawFrameBuilder.buildClose(new CloseStatus(CloseStatus.NORMAL), true));
|
||||||
assertFalse(serverHandler.onClosed.await(1, TimeUnit.SECONDS));
|
assertFalse(serverHandler.onClosed.await(1, TimeUnit.SECONDS));
|
||||||
|
|
||||||
// Succeeded moves to OPEN state and still does not read CLOSE frame
|
// Succeeded moves to OPEN state and still does not read CLOSE frame
|
||||||
onOpenCallback.succeeded();
|
onOpenCallback.succeeded();
|
||||||
assertThat(session.toString(),containsString("OPEN"));
|
assertThat(coreSession.toString(),containsString("OPEN"));
|
||||||
|
|
||||||
// Demand start receiving frames
|
// Demand start receiving frames
|
||||||
session.demand(1);
|
coreSession.demand(1);
|
||||||
client.getOutputStream().write(RawFrameBuilder.buildClose(new CloseStatus(CloseStatus.NORMAL), true));
|
client.getOutputStream().write(RawFrameBuilder.buildClose(new CloseStatus(CloseStatus.NORMAL), true));
|
||||||
assertTrue(serverHandler.onClosed.await(5, TimeUnit.SECONDS));
|
assertTrue(serverHandler.onClosed.await(5, TimeUnit.SECONDS));
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ public class WebSocketOpenTest extends WebSocketTester
|
||||||
|
|
||||||
static class TestFrameHandler implements SynchronousFrameHandler
|
static class TestFrameHandler implements SynchronousFrameHandler
|
||||||
{
|
{
|
||||||
private CoreSession session;
|
private CoreSession coreSession;
|
||||||
private BiFunction<CoreSession,Callback,Void> onOpen;
|
private BiFunction<CoreSession,Callback,Void> onOpen;
|
||||||
private CloseStatus closeStatus;
|
private CloseStatus closeStatus;
|
||||||
private CountDownLatch onClosed = new CountDownLatch(1);
|
private CountDownLatch onClosed = new CountDownLatch(1);
|
||||||
|
@ -211,7 +211,7 @@ public class WebSocketOpenTest extends WebSocketTester
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
return session;
|
return coreSession;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ public class WebSocketOpenTest extends WebSocketTester
|
||||||
LOG.info("onOpen {}", coreSession);
|
LOG.info("onOpen {}", coreSession);
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
session = coreSession;
|
this.coreSession = coreSession;
|
||||||
}
|
}
|
||||||
onOpen.apply(coreSession, callback);
|
onOpen.apply(coreSession, callback);
|
||||||
}
|
}
|
||||||
|
@ -271,25 +271,25 @@ public class WebSocketOpenTest extends WebSocketTester
|
||||||
|
|
||||||
public void sendText(String text)
|
public void sendText(String text)
|
||||||
{
|
{
|
||||||
sendText(session, text);
|
sendText(coreSession, text);
|
||||||
}
|
}
|
||||||
public void sendText(String text, Callback callback)
|
public void sendText(String text, Callback callback)
|
||||||
{
|
{
|
||||||
sendText(session, text, callback);
|
sendText(coreSession, text, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sendText(FrameHandler.CoreSession session, String text)
|
static void sendText(FrameHandler.CoreSession coreSession, String text)
|
||||||
{
|
{
|
||||||
sendText(session, text, NOOP);
|
sendText(coreSession, text, NOOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sendText(FrameHandler.CoreSession session, String text, Callback callback)
|
static void sendText(FrameHandler.CoreSession coreSession, String text, Callback callback)
|
||||||
{
|
{
|
||||||
Frame frame = new Frame(OpCode.TEXT);
|
Frame frame = new Frame(OpCode.TEXT);
|
||||||
frame.setFin(true);
|
frame.setFin(true);
|
||||||
frame.setPayload(text);
|
frame.setPayload(text);
|
||||||
|
|
||||||
session.sendFrame(frame, callback, false);
|
coreSession.sendFrame(frame, callback, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,12 +82,12 @@ class AutobahnWebSocketNegotiator implements WebSocketNegotiator
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(FrameHandler.CoreSession session)
|
public void customize(FrameHandler.CoreSession coreSession)
|
||||||
{
|
{
|
||||||
session.setIdleTimeout(Duration.ofMillis(10000));
|
coreSession.setIdleTimeout(Duration.ofMillis(10000));
|
||||||
session.setMaxTextMessageSize(Integer.MAX_VALUE);
|
coreSession.setMaxTextMessageSize(Integer.MAX_VALUE);
|
||||||
session.setMaxBinaryMessageSize(Integer.MAX_VALUE);
|
coreSession.setMaxBinaryMessageSize(Integer.MAX_VALUE);
|
||||||
session.setMaxFrameSize(65536*2);
|
coreSession.setMaxFrameSize(65536*2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -422,8 +422,8 @@ public class DeflateFrameExtensionTest extends AbstractExtensionTest
|
||||||
ExtensionStack exStack = new ExtensionStack(new WebSocketExtensionRegistry(), Behavior.SERVER);
|
ExtensionStack exStack = new ExtensionStack(new WebSocketExtensionRegistry(), Behavior.SERVER);
|
||||||
exStack.negotiate(new DecoratedObjectFactory(), bufferPool, new LinkedList<>(), new LinkedList<>());
|
exStack.negotiate(new DecoratedObjectFactory(), bufferPool, new LinkedList<>(), new LinkedList<>());
|
||||||
|
|
||||||
WebSocketCoreSession session = new WebSocketCoreSession(new AbstractTestFrameHandler(), Behavior.SERVER, Negotiated.from(exStack));
|
WebSocketCoreSession coreSession = new WebSocketCoreSession(new AbstractTestFrameHandler(), Behavior.SERVER, Negotiated.from(exStack));
|
||||||
session.setMaxFrameSize(maxMessageSize);
|
coreSession.setMaxFrameSize(maxMessageSize);
|
||||||
return session;
|
return coreSession;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ public class ExtensionTool
|
||||||
ByteBufferPool bufferPool = new MappedByteBufferPool();
|
ByteBufferPool bufferPool = new MappedByteBufferPool();
|
||||||
ExtensionStack exStack = new ExtensionStack(new WebSocketExtensionRegistry(), Behavior.SERVER);
|
ExtensionStack exStack = new ExtensionStack(new WebSocketExtensionRegistry(), Behavior.SERVER);
|
||||||
exStack.negotiate(new DecoratedObjectFactory(), bufferPool, new LinkedList<>(), new LinkedList<>());
|
exStack.negotiate(new DecoratedObjectFactory(), bufferPool, new LinkedList<>(), new LinkedList<>());
|
||||||
WebSocketCoreSession session = new WebSocketCoreSession(new AbstractTestFrameHandler(), Behavior.SERVER, Negotiated.from(exStack));
|
WebSocketCoreSession coreSession = new WebSocketCoreSession(new AbstractTestFrameHandler(), Behavior.SERVER, Negotiated.from(exStack));
|
||||||
return session;
|
return coreSession;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue