Class WebSocketServerHandshakerFactory
- java.lang.Object
-
- io.netty.handler.codec.http.websocketx.WebSocketServerHandshakerFactory
-
public class WebSocketServerHandshakerFactory extends Object
Auto-detects the version of the Web Socket protocol in use and creates a new properWebSocketServerHandshaker
.
-
-
Constructor Summary
Constructors Constructor Description WebSocketServerHandshakerFactory(String webSocketURL, String subprotocols, boolean allowExtensions)
Constructor specifying the destination web socket locationWebSocketServerHandshakerFactory(String webSocketURL, String subprotocols, boolean allowExtensions, int maxFramePayloadLength)
Constructor specifying the destination web socket locationWebSocketServerHandshakerFactory(String webSocketURL, String subprotocols, boolean allowExtensions, int maxFramePayloadLength, boolean allowMaskMismatch)
Constructor specifying the destination web socket locationWebSocketServerHandshakerFactory(String webSocketURL, String subprotocols, WebSocketDecoderConfig decoderConfig)
Constructor specifying the destination web socket location
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description WebSocketServerHandshaker
newHandshaker(HttpRequest req)
Instances a new handshakerstatic WebSocketServerHandshaker
resolveHandshaker(HttpRequest req, String webSocketURL, String subprotocols, WebSocketDecoderConfig decoderConfig)
Resolves the client's WebSocket protocol version from the HTTP request header, and creates the corresponding handshaker.static io.netty.channel.ChannelFuture
sendUnsupportedVersionResponse(io.netty.channel.Channel channel)
Return that we need cannot support the web socket versionstatic io.netty.channel.ChannelFuture
sendUnsupportedVersionResponse(io.netty.channel.Channel channel, io.netty.channel.ChannelPromise promise)
Return that we need cannot support the web socket versionstatic void
sendUnsupportedWebSocketVersionResponse(io.netty.channel.Channel channel)
Deprecated.
-
-
-
Constructor Detail
-
WebSocketServerHandshakerFactory
public WebSocketServerHandshakerFactory(String webSocketURL, String subprotocols, boolean allowExtensions)
Constructor specifying the destination web socket location- Parameters:
webSocketURL
- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.subprotocols
- CSV of supported protocols. Null if sub protocols not supported.allowExtensions
- Allow extensions to be used in the reserved bits of the web socket frame
-
WebSocketServerHandshakerFactory
public WebSocketServerHandshakerFactory(String webSocketURL, String subprotocols, boolean allowExtensions, int maxFramePayloadLength)
Constructor specifying the destination web socket location- Parameters:
webSocketURL
- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.subprotocols
- CSV of supported protocols. Null if sub protocols not supported.allowExtensions
- Allow extensions to be used in the reserved bits of the web socket framemaxFramePayloadLength
- Maximum allowable frame payload length. Setting this value to your application's requirement may reduce denial of service attacks using long data frames.
-
WebSocketServerHandshakerFactory
public WebSocketServerHandshakerFactory(String webSocketURL, String subprotocols, boolean allowExtensions, int maxFramePayloadLength, boolean allowMaskMismatch)
Constructor specifying the destination web socket location- Parameters:
webSocketURL
- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.subprotocols
- CSV of supported protocols. Null if sub protocols not supported.allowExtensions
- Allow extensions to be used in the reserved bits of the web socket framemaxFramePayloadLength
- Maximum allowable frame payload length. Setting this value to your application's requirement may reduce denial of service attacks using long data frames.allowMaskMismatch
- When set to true, frames which are not masked properly according to the standard will still be accepted.
-
WebSocketServerHandshakerFactory
public WebSocketServerHandshakerFactory(String webSocketURL, String subprotocols, WebSocketDecoderConfig decoderConfig)
Constructor specifying the destination web socket location- Parameters:
webSocketURL
- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.subprotocols
- CSV of supported protocols. Null if sub protocols not supported.decoderConfig
- Frames decoder options.
-
-
Method Detail
-
newHandshaker
public WebSocketServerHandshaker newHandshaker(HttpRequest req)
Instances a new handshaker- Returns:
- A new WebSocketServerHandshaker for the requested web socket version. Null if web socket version is not supported.
-
resolveHandshaker
public static WebSocketServerHandshaker resolveHandshaker(HttpRequest req, String webSocketURL, String subprotocols, WebSocketDecoderConfig decoderConfig)
Resolves the client's WebSocket protocol version from the HTTP request header, and creates the corresponding handshaker. This method is identical tonewHandshaker(HttpRequest)
, however it does not require aWebSocketServerHandshakerFactory
instance allocation.- Parameters:
req
- The HTTP request that came from the client to upgrade the protocol to WebSocket.webSocketURL
- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.subprotocols
- CSV of supported protocols. Null if sub protocols not supported.decoderConfig
- Frames decoder options.- Returns:
- A new
WebSocketServerHandshaker
for the requested web socket version. Null if web socket version is not supported. - Throws:
NullPointerException
- if thedecoderConfig
isnull
.
-
sendUnsupportedWebSocketVersionResponse
@Deprecated public static void sendUnsupportedWebSocketVersionResponse(io.netty.channel.Channel channel)
Deprecated.
-
sendUnsupportedVersionResponse
public static io.netty.channel.ChannelFuture sendUnsupportedVersionResponse(io.netty.channel.Channel channel)
Return that we need cannot support the web socket version
-
sendUnsupportedVersionResponse
public static io.netty.channel.ChannelFuture sendUnsupportedVersionResponse(io.netty.channel.Channel channel, io.netty.channel.ChannelPromise promise)
Return that we need cannot support the web socket version
-
-