Merge pull request #3381 from eclipse/jetty-10-issue-3380-websocket-connection-listener

Issue #3380 - Adding configured Connection.Listeners to WebSocket Connections
This commit is contained in:
Joakim Erdfelt 2019-02-21 12:10:25 -05:00 committed by GitHub
commit 3826397190
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View File

@ -46,6 +46,7 @@ import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.B64Code;
import org.eclipse.jetty.util.QuotedStringTokenizer;
@ -338,6 +339,10 @@ public abstract class ClientUpgradeRequest extends HttpRequest implements Respon
WebSocketChannel wsChannel = newWebSocketChannel(frameHandler, negotiated);
WebSocketConnection wsConnection = newWebSocketConnection(endp, httpClient.getExecutor(), httpClient.getByteBufferPool(), wsChannel);
for (Connection.Listener listener : wsClient.getBeans(Connection.Listener.class))
wsConnection.addListener(listener);
wsChannel.setWebSocketConnection(wsConnection);
wsClient.customize(wsChannel);

View File

@ -18,12 +18,18 @@
package org.eclipse.jetty.websocket.core.server.internal;
import java.io.IOException;
import java.util.concurrent.Executor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.http.PreEncodedHttpField;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.server.ConnectionFactory;
import org.eclipse.jetty.server.Connector;
@ -46,11 +52,6 @@ import org.eclipse.jetty.websocket.core.server.Handshaker;
import org.eclipse.jetty.websocket.core.server.Negotiation;
import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.concurrent.Executor;
public final class RFC6455Handshaker implements Handshaker
{
static final Logger LOG = Log.getLogger(RFC6455Handshaker.class);
@ -193,6 +194,9 @@ public final class RFC6455Handshaker implements Handshaker
return false;
}
for (Connection.Listener listener : connector.getBeans(Connection.Listener.class))
connection.addListener(listener);
channel.setWebSocketConnection(connection);
if (defaultCustomizer!=null)
defaultCustomizer.customize(channel);