2011-09-26 14:51:15 +02:00
|
|
|
/*
|
2019-06-18 10:05:58 +02:00
|
|
|
* Copyright 2019 The Netty Project
|
2011-09-26 14:51:15 +02:00
|
|
|
*
|
2011-12-09 06:18:34 +01:00
|
|
|
* The Netty Project licenses this file to you under the Apache License,
|
|
|
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at:
|
2011-09-26 14:51:15 +02:00
|
|
|
*
|
2020-10-23 14:44:18 +02:00
|
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
2011-09-26 14:51:15 +02:00
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
2011-12-09 06:18:34 +01:00
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
2011-09-26 14:51:15 +02:00
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
2011-12-09 04:38:59 +01:00
|
|
|
package io.netty.handler.codec.http.websocketx;
|
2011-09-26 14:51:15 +02:00
|
|
|
|
2011-12-11 00:47:07 +01:00
|
|
|
import io.netty.channel.Channel;
|
Clean up Future/Promises API (#11575)
Motivation:
The generics for the existing futures, promises, and listeners are too complicated.
This complication comes from the existence of `ChannelPromise` and `ChannelFuture`, which forces listeners to care about the particular _type_ of future being listened on.
Modification:
* Add a `FutureContextListener` which can take a context object as an additional argument. This allows our listeners to have the channel piped through to them, so they don't need to rely on the `ChannelFuture.channel()` method.
* Make the `FutureListener`, along with the `FutureContextListener` sibling, the default listener API, retiring the `GenericFutureListener` since we no longer need to abstract over the type of the future.
* Change all uses of `ChannelPromise` to `Promise<Void>`.
* Change all uses of `ChannelFuture` to `Future<Void>`.
* Change all uses of `GenericFutureListener` to either `FutureListener` or `FutureContextListener` as needed.
* Remove `ChannelFutureListener` and `GenericFutureListener`.
* Introduce a `ChannelFutureListeners` enum to house the constants that previously lived in `ChannelFutureListener`. These constants now implement `FutureContextListener` and take the `Channel` as a context.
* Remove `ChannelPromise` and `ChannelFuture` — all usages now rely on the plain `Future` and `Promise` APIs.
* Add static factory methods to `DefaultPromise` that allow us to create promises that are initialised as successful or failed.
* Remove `CompleteFuture`, `SucceededFuture`, `FailedFuture`, `CompleteChannelFuture`, `SucceededChannelFuture`, and `FailedChannelFuture`.
* Remove `ChannelPromiseNotifier`.
Result:
Cleaner generics and more straight forward code.
2021-08-20 09:55:16 +02:00
|
|
|
import io.netty.channel.ChannelFutureListeners;
|
2021-04-21 15:16:10 +02:00
|
|
|
import io.netty.channel.ChannelHandler;
|
2013-03-07 10:57:27 +01:00
|
|
|
import io.netty.channel.ChannelHandlerContext;
|
2021-04-21 15:16:10 +02:00
|
|
|
import io.netty.channel.ChannelOutboundInvoker;
|
2013-03-07 10:57:27 +01:00
|
|
|
import io.netty.channel.ChannelPipeline;
|
2015-01-06 06:55:01 +01:00
|
|
|
import io.netty.channel.SimpleChannelInboundHandler;
|
2013-01-16 05:22:50 +01:00
|
|
|
import io.netty.handler.codec.http.FullHttpRequest;
|
2013-03-07 10:57:27 +01:00
|
|
|
import io.netty.handler.codec.http.FullHttpResponse;
|
2013-09-09 11:55:25 +02:00
|
|
|
import io.netty.handler.codec.http.HttpContentCompressor;
|
2013-02-08 19:54:05 +01:00
|
|
|
import io.netty.handler.codec.http.HttpHeaders;
|
2013-03-07 10:57:27 +01:00
|
|
|
import io.netty.handler.codec.http.HttpObjectAggregator;
|
2015-01-06 06:55:01 +01:00
|
|
|
import io.netty.handler.codec.http.HttpRequest;
|
2013-03-07 10:57:27 +01:00
|
|
|
import io.netty.handler.codec.http.HttpRequestDecoder;
|
|
|
|
import io.netty.handler.codec.http.HttpResponseEncoder;
|
|
|
|
import io.netty.handler.codec.http.HttpServerCodec;
|
2015-01-06 06:55:01 +01:00
|
|
|
import io.netty.util.ReferenceCountUtil;
|
Clean up Future/Promises API (#11575)
Motivation:
The generics for the existing futures, promises, and listeners are too complicated.
This complication comes from the existence of `ChannelPromise` and `ChannelFuture`, which forces listeners to care about the particular _type_ of future being listened on.
Modification:
* Add a `FutureContextListener` which can take a context object as an additional argument. This allows our listeners to have the channel piped through to them, so they don't need to rely on the `ChannelFuture.channel()` method.
* Make the `FutureListener`, along with the `FutureContextListener` sibling, the default listener API, retiring the `GenericFutureListener` since we no longer need to abstract over the type of the future.
* Change all uses of `ChannelPromise` to `Promise<Void>`.
* Change all uses of `ChannelFuture` to `Future<Void>`.
* Change all uses of `GenericFutureListener` to either `FutureListener` or `FutureContextListener` as needed.
* Remove `ChannelFutureListener` and `GenericFutureListener`.
* Introduce a `ChannelFutureListeners` enum to house the constants that previously lived in `ChannelFutureListener`. These constants now implement `FutureContextListener` and take the `Channel` as a context.
* Remove `ChannelPromise` and `ChannelFuture` — all usages now rely on the plain `Future` and `Promise` APIs.
* Add static factory methods to `DefaultPromise` that allow us to create promises that are initialised as successful or failed.
* Remove `CompleteFuture`, `SucceededFuture`, `FailedFuture`, `CompleteChannelFuture`, `SucceededChannelFuture`, and `FailedChannelFuture`.
* Remove `ChannelPromiseNotifier`.
Result:
Cleaner generics and more straight forward code.
2021-08-20 09:55:16 +02:00
|
|
|
import io.netty.util.concurrent.Future;
|
|
|
|
import io.netty.util.concurrent.Promise;
|
2013-04-24 02:32:53 +02:00
|
|
|
import io.netty.util.internal.EmptyArrays;
|
2013-03-07 10:57:27 +01:00
|
|
|
import io.netty.util.internal.logging.InternalLogger;
|
|
|
|
import io.netty.util.internal.logging.InternalLoggerFactory;
|
2011-09-26 14:51:15 +02:00
|
|
|
|
2015-01-06 06:55:01 +01:00
|
|
|
import java.nio.channels.ClosedChannelException;
|
2012-06-11 15:54:28 +02:00
|
|
|
import java.util.Collections;
|
2012-05-31 02:13:00 +02:00
|
|
|
import java.util.LinkedHashSet;
|
|
|
|
import java.util.Set;
|
|
|
|
|
Clean up Future/Promises API (#11575)
Motivation:
The generics for the existing futures, promises, and listeners are too complicated.
This complication comes from the existence of `ChannelPromise` and `ChannelFuture`, which forces listeners to care about the particular _type_ of future being listened on.
Modification:
* Add a `FutureContextListener` which can take a context object as an additional argument. This allows our listeners to have the channel piped through to them, so they don't need to rely on the `ChannelFuture.channel()` method.
* Make the `FutureListener`, along with the `FutureContextListener` sibling, the default listener API, retiring the `GenericFutureListener` since we no longer need to abstract over the type of the future.
* Change all uses of `ChannelPromise` to `Promise<Void>`.
* Change all uses of `ChannelFuture` to `Future<Void>`.
* Change all uses of `GenericFutureListener` to either `FutureListener` or `FutureContextListener` as needed.
* Remove `ChannelFutureListener` and `GenericFutureListener`.
* Introduce a `ChannelFutureListeners` enum to house the constants that previously lived in `ChannelFutureListener`. These constants now implement `FutureContextListener` and take the `Channel` as a context.
* Remove `ChannelPromise` and `ChannelFuture` — all usages now rely on the plain `Future` and `Promise` APIs.
* Add static factory methods to `DefaultPromise` that allow us to create promises that are initialised as successful or failed.
* Remove `CompleteFuture`, `SucceededFuture`, `FailedFuture`, `CompleteChannelFuture`, `SucceededChannelFuture`, and `FailedChannelFuture`.
* Remove `ChannelPromiseNotifier`.
Result:
Cleaner generics and more straight forward code.
2021-08-20 09:55:16 +02:00
|
|
|
import static java.util.Objects.requireNonNull;
|
|
|
|
|
2011-09-26 14:51:15 +02:00
|
|
|
/**
|
|
|
|
* Base class for server side web socket opening and closing handshakes
|
|
|
|
*/
|
|
|
|
public abstract class WebSocketServerHandshaker {
|
2013-03-07 10:57:27 +01:00
|
|
|
protected static final InternalLogger logger = InternalLoggerFactory.getInstance(WebSocketServerHandshaker.class);
|
2011-09-26 14:51:15 +02:00
|
|
|
|
2013-01-17 07:06:46 +01:00
|
|
|
private final String uri;
|
2011-12-15 12:25:40 +01:00
|
|
|
|
2012-01-19 05:12:45 +01:00
|
|
|
private final String[] subprotocols;
|
2011-12-15 12:25:40 +01:00
|
|
|
|
2012-01-19 05:12:45 +01:00
|
|
|
private final WebSocketVersion version;
|
2011-12-15 12:25:40 +01:00
|
|
|
|
2019-06-18 10:05:58 +02:00
|
|
|
private final WebSocketDecoderConfig decoderConfig;
|
2012-05-31 02:13:00 +02:00
|
|
|
|
2012-05-31 04:09:23 +02:00
|
|
|
private String selectedSubprotocol;
|
2012-05-12 13:05:15 +02:00
|
|
|
|
2013-05-17 21:57:47 +02:00
|
|
|
/**
|
|
|
|
* Use this as wildcard to support all requested sub-protocols
|
|
|
|
*/
|
2013-05-17 22:09:11 +02:00
|
|
|
public static final String SUB_PROTOCOL_WILDCARD = "*";
|
2013-05-17 21:57:47 +02:00
|
|
|
|
2011-12-15 12:25:40 +01:00
|
|
|
/**
|
|
|
|
* Constructor specifying the destination web socket location
|
2012-02-21 03:06:26 +01:00
|
|
|
*
|
2012-01-19 05:12:45 +01:00
|
|
|
* @param version
|
|
|
|
* the protocol version
|
2013-01-17 07:06:46 +01:00
|
|
|
* @param uri
|
2011-12-15 12:25:40 +01:00
|
|
|
* URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be
|
|
|
|
* sent to this URL.
|
2012-01-19 05:12:45 +01:00
|
|
|
* @param subprotocols
|
2011-12-15 12:25:40 +01:00
|
|
|
* CSV of supported protocols. Null if sub protocols not supported.
|
2012-05-31 02:13:00 +02:00
|
|
|
* @param maxFramePayloadLength
|
|
|
|
* Maximum length of a frame's payload
|
2011-12-15 12:25:40 +01:00
|
|
|
*/
|
2012-01-19 05:12:45 +01:00
|
|
|
protected WebSocketServerHandshaker(
|
2013-01-17 07:06:46 +01:00
|
|
|
WebSocketVersion version, String uri, String subprotocols,
|
2012-05-31 02:21:51 +02:00
|
|
|
int maxFramePayloadLength) {
|
2019-06-18 10:05:58 +02:00
|
|
|
this(version, uri, subprotocols, WebSocketDecoderConfig.newBuilder()
|
|
|
|
.maxFramePayloadLength(maxFramePayloadLength)
|
|
|
|
.build());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor specifying the destination web socket location
|
|
|
|
*
|
|
|
|
* @param version
|
|
|
|
* the protocol version
|
|
|
|
* @param uri
|
|
|
|
* URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be
|
|
|
|
* sent to this URL.
|
|
|
|
* @param subprotocols
|
|
|
|
* CSV of supported protocols. Null if sub protocols not supported.
|
|
|
|
* @param decoderConfig
|
|
|
|
* Frames decoder configuration.
|
|
|
|
*/
|
|
|
|
protected WebSocketServerHandshaker(
|
|
|
|
WebSocketVersion version, String uri, String subprotocols, WebSocketDecoderConfig decoderConfig) {
|
2012-01-19 05:12:45 +01:00
|
|
|
this.version = version;
|
2013-01-17 07:06:46 +01:00
|
|
|
this.uri = uri;
|
2012-01-19 05:12:45 +01:00
|
|
|
if (subprotocols != null) {
|
2016-08-01 11:17:05 +02:00
|
|
|
String[] subprotocolArray = subprotocols.split(",");
|
2012-01-19 05:12:45 +01:00
|
|
|
for (int i = 0; i < subprotocolArray.length; i++) {
|
|
|
|
subprotocolArray[i] = subprotocolArray[i].trim();
|
2011-12-15 12:25:40 +01:00
|
|
|
}
|
2012-01-19 05:12:45 +01:00
|
|
|
this.subprotocols = subprotocolArray;
|
|
|
|
} else {
|
2013-04-24 02:32:53 +02:00
|
|
|
this.subprotocols = EmptyArrays.EMPTY_STRINGS;
|
2011-12-15 12:25:40 +01:00
|
|
|
}
|
Clean up Future/Promises API (#11575)
Motivation:
The generics for the existing futures, promises, and listeners are too complicated.
This complication comes from the existence of `ChannelPromise` and `ChannelFuture`, which forces listeners to care about the particular _type_ of future being listened on.
Modification:
* Add a `FutureContextListener` which can take a context object as an additional argument. This allows our listeners to have the channel piped through to them, so they don't need to rely on the `ChannelFuture.channel()` method.
* Make the `FutureListener`, along with the `FutureContextListener` sibling, the default listener API, retiring the `GenericFutureListener` since we no longer need to abstract over the type of the future.
* Change all uses of `ChannelPromise` to `Promise<Void>`.
* Change all uses of `ChannelFuture` to `Future<Void>`.
* Change all uses of `GenericFutureListener` to either `FutureListener` or `FutureContextListener` as needed.
* Remove `ChannelFutureListener` and `GenericFutureListener`.
* Introduce a `ChannelFutureListeners` enum to house the constants that previously lived in `ChannelFutureListener`. These constants now implement `FutureContextListener` and take the `Channel` as a context.
* Remove `ChannelPromise` and `ChannelFuture` — all usages now rely on the plain `Future` and `Promise` APIs.
* Add static factory methods to `DefaultPromise` that allow us to create promises that are initialised as successful or failed.
* Remove `CompleteFuture`, `SucceededFuture`, `FailedFuture`, `CompleteChannelFuture`, `SucceededChannelFuture`, and `FailedChannelFuture`.
* Remove `ChannelPromiseNotifier`.
Result:
Cleaner generics and more straight forward code.
2021-08-20 09:55:16 +02:00
|
|
|
this.decoderConfig = requireNonNull(decoderConfig, "decoderConfig");
|
2011-12-15 12:25:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the URL of the web socket
|
|
|
|
*/
|
2013-01-17 07:06:46 +01:00
|
|
|
public String uri() {
|
|
|
|
return uri;
|
2011-12-15 12:25:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the CSV of supported sub protocols
|
|
|
|
*/
|
2013-01-17 07:06:46 +01:00
|
|
|
public Set<String> subprotocols() {
|
2019-01-22 16:07:26 +01:00
|
|
|
Set<String> ret = new LinkedHashSet<>();
|
2012-06-11 15:54:28 +02:00
|
|
|
Collections.addAll(ret, subprotocols);
|
2012-01-19 05:12:45 +01:00
|
|
|
return ret;
|
2011-12-15 12:25:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the version of the specification being supported
|
|
|
|
*/
|
2013-01-17 07:06:46 +01:00
|
|
|
public WebSocketVersion version() {
|
2011-12-15 12:25:40 +01:00
|
|
|
return version;
|
|
|
|
}
|
|
|
|
|
2012-05-31 02:13:00 +02:00
|
|
|
/**
|
2012-06-29 07:03:41 +02:00
|
|
|
* Gets the maximum length for any frame's payload.
|
|
|
|
*
|
|
|
|
* @return The maximum length for a frame's payload
|
2012-05-31 02:13:00 +02:00
|
|
|
*/
|
2013-01-17 07:06:46 +01:00
|
|
|
public int maxFramePayloadLength() {
|
2019-06-18 10:05:58 +02:00
|
|
|
return decoderConfig.maxFramePayloadLength();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets this decoder configuration.
|
|
|
|
*
|
|
|
|
* @return This decoder configuration.
|
|
|
|
*/
|
|
|
|
public WebSocketDecoderConfig decoderConfig() {
|
|
|
|
return decoderConfig;
|
2012-05-31 02:13:00 +02:00
|
|
|
}
|
|
|
|
|
2011-12-15 12:25:40 +01:00
|
|
|
/**
|
2013-07-03 06:41:12 +02:00
|
|
|
* Performs the opening handshake. When call this method you <strong>MUST NOT</strong> retain the
|
|
|
|
* {@link FullHttpRequest} which is passed in.
|
2012-02-21 03:06:26 +01:00
|
|
|
*
|
2011-12-15 12:25:40 +01:00
|
|
|
* @param channel
|
2013-07-03 06:41:12 +02:00
|
|
|
* Channel
|
2011-12-15 12:25:40 +01:00
|
|
|
* @param req
|
2013-07-03 06:41:12 +02:00
|
|
|
* HTTP Request
|
|
|
|
* @return future
|
Clean up Future/Promises API (#11575)
Motivation:
The generics for the existing futures, promises, and listeners are too complicated.
This complication comes from the existence of `ChannelPromise` and `ChannelFuture`, which forces listeners to care about the particular _type_ of future being listened on.
Modification:
* Add a `FutureContextListener` which can take a context object as an additional argument. This allows our listeners to have the channel piped through to them, so they don't need to rely on the `ChannelFuture.channel()` method.
* Make the `FutureListener`, along with the `FutureContextListener` sibling, the default listener API, retiring the `GenericFutureListener` since we no longer need to abstract over the type of the future.
* Change all uses of `ChannelPromise` to `Promise<Void>`.
* Change all uses of `ChannelFuture` to `Future<Void>`.
* Change all uses of `GenericFutureListener` to either `FutureListener` or `FutureContextListener` as needed.
* Remove `ChannelFutureListener` and `GenericFutureListener`.
* Introduce a `ChannelFutureListeners` enum to house the constants that previously lived in `ChannelFutureListener`. These constants now implement `FutureContextListener` and take the `Channel` as a context.
* Remove `ChannelPromise` and `ChannelFuture` — all usages now rely on the plain `Future` and `Promise` APIs.
* Add static factory methods to `DefaultPromise` that allow us to create promises that are initialised as successful or failed.
* Remove `CompleteFuture`, `SucceededFuture`, `FailedFuture`, `CompleteChannelFuture`, `SucceededChannelFuture`, and `FailedChannelFuture`.
* Remove `ChannelPromiseNotifier`.
Result:
Cleaner generics and more straight forward code.
2021-08-20 09:55:16 +02:00
|
|
|
* The {@link Future} which is notified once the opening handshake completes
|
2011-12-15 12:25:40 +01:00
|
|
|
*/
|
Clean up Future/Promises API (#11575)
Motivation:
The generics for the existing futures, promises, and listeners are too complicated.
This complication comes from the existence of `ChannelPromise` and `ChannelFuture`, which forces listeners to care about the particular _type_ of future being listened on.
Modification:
* Add a `FutureContextListener` which can take a context object as an additional argument. This allows our listeners to have the channel piped through to them, so they don't need to rely on the `ChannelFuture.channel()` method.
* Make the `FutureListener`, along with the `FutureContextListener` sibling, the default listener API, retiring the `GenericFutureListener` since we no longer need to abstract over the type of the future.
* Change all uses of `ChannelPromise` to `Promise<Void>`.
* Change all uses of `ChannelFuture` to `Future<Void>`.
* Change all uses of `GenericFutureListener` to either `FutureListener` or `FutureContextListener` as needed.
* Remove `ChannelFutureListener` and `GenericFutureListener`.
* Introduce a `ChannelFutureListeners` enum to house the constants that previously lived in `ChannelFutureListener`. These constants now implement `FutureContextListener` and take the `Channel` as a context.
* Remove `ChannelPromise` and `ChannelFuture` — all usages now rely on the plain `Future` and `Promise` APIs.
* Add static factory methods to `DefaultPromise` that allow us to create promises that are initialised as successful or failed.
* Remove `CompleteFuture`, `SucceededFuture`, `FailedFuture`, `CompleteChannelFuture`, `SucceededChannelFuture`, and `FailedChannelFuture`.
* Remove `ChannelPromiseNotifier`.
Result:
Cleaner generics and more straight forward code.
2021-08-20 09:55:16 +02:00
|
|
|
public Future<Void> handshake(Channel channel, FullHttpRequest req) {
|
2021-08-30 13:15:14 +02:00
|
|
|
return handshake(channel, req, null);
|
2012-12-14 11:42:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs the opening handshake
|
|
|
|
*
|
2013-07-03 06:41:12 +02:00
|
|
|
* When call this method you <strong>MUST NOT</strong> retain the {@link FullHttpRequest} which is passed in.
|
|
|
|
*
|
2012-12-14 11:42:58 +01:00
|
|
|
* @param channel
|
|
|
|
* Channel
|
|
|
|
* @param req
|
|
|
|
* HTTP Request
|
2013-02-08 19:54:05 +01:00
|
|
|
* @param responseHeaders
|
|
|
|
* Extra headers to add to the handshake response or {@code null} if no extra headers should be added
|
2013-07-03 06:41:12 +02:00
|
|
|
* @return future
|
Clean up Future/Promises API (#11575)
Motivation:
The generics for the existing futures, promises, and listeners are too complicated.
This complication comes from the existence of `ChannelPromise` and `ChannelFuture`, which forces listeners to care about the particular _type_ of future being listened on.
Modification:
* Add a `FutureContextListener` which can take a context object as an additional argument. This allows our listeners to have the channel piped through to them, so they don't need to rely on the `ChannelFuture.channel()` method.
* Make the `FutureListener`, along with the `FutureContextListener` sibling, the default listener API, retiring the `GenericFutureListener` since we no longer need to abstract over the type of the future.
* Change all uses of `ChannelPromise` to `Promise<Void>`.
* Change all uses of `ChannelFuture` to `Future<Void>`.
* Change all uses of `GenericFutureListener` to either `FutureListener` or `FutureContextListener` as needed.
* Remove `ChannelFutureListener` and `GenericFutureListener`.
* Introduce a `ChannelFutureListeners` enum to house the constants that previously lived in `ChannelFutureListener`. These constants now implement `FutureContextListener` and take the `Channel` as a context.
* Remove `ChannelPromise` and `ChannelFuture` — all usages now rely on the plain `Future` and `Promise` APIs.
* Add static factory methods to `DefaultPromise` that allow us to create promises that are initialised as successful or failed.
* Remove `CompleteFuture`, `SucceededFuture`, `FailedFuture`, `CompleteChannelFuture`, `SucceededChannelFuture`, and `FailedChannelFuture`.
* Remove `ChannelPromiseNotifier`.
Result:
Cleaner generics and more straight forward code.
2021-08-20 09:55:16 +02:00
|
|
|
* the {@link Future} which is notified when the opening handshake is done
|
2012-12-14 11:42:58 +01:00
|
|
|
*/
|
2021-08-30 13:15:14 +02:00
|
|
|
public final Future<Void> handshake(Channel channel, FullHttpRequest req, HttpHeaders responseHeaders) {
|
2012-12-14 11:42:58 +01:00
|
|
|
|
2013-03-07 10:57:27 +01:00
|
|
|
if (logger.isDebugEnabled()) {
|
2014-02-28 22:38:54 +01:00
|
|
|
logger.debug("{} WebSocket version {} server handshake", channel, version());
|
2013-03-07 10:57:27 +01:00
|
|
|
}
|
|
|
|
FullHttpResponse response = newHandshakeResponse(req, responseHeaders);
|
2013-10-18 18:22:20 +02:00
|
|
|
ChannelPipeline p = channel.pipeline();
|
|
|
|
if (p.get(HttpObjectAggregator.class) != null) {
|
|
|
|
p.remove(HttpObjectAggregator.class);
|
|
|
|
}
|
|
|
|
if (p.get(HttpContentCompressor.class) != null) {
|
|
|
|
p.remove(HttpContentCompressor.class);
|
|
|
|
}
|
|
|
|
ChannelHandlerContext ctx = p.context(HttpRequestDecoder.class);
|
|
|
|
final String encoderName;
|
|
|
|
if (ctx == null) {
|
2019-10-09 15:12:52 +02:00
|
|
|
// this means the user use an HttpServerCodec
|
2013-10-18 18:22:20 +02:00
|
|
|
ctx = p.context(HttpServerCodec.class);
|
|
|
|
if (ctx == null) {
|
2021-08-30 13:15:14 +02:00
|
|
|
return channel.newFailedFuture(
|
2013-10-18 18:22:20 +02:00
|
|
|
new IllegalStateException("No HttpDecoder and no HttpServerCodec in the pipeline"));
|
|
|
|
}
|
|
|
|
p.addBefore(ctx.name(), "wsencoder", newWebSocketEncoder());
|
2019-07-18 10:19:09 +02:00
|
|
|
p.addBefore(ctx.name(), "wsdecoder", newWebsocketDecoder());
|
2013-10-18 18:22:20 +02:00
|
|
|
encoderName = ctx.name();
|
|
|
|
} else {
|
|
|
|
p.replace(ctx.name(), "wsdecoder", newWebsocketDecoder());
|
|
|
|
|
|
|
|
encoderName = p.context(HttpResponseEncoder.class).name();
|
2013-10-19 20:53:57 +02:00
|
|
|
p.addBefore(encoderName, "wsencoder", newWebSocketEncoder());
|
2013-10-18 18:22:20 +02:00
|
|
|
}
|
2021-08-30 13:15:14 +02:00
|
|
|
return channel.writeAndFlush(response).addListener(channel, (ch, future) -> {
|
2019-01-29 14:06:05 +01:00
|
|
|
if (future.isSuccess()) {
|
Clean up Future/Promises API (#11575)
Motivation:
The generics for the existing futures, promises, and listeners are too complicated.
This complication comes from the existence of `ChannelPromise` and `ChannelFuture`, which forces listeners to care about the particular _type_ of future being listened on.
Modification:
* Add a `FutureContextListener` which can take a context object as an additional argument. This allows our listeners to have the channel piped through to them, so they don't need to rely on the `ChannelFuture.channel()` method.
* Make the `FutureListener`, along with the `FutureContextListener` sibling, the default listener API, retiring the `GenericFutureListener` since we no longer need to abstract over the type of the future.
* Change all uses of `ChannelPromise` to `Promise<Void>`.
* Change all uses of `ChannelFuture` to `Future<Void>`.
* Change all uses of `GenericFutureListener` to either `FutureListener` or `FutureContextListener` as needed.
* Remove `ChannelFutureListener` and `GenericFutureListener`.
* Introduce a `ChannelFutureListeners` enum to house the constants that previously lived in `ChannelFutureListener`. These constants now implement `FutureContextListener` and take the `Channel` as a context.
* Remove `ChannelPromise` and `ChannelFuture` — all usages now rely on the plain `Future` and `Promise` APIs.
* Add static factory methods to `DefaultPromise` that allow us to create promises that are initialised as successful or failed.
* Remove `CompleteFuture`, `SucceededFuture`, `FailedFuture`, `CompleteChannelFuture`, `SucceededChannelFuture`, and `FailedChannelFuture`.
* Remove `ChannelPromiseNotifier`.
Result:
Cleaner generics and more straight forward code.
2021-08-20 09:55:16 +02:00
|
|
|
ChannelPipeline p1 = ch.pipeline();
|
2019-01-29 14:06:05 +01:00
|
|
|
p1.remove(encoderName);
|
2013-03-07 10:57:27 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-01-06 06:55:01 +01:00
|
|
|
/**
|
|
|
|
* Performs the opening handshake. When call this method you <strong>MUST NOT</strong> retain the
|
|
|
|
* {@link FullHttpRequest} which is passed in.
|
|
|
|
*
|
|
|
|
* @param channel
|
|
|
|
* Channel
|
|
|
|
* @param req
|
|
|
|
* HTTP Request
|
|
|
|
* @return future
|
Clean up Future/Promises API (#11575)
Motivation:
The generics for the existing futures, promises, and listeners are too complicated.
This complication comes from the existence of `ChannelPromise` and `ChannelFuture`, which forces listeners to care about the particular _type_ of future being listened on.
Modification:
* Add a `FutureContextListener` which can take a context object as an additional argument. This allows our listeners to have the channel piped through to them, so they don't need to rely on the `ChannelFuture.channel()` method.
* Make the `FutureListener`, along with the `FutureContextListener` sibling, the default listener API, retiring the `GenericFutureListener` since we no longer need to abstract over the type of the future.
* Change all uses of `ChannelPromise` to `Promise<Void>`.
* Change all uses of `ChannelFuture` to `Future<Void>`.
* Change all uses of `GenericFutureListener` to either `FutureListener` or `FutureContextListener` as needed.
* Remove `ChannelFutureListener` and `GenericFutureListener`.
* Introduce a `ChannelFutureListeners` enum to house the constants that previously lived in `ChannelFutureListener`. These constants now implement `FutureContextListener` and take the `Channel` as a context.
* Remove `ChannelPromise` and `ChannelFuture` — all usages now rely on the plain `Future` and `Promise` APIs.
* Add static factory methods to `DefaultPromise` that allow us to create promises that are initialised as successful or failed.
* Remove `CompleteFuture`, `SucceededFuture`, `FailedFuture`, `CompleteChannelFuture`, `SucceededChannelFuture`, and `FailedChannelFuture`.
* Remove `ChannelPromiseNotifier`.
Result:
Cleaner generics and more straight forward code.
2021-08-20 09:55:16 +02:00
|
|
|
* The {@link Future} which is notified once the opening handshake completes
|
2015-01-06 06:55:01 +01:00
|
|
|
*/
|
Clean up Future/Promises API (#11575)
Motivation:
The generics for the existing futures, promises, and listeners are too complicated.
This complication comes from the existence of `ChannelPromise` and `ChannelFuture`, which forces listeners to care about the particular _type_ of future being listened on.
Modification:
* Add a `FutureContextListener` which can take a context object as an additional argument. This allows our listeners to have the channel piped through to them, so they don't need to rely on the `ChannelFuture.channel()` method.
* Make the `FutureListener`, along with the `FutureContextListener` sibling, the default listener API, retiring the `GenericFutureListener` since we no longer need to abstract over the type of the future.
* Change all uses of `ChannelPromise` to `Promise<Void>`.
* Change all uses of `ChannelFuture` to `Future<Void>`.
* Change all uses of `GenericFutureListener` to either `FutureListener` or `FutureContextListener` as needed.
* Remove `ChannelFutureListener` and `GenericFutureListener`.
* Introduce a `ChannelFutureListeners` enum to house the constants that previously lived in `ChannelFutureListener`. These constants now implement `FutureContextListener` and take the `Channel` as a context.
* Remove `ChannelPromise` and `ChannelFuture` — all usages now rely on the plain `Future` and `Promise` APIs.
* Add static factory methods to `DefaultPromise` that allow us to create promises that are initialised as successful or failed.
* Remove `CompleteFuture`, `SucceededFuture`, `FailedFuture`, `CompleteChannelFuture`, `SucceededChannelFuture`, and `FailedChannelFuture`.
* Remove `ChannelPromiseNotifier`.
Result:
Cleaner generics and more straight forward code.
2021-08-20 09:55:16 +02:00
|
|
|
public Future<Void> handshake(Channel channel, HttpRequest req) {
|
2021-08-30 13:15:14 +02:00
|
|
|
return handshake(channel, req, null);
|
2015-01-06 06:55:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs the opening handshake
|
|
|
|
*
|
|
|
|
* When call this method you <strong>MUST NOT</strong> retain the {@link HttpRequest} which is passed in.
|
|
|
|
*
|
|
|
|
* @param channel
|
|
|
|
* Channel
|
|
|
|
* @param req
|
|
|
|
* HTTP Request
|
|
|
|
* @param responseHeaders
|
|
|
|
* Extra headers to add to the handshake response or {@code null} if no extra headers should be added
|
|
|
|
* @return future
|
Clean up Future/Promises API (#11575)
Motivation:
The generics for the existing futures, promises, and listeners are too complicated.
This complication comes from the existence of `ChannelPromise` and `ChannelFuture`, which forces listeners to care about the particular _type_ of future being listened on.
Modification:
* Add a `FutureContextListener` which can take a context object as an additional argument. This allows our listeners to have the channel piped through to them, so they don't need to rely on the `ChannelFuture.channel()` method.
* Make the `FutureListener`, along with the `FutureContextListener` sibling, the default listener API, retiring the `GenericFutureListener` since we no longer need to abstract over the type of the future.
* Change all uses of `ChannelPromise` to `Promise<Void>`.
* Change all uses of `ChannelFuture` to `Future<Void>`.
* Change all uses of `GenericFutureListener` to either `FutureListener` or `FutureContextListener` as needed.
* Remove `ChannelFutureListener` and `GenericFutureListener`.
* Introduce a `ChannelFutureListeners` enum to house the constants that previously lived in `ChannelFutureListener`. These constants now implement `FutureContextListener` and take the `Channel` as a context.
* Remove `ChannelPromise` and `ChannelFuture` — all usages now rely on the plain `Future` and `Promise` APIs.
* Add static factory methods to `DefaultPromise` that allow us to create promises that are initialised as successful or failed.
* Remove `CompleteFuture`, `SucceededFuture`, `FailedFuture`, `CompleteChannelFuture`, `SucceededChannelFuture`, and `FailedChannelFuture`.
* Remove `ChannelPromiseNotifier`.
Result:
Cleaner generics and more straight forward code.
2021-08-20 09:55:16 +02:00
|
|
|
* the {@link Future} which is notified when the opening handshake is done
|
2015-01-06 06:55:01 +01:00
|
|
|
*/
|
Clean up Future/Promises API (#11575)
Motivation:
The generics for the existing futures, promises, and listeners are too complicated.
This complication comes from the existence of `ChannelPromise` and `ChannelFuture`, which forces listeners to care about the particular _type_ of future being listened on.
Modification:
* Add a `FutureContextListener` which can take a context object as an additional argument. This allows our listeners to have the channel piped through to them, so they don't need to rely on the `ChannelFuture.channel()` method.
* Make the `FutureListener`, along with the `FutureContextListener` sibling, the default listener API, retiring the `GenericFutureListener` since we no longer need to abstract over the type of the future.
* Change all uses of `ChannelPromise` to `Promise<Void>`.
* Change all uses of `ChannelFuture` to `Future<Void>`.
* Change all uses of `GenericFutureListener` to either `FutureListener` or `FutureContextListener` as needed.
* Remove `ChannelFutureListener` and `GenericFutureListener`.
* Introduce a `ChannelFutureListeners` enum to house the constants that previously lived in `ChannelFutureListener`. These constants now implement `FutureContextListener` and take the `Channel` as a context.
* Remove `ChannelPromise` and `ChannelFuture` — all usages now rely on the plain `Future` and `Promise` APIs.
* Add static factory methods to `DefaultPromise` that allow us to create promises that are initialised as successful or failed.
* Remove `CompleteFuture`, `SucceededFuture`, `FailedFuture`, `CompleteChannelFuture`, `SucceededChannelFuture`, and `FailedChannelFuture`.
* Remove `ChannelPromiseNotifier`.
Result:
Cleaner generics and more straight forward code.
2021-08-20 09:55:16 +02:00
|
|
|
public final Future<Void> handshake(final Channel channel, HttpRequest req,
|
2021-08-30 13:15:14 +02:00
|
|
|
final HttpHeaders responseHeaders) {
|
2015-01-06 06:55:01 +01:00
|
|
|
|
|
|
|
if (req instanceof FullHttpRequest) {
|
2021-08-30 13:15:14 +02:00
|
|
|
return handshake(channel, (FullHttpRequest) req, responseHeaders);
|
2015-01-06 06:55:01 +01:00
|
|
|
}
|
|
|
|
if (logger.isDebugEnabled()) {
|
|
|
|
logger.debug("{} WebSocket version {} server handshake", channel, version());
|
|
|
|
}
|
|
|
|
ChannelPipeline p = channel.pipeline();
|
|
|
|
ChannelHandlerContext ctx = p.context(HttpRequestDecoder.class);
|
|
|
|
if (ctx == null) {
|
2019-10-09 15:12:52 +02:00
|
|
|
// this means the user use an HttpServerCodec
|
2015-01-06 06:55:01 +01:00
|
|
|
ctx = p.context(HttpServerCodec.class);
|
|
|
|
if (ctx == null) {
|
2021-08-30 13:15:14 +02:00
|
|
|
return channel.newFailedFuture(
|
2015-01-06 06:55:01 +01:00
|
|
|
new IllegalStateException("No HttpDecoder and no HttpServerCodec in the pipeline"));
|
|
|
|
}
|
|
|
|
}
|
2021-08-30 13:15:14 +02:00
|
|
|
|
|
|
|
Promise<Void> promise = channel.newPromise();
|
2015-01-06 06:55:01 +01:00
|
|
|
// Add aggregator and ensure we feed the HttpRequest so it is aggregated. A limit o 8192 should be more then
|
|
|
|
// enough for the websockets handshake payload.
|
|
|
|
//
|
|
|
|
// TODO: Make handshake work without HttpObjectAggregator at all.
|
|
|
|
String aggregatorName = "httpAggregator";
|
|
|
|
p.addAfter(ctx.name(), aggregatorName, new HttpObjectAggregator(8192));
|
|
|
|
p.addAfter(aggregatorName, "handshaker", new SimpleChannelInboundHandler<FullHttpRequest>() {
|
|
|
|
@Override
|
2019-11-01 07:23:07 +01:00
|
|
|
protected void messageReceived(ChannelHandlerContext ctx, FullHttpRequest msg) throws Exception {
|
2015-01-06 06:55:01 +01:00
|
|
|
// Remove ourself and do the actual handshake
|
|
|
|
ctx.pipeline().remove(this);
|
2021-08-30 13:15:14 +02:00
|
|
|
handshake(channel, msg, responseHeaders);
|
2015-01-06 06:55:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
|
|
|
// Remove ourself and fail the handshake promise.
|
|
|
|
promise.tryFailure(cause);
|
|
|
|
ctx.fireExceptionCaught(cause);
|
2020-03-01 08:13:33 +01:00
|
|
|
ctx.pipeline().remove(this);
|
2015-01-06 06:55:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
|
|
|
// Fail promise if Channel was closed
|
2019-05-17 22:23:02 +02:00
|
|
|
if (!promise.isDone()) {
|
|
|
|
promise.tryFailure(new ClosedChannelException());
|
|
|
|
}
|
2015-01-06 06:55:01 +01:00
|
|
|
ctx.fireChannelInactive();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
try {
|
|
|
|
ctx.fireChannelRead(ReferenceCountUtil.retain(req));
|
|
|
|
} catch (Throwable cause) {
|
|
|
|
promise.setFailure(cause);
|
|
|
|
}
|
2021-09-02 10:46:54 +02:00
|
|
|
return promise.asFuture();
|
2015-01-06 06:55:01 +01:00
|
|
|
}
|
|
|
|
|
2013-03-07 10:57:27 +01:00
|
|
|
/**
|
|
|
|
* Returns a new {@link FullHttpResponse) which will be used for as response to the handshake request.
|
|
|
|
*/
|
|
|
|
protected abstract FullHttpResponse newHandshakeResponse(FullHttpRequest req,
|
|
|
|
HttpHeaders responseHeaders);
|
2012-12-14 11:42:58 +01:00
|
|
|
/**
|
2021-04-21 15:16:10 +02:00
|
|
|
* Performs the closing handshake.
|
|
|
|
*
|
|
|
|
* When called from within a {@link ChannelHandler} you most likely want to use
|
|
|
|
* {@link #close(ChannelHandlerContext, CloseWebSocketFrame)}.
|
2012-12-14 11:42:58 +01:00
|
|
|
*
|
|
|
|
* @param channel
|
2021-04-21 15:16:10 +02:00
|
|
|
* the {@link Channel} to use.
|
2012-12-14 11:42:58 +01:00
|
|
|
* @param frame
|
2021-04-21 15:16:10 +02:00
|
|
|
* Closing Frame that was received.
|
2012-12-14 11:42:58 +01:00
|
|
|
*/
|
Clean up Future/Promises API (#11575)
Motivation:
The generics for the existing futures, promises, and listeners are too complicated.
This complication comes from the existence of `ChannelPromise` and `ChannelFuture`, which forces listeners to care about the particular _type_ of future being listened on.
Modification:
* Add a `FutureContextListener` which can take a context object as an additional argument. This allows our listeners to have the channel piped through to them, so they don't need to rely on the `ChannelFuture.channel()` method.
* Make the `FutureListener`, along with the `FutureContextListener` sibling, the default listener API, retiring the `GenericFutureListener` since we no longer need to abstract over the type of the future.
* Change all uses of `ChannelPromise` to `Promise<Void>`.
* Change all uses of `ChannelFuture` to `Future<Void>`.
* Change all uses of `GenericFutureListener` to either `FutureListener` or `FutureContextListener` as needed.
* Remove `ChannelFutureListener` and `GenericFutureListener`.
* Introduce a `ChannelFutureListeners` enum to house the constants that previously lived in `ChannelFutureListener`. These constants now implement `FutureContextListener` and take the `Channel` as a context.
* Remove `ChannelPromise` and `ChannelFuture` — all usages now rely on the plain `Future` and `Promise` APIs.
* Add static factory methods to `DefaultPromise` that allow us to create promises that are initialised as successful or failed.
* Remove `CompleteFuture`, `SucceededFuture`, `FailedFuture`, `CompleteChannelFuture`, `SucceededChannelFuture`, and `FailedChannelFuture`.
* Remove `ChannelPromiseNotifier`.
Result:
Cleaner generics and more straight forward code.
2021-08-20 09:55:16 +02:00
|
|
|
public Future<Void> close(Channel channel, CloseWebSocketFrame frame) {
|
2019-02-04 10:32:25 +01:00
|
|
|
requireNonNull(channel, "channel");
|
2021-08-31 12:49:30 +02:00
|
|
|
return close0(channel, frame);
|
2021-04-21 15:16:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs the closing handshake.
|
|
|
|
*
|
|
|
|
* @param ctx
|
|
|
|
* the {@link ChannelHandlerContext} to use.
|
|
|
|
* @param frame
|
|
|
|
* Closing Frame that was received.
|
|
|
|
*/
|
Clean up Future/Promises API (#11575)
Motivation:
The generics for the existing futures, promises, and listeners are too complicated.
This complication comes from the existence of `ChannelPromise` and `ChannelFuture`, which forces listeners to care about the particular _type_ of future being listened on.
Modification:
* Add a `FutureContextListener` which can take a context object as an additional argument. This allows our listeners to have the channel piped through to them, so they don't need to rely on the `ChannelFuture.channel()` method.
* Make the `FutureListener`, along with the `FutureContextListener` sibling, the default listener API, retiring the `GenericFutureListener` since we no longer need to abstract over the type of the future.
* Change all uses of `ChannelPromise` to `Promise<Void>`.
* Change all uses of `ChannelFuture` to `Future<Void>`.
* Change all uses of `GenericFutureListener` to either `FutureListener` or `FutureContextListener` as needed.
* Remove `ChannelFutureListener` and `GenericFutureListener`.
* Introduce a `ChannelFutureListeners` enum to house the constants that previously lived in `ChannelFutureListener`. These constants now implement `FutureContextListener` and take the `Channel` as a context.
* Remove `ChannelPromise` and `ChannelFuture` — all usages now rely on the plain `Future` and `Promise` APIs.
* Add static factory methods to `DefaultPromise` that allow us to create promises that are initialised as successful or failed.
* Remove `CompleteFuture`, `SucceededFuture`, `FailedFuture`, `CompleteChannelFuture`, `SucceededChannelFuture`, and `FailedChannelFuture`.
* Remove `ChannelPromiseNotifier`.
Result:
Cleaner generics and more straight forward code.
2021-08-20 09:55:16 +02:00
|
|
|
public Future<Void> close(ChannelHandlerContext ctx, CloseWebSocketFrame frame) {
|
2021-04-21 15:16:10 +02:00
|
|
|
requireNonNull(ctx, "ctx");
|
2021-08-31 12:49:30 +02:00
|
|
|
return close0(ctx, frame);
|
2021-04-21 15:16:10 +02:00
|
|
|
}
|
|
|
|
|
2021-08-31 12:49:30 +02:00
|
|
|
private static Future<Void> close0(ChannelOutboundInvoker invoker, CloseWebSocketFrame frame) {
|
|
|
|
return invoker.writeAndFlush(frame).addListener(invoker, ChannelFutureListeners.CLOSE);
|
2013-03-07 10:57:27 +01:00
|
|
|
}
|
2011-12-15 12:25:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Selects the first matching supported sub protocol
|
2012-02-21 03:06:26 +01:00
|
|
|
*
|
2012-01-19 05:12:45 +01:00
|
|
|
* @param requestedSubprotocols
|
2011-12-15 12:25:40 +01:00
|
|
|
* CSV of protocols to be supported. e.g. "chat, superchat"
|
|
|
|
* @return First matching supported sub protocol. Null if not found.
|
|
|
|
*/
|
2012-01-19 05:12:45 +01:00
|
|
|
protected String selectSubprotocol(String requestedSubprotocols) {
|
|
|
|
if (requestedSubprotocols == null || subprotocols.length == 0) {
|
2011-12-15 12:25:40 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2016-08-01 11:17:05 +02:00
|
|
|
String[] requestedSubprotocolArray = requestedSubprotocols.split(",");
|
2012-05-12 13:05:15 +02:00
|
|
|
for (String p: requestedSubprotocolArray) {
|
2012-01-19 05:12:45 +01:00
|
|
|
String requestedSubprotocol = p.trim();
|
2011-12-15 12:25:40 +01:00
|
|
|
|
2012-01-19 05:12:45 +01:00
|
|
|
for (String supportedSubprotocol: subprotocols) {
|
2013-05-17 21:57:47 +02:00
|
|
|
if (SUB_PROTOCOL_WILDCARD.equals(supportedSubprotocol)
|
|
|
|
|| requestedSubprotocol.equals(supportedSubprotocol)) {
|
2013-05-17 22:00:55 +02:00
|
|
|
selectedSubprotocol = requestedSubprotocol;
|
2012-01-19 05:12:45 +01:00
|
|
|
return requestedSubprotocol;
|
2011-12-15 12:25:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// No match found
|
|
|
|
return null;
|
|
|
|
}
|
2012-05-12 13:05:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the selected subprotocol. Null if no subprotocol has been selected.
|
|
|
|
* <p>
|
|
|
|
* This is only available AFTER <tt>handshake()</tt> has been called.
|
|
|
|
* </p>
|
|
|
|
*/
|
2013-01-17 07:06:46 +01:00
|
|
|
public String selectedSubprotocol() {
|
2012-05-12 13:05:15 +02:00
|
|
|
return selectedSubprotocol;
|
|
|
|
}
|
|
|
|
|
2013-03-07 10:57:27 +01:00
|
|
|
/**
|
|
|
|
* Returns the decoder to use after handshake is complete.
|
|
|
|
*/
|
2013-07-04 06:41:22 +02:00
|
|
|
protected abstract WebSocketFrameDecoder newWebsocketDecoder();
|
2013-03-07 10:57:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the encoder to use after the handshake is complete.
|
|
|
|
*/
|
2013-07-04 06:41:22 +02:00
|
|
|
protected abstract WebSocketFrameEncoder newWebSocketEncoder();
|
2013-03-07 10:57:27 +01:00
|
|
|
|
2011-09-26 14:51:15 +02:00
|
|
|
}
|