#722 - Make WebSocketClientHandshakerFactory a static utility class

This commit is contained in:
Veebs 2012-12-11 21:57:03 -08:00 committed by Norman Maurer
parent 2704efc056
commit 0c5fd38eb6
2 changed files with 10 additions and 4 deletions

View File

@ -23,7 +23,13 @@ import static io.netty.handler.codec.http.websocketx.WebSocketVersion.*;
/**
* Instances the appropriate handshake class to use for clients
*/
public class WebSocketClientHandshakerFactory {
public final class WebSocketClientHandshakerFactory {
/**
* Private constructor so this static class cannot be instanced.
*/
private WebSocketClientHandshakerFactory() {
}
/**
* Creates a new handshaker.
@ -40,7 +46,7 @@ public class WebSocketClientHandshakerFactory {
* @param customHeaders
* Custom HTTP headers to send during the handshake
*/
public WebSocketClientHandshaker newHandshaker(
public static WebSocketClientHandshaker newHandshaker(
URI webSocketURL, WebSocketVersion version, String subprotocol,
boolean allowExtensions, Map<String, String> customHeaders) {
return newHandshaker(webSocketURL, version, subprotocol, allowExtensions, customHeaders, 65536);
@ -64,7 +70,7 @@ public class WebSocketClientHandshakerFactory {
* Maximum allowable frame payload length. Setting this value to your application's
* requirement may reduce denial of service attacks using long data frames.
*/
public WebSocketClientHandshaker newHandshaker(
public static WebSocketClientHandshaker newHandshaker(
URI webSocketURL, WebSocketVersion version, String subprotocol,
boolean allowExtensions, Map<String, String> customHeaders, int maxFramePayloadLength) {
if (version == V13) {

View File

@ -79,7 +79,7 @@ public class WebSocketClient {
// HttpResponseDecoder to WebSocketHttpResponseDecoder in the pipeline.
final WebSocketClientHandler handler =
new WebSocketClientHandler(
new WebSocketClientHandshakerFactory().newHandshaker(
WebSocketClientHandshakerFactory.newHandshaker(
uri, WebSocketVersion.V13, null, false, customHeaders));
b.group(new NioEventLoopGroup())