Class WebSocketServerHandshaker00
java.lang.Object
io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker
io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker00
Performs server side opening and closing handshakes for web socket specification version draft-ietf-hybi-thewebsocketprotocol- 00
A very large portion of this code was taken from the Netty 3.2 HTTP example.
-
Field Summary
Fields inherited from class io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker
logger, SUB_PROTOCOL_WILDCARD -
Constructor Summary
ConstructorsConstructorDescriptionWebSocketServerHandshaker00(String webSocketURL, String subprotocols, int maxFramePayloadLength) Constructor specifying the destination web socket locationWebSocketServerHandshaker00(String webSocketURL, String subprotocols, WebSocketDecoderConfig decoderConfig) Constructor specifying the destination web socket location -
Method Summary
Modifier and TypeMethodDescriptionio.netty.channel.ChannelFutureclose(io.netty.channel.ChannelHandlerContext ctx, CloseWebSocketFrame frame, io.netty.channel.ChannelPromise promise) Echo back the closing frameio.netty.channel.ChannelFutureclose(io.netty.channel.Channel channel, CloseWebSocketFrame frame, io.netty.channel.ChannelPromise promise) Echo back the closing frameprotected FullHttpResponsenewHandshakeResponse(FullHttpRequest req, HttpHeaders headers) Handle the web socket handshake for the web socket specification HyBi version 0 and lower.protected WebSocketFrameDecoderReturns the decoder to use after handshake is complete.protected WebSocketFrameEncoderReturns the encoder to use after the handshake is complete.Methods inherited from class io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker
close, close, decoderConfig, handshake, handshake, handshake, handshake, maxFramePayloadLength, selectedSubprotocol, selectSubprotocol, subprotocols, uri, version
-
Constructor Details
-
WebSocketServerHandshaker00
public WebSocketServerHandshaker00(String webSocketURL, String subprotocols, 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 protocolsmaxFramePayloadLength- Maximum allowable frame payload length. Setting this value to your application's requirement may reduce denial of service attacks using long data frames.
-
WebSocketServerHandshaker00
public WebSocketServerHandshaker00(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 protocolsdecoderConfig- Frames decoder configuration.
-
-
Method Details
-
newHandshakeResponse
Handle the web socket handshake for the web socket specification HyBi version 0 and lower. This standard is really a rehash of hixie-76 and hixie-75.
Browser request to the server:
GET /demo HTTP/1.1 Upgrade: WebSocket Connection: Upgrade Host: example.com Origin: http://example.com Sec-WebSocket-Protocol: chat, sample Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5 Sec-WebSocket-Key2: 12998 5 Y3 1 .P00 ^n:ds[4U
Server response:
HTTP/1.1 101 WebSocket Protocol Handshake Upgrade: WebSocket Connection: Upgrade Sec-WebSocket-Origin: http://example.com Sec-WebSocket-Location: ws://example.com/demo Sec-WebSocket-Protocol: sample 8jKS'y:G*Co,Wxa-
- Specified by:
newHandshakeResponsein classWebSocketServerHandshaker
-
close
public io.netty.channel.ChannelFuture close(io.netty.channel.Channel channel, CloseWebSocketFrame frame, io.netty.channel.ChannelPromise promise) Echo back the closing frame- Overrides:
closein classWebSocketServerHandshaker- Parameters:
channel- theChannelto use.frame- Web Socket frame that was received.promise- theChannelPromiseto be notified when the closing handshake is done.
-
close
public io.netty.channel.ChannelFuture close(io.netty.channel.ChannelHandlerContext ctx, CloseWebSocketFrame frame, io.netty.channel.ChannelPromise promise) Echo back the closing frame- Overrides:
closein classWebSocketServerHandshaker- Parameters:
ctx- theChannelHandlerContextto use.frame- Closing Frame that was received.promise- theChannelPromiseto be notified when the closing handshake is done.
-
newWebsocketDecoder
Description copied from class:WebSocketServerHandshakerReturns the decoder to use after handshake is complete.- Specified by:
newWebsocketDecoderin classWebSocketServerHandshaker
-
newWebSocketEncoder
Description copied from class:WebSocketServerHandshakerReturns the encoder to use after the handshake is complete.- Specified by:
newWebSocketEncoderin classWebSocketServerHandshaker
-