We need to keep the old constructor to not break the API.

This commit is contained in:
vibul 2012-04-27 10:22:56 +10:00
parent 763f22463e
commit 7c72a91e6b
11 changed files with 160 additions and 5 deletions

View File

@ -42,6 +42,17 @@ public class WebSocket00FrameDecoder extends ReplayingDecoder<VoidEnum> {
this(DEFAULT_MAX_FRAME_SIZE); 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 * 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. * sends a frame size larger than {@code maxFrameSize}, the channel will be closed.

View File

@ -99,6 +99,19 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
FRAME_START, MASKING_KEY, PAYLOAD, CORRUPT FRAME_START, MASKING_KEY, PAYLOAD, CORRUPT
} }
/**
* Constructor with default values
*
* @param maskedPayload
* Web socket servers must set this to true processed incoming masked payload. Client implementations
* must set this to false.
* @param allowExtensions
* Flag to allow reserved extension bits to be used or not
*/
public WebSocket08FrameDecoder(boolean maskedPayload, boolean allowExtensions) {
this(maskedPayload, allowExtensions, Long.MAX_VALUE);
}
/** /**
* Constructor * Constructor
* *

View File

@ -59,7 +59,20 @@ package org.jboss.netty.handler.codec.http.websocketx;
*/ */
public class WebSocket13FrameDecoder extends WebSocket08FrameDecoder { public class WebSocket13FrameDecoder extends WebSocket08FrameDecoder {
/** /**
* Constructor with default values
*
* @param maskedPayload
* Web socket servers must set this to true processed incoming masked payload. Client implementations
* must set this to false.
* @param allowExtensions
* Flag to allow reserved extension bits to be used or not
*/
public WebSocket13FrameDecoder(boolean maskedPayload, boolean allowExtensions) {
this(maskedPayload, allowExtensions, Long.MAX_VALUE);
}
/**
* Constructor * Constructor
* *
* @param maskedPayload * @param maskedPayload

View File

@ -41,6 +41,24 @@ public abstract class WebSocketClientHandshaker {
private final long maxFramePayloadLength; private final long maxFramePayloadLength;
/**
* Base 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 WebSocketClientHandshaker(URI webSocketUrl, WebSocketVersion version, String subprotocol,
Map<String, String> customHeaders) {
this(webSocketUrl, version, subprotocol, customHeaders, Long.MAX_VALUE);
}
/** /**
* Base constructor * Base constructor
* *

View File

@ -49,7 +49,25 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
private byte[] expectedChallengeResponseBytes; private byte[] expectedChallengeResponseBytes;
/** /**
* Constructor specifying the destination web socket location and version to initiate * 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<String, String> customHeaders) {
this(webSocketURL, version, subprotocol, customHeaders, Long.MAX_VALUE);
}
/**
* Constructor
* *
* @param webSocketURL * @param webSocketURL
* URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be * URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be

View File

@ -53,6 +53,26 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
private final boolean allowExtensions; 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<String, String> customHeaders) {
this(webSocketURL, version, subprotocol, allowExtensions, customHeaders, Long.MAX_VALUE);
}
/** /**
* Constructor * Constructor
* *

View File

@ -53,6 +53,26 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
private final boolean allowExtensions; 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<String, String> customHeaders) {
this(webSocketURL, version, subprotocol, allowExtensions, customHeaders, Long.MAX_VALUE);
}
/** /**
* Constructor * Constructor
* *

View File

@ -49,6 +49,21 @@ public abstract class WebSocketServerHandshaker {
} }
}; };
/**
* 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 * Constructor specifying the destination web socket location
* *

View File

@ -50,7 +50,20 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(WebSocketServerHandshaker00.class); 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 * Constructor specifying the destination web socket location
* *
* @param webSocketURL * @param webSocketURL

View File

@ -64,8 +64,7 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker {
* Allow extensions to be used in the reserved bits of the web socket frame * Allow extensions to be used in the reserved bits of the web socket frame
*/ */
public WebSocketServerHandshaker08(String webSocketURL, String subprotocols, boolean allowExtensions) { public WebSocketServerHandshaker08(String webSocketURL, String subprotocols, boolean allowExtensions) {
super(WebSocketVersion.V08, webSocketURL, subprotocols, Long.MAX_VALUE); this(webSocketURL, subprotocols, allowExtensions, Long.MAX_VALUE);
this.allowExtensions = allowExtensions;
} }
/** /**

View File

@ -53,6 +53,21 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker {
private final boolean allowExtensions; 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 * Constructor specifying the destination web socket location
* *