From 40e9b96764d47465835ef3b23f28c5fe38cdd604 Mon Sep 17 00:00:00 2001 From: vibul Date: Fri, 27 Apr 2012 10:43:34 +1000 Subject: [PATCH] We need to keep the old constructor to not break the API. --- .../websocketx/WebSocket00FrameDecoder.java | 11 ++++++++++ .../websocketx/WebSocket08FrameDecoder.java | 13 ++++++++++++ .../websocketx/WebSocket13FrameDecoder.java | 13 ++++++++++++ .../websocketx/WebSocketClientHandshaker.java | 18 +++++++++++++++++ .../WebSocketClientHandshaker00.java | 18 +++++++++++++++++ .../WebSocketClientHandshaker08.java | 20 +++++++++++++++++++ .../WebSocketClientHandshaker13.java | 20 +++++++++++++++++++ .../websocketx/WebSocketServerHandshaker.java | 15 ++++++++++++++ .../WebSocketServerHandshaker00.java | 13 ++++++++++++ .../WebSocketServerHandshaker08.java | 15 ++++++++++++++ .../WebSocketServerHandshaker13.java | 15 ++++++++++++++ 11 files changed, 171 insertions(+) diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket00FrameDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket00FrameDecoder.java index 24561287c6..9a7304f346 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket00FrameDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket00FrameDecoder.java @@ -42,6 +42,17 @@ public class WebSocket00FrameDecoder extends ReplayingDecoder { this(DEFAULT_MAX_FRAME_SIZE); } + /** + * Creates a new instance of {@code WebSocketFrameDecoder} with the specified {@code maxFrameSize}. If the client + * sends a frame size larger than {@code maxFrameSize}, the channel will be closed. + * + * @param maxFrameSize + * the maximum frame size to decode + */ + public WebSocket00FrameDecoder(int maxFrameSize) { + this.maxFrameSize = maxFrameSize; + } + /** * Creates a new instance of {@code WebSocketFrameDecoder} with the specified {@code maxFrameSize}. If the client * sends a frame size larger than {@code maxFrameSize}, the channel will be closed. diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoder.java index 5ffdeccfa0..19d81ec2eb 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoder.java @@ -99,6 +99,19 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder customHeaders) { + this(webSocketUrl, version, subprotocol, customHeaders, Long.MAX_VALUE); + } + /** * Base constructor * diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java index bc51b5cd75..b52b840907 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java @@ -48,6 +48,24 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker { private byte[] expectedChallengeResponseBytes; + /** + * Constructor with default values + * + * @param webSocketURL + * URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be + * sent to this URL. + * @param version + * Version of web socket specification to use to connect to the server + * @param subprotocol + * Sub protocol request sent to the server. + * @param customHeaders + * Map of custom headers to add to the client request + */ + public WebSocketClientHandshaker00(URI webSocketURL, WebSocketVersion version, String subprotocol, + Map customHeaders) { + this(webSocketURL, version, subprotocol, customHeaders, Long.MAX_VALUE); + } + /** * Constructor specifying the destination web socket location and version to initiate * diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java index e0728c1b4e..5ba568e3cc 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java @@ -53,6 +53,26 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker { private final boolean allowExtensions; + /** + * Constructor with default values + * + * @param webSocketURL + * URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be + * sent to this URL. + * @param version + * Version of web socket specification to use to connect to the server + * @param subprotocol + * Sub protocol request sent to the server. + * @param allowExtensions + * Allow extensions to be used in the reserved bits of the web socket frame + * @param customHeaders + * Map of custom headers to add to the client request + */ + public WebSocketClientHandshaker08(URI webSocketURL, WebSocketVersion version, String subprotocol, + boolean allowExtensions, Map customHeaders) { + this(webSocketURL, version, subprotocol, allowExtensions, customHeaders, Long.MAX_VALUE); + } + /** * Constructor * diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java index 78eade9787..5f31eed5b0 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java @@ -53,6 +53,26 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker { private final boolean allowExtensions; + /** + * Constructor with default values + * + * @param webSocketURL + * URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be + * sent to this URL. + * @param version + * Version of web socket specification to use to connect to the server + * @param subprotocol + * Sub protocol request sent to the server. + * @param allowExtensions + * Allow extensions to be used in the reserved bits of the web socket frame + * @param customHeaders + * Map of custom headers to add to the client request + */ + public WebSocketClientHandshaker13(URI webSocketURL, WebSocketVersion version, String subprotocol, + boolean allowExtensions, Map customHeaders) { + this(webSocketURL, version, subprotocol, allowExtensions, customHeaders, Long.MAX_VALUE); + } + /** * Constructor * diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java index 3060c8c9f3..e648915a6f 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java @@ -35,6 +35,21 @@ public abstract class WebSocketServerHandshaker { private final long maxFramePayloadLength; + /** + * Constructor using default values + * + * @param version + * the protocol version + * @param webSocketUrl + * 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. + */ + protected WebSocketServerHandshaker(WebSocketVersion version, String webSocketUrl, String subprotocols) { + this(version, webSocketUrl, subprotocols, Long.MAX_VALUE); + } + /** * Constructor specifying the destination web socket location * diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker00.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker00.java index ed8d8e8411..78a5f7669b 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker00.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker00.java @@ -50,6 +50,19 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker { private static final InternalLogger logger = InternalLoggerFactory.getInstance(WebSocketServerHandshaker00.class); + /** + * Constructor with default values + * + * @param webSocketURL + * 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 + */ + public WebSocketServerHandshaker00(String webSocketURL, String subprotocols) { + this(webSocketURL, subprotocols, Long.MAX_VALUE); + } + /** * Constructor specifying the destination web socket location * diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker08.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker08.java index 18f1b72ebd..96eedfc580 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker08.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker08.java @@ -49,6 +49,21 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker { private final boolean allowExtensions; + /** + * Constructor using defaults + * + * @param webSocketURL + * 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 + * @param allowExtensions + * Allow extensions to be used in the reserved bits of the web socket frame + */ + public WebSocketServerHandshaker08(String webSocketURL, String subprotocols, boolean allowExtensions) { + this(webSocketURL, subprotocols, allowExtensions, Long.MAX_VALUE); + } + /** * Constructor specifying the destination web socket location * diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13.java index f3396f1c7f..dab9a8f8d9 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13.java @@ -50,6 +50,21 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker { private final boolean allowExtensions; + /** + * Constructor using defaults + * + * @param webSocketURL + * 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 + * @param allowExtensions + * Allow extensions to be used in the reserved bits of the web socket frame + */ + public WebSocketServerHandshaker13(String webSocketURL, String subprotocols, boolean allowExtensions) { + this(webSocketURL, subprotocols, allowExtensions, Long.MAX_VALUE); + } + /** * Constructor specifying the destination web socket location *