Top Description Fields Constructors Methods
io.netty.handler.codec.http.websocketx

public Class WebSocketServerHandshaker00

extends WebSocketServerHandshaker
Class Inheritance
Imports
io.netty.buffer.ByteBuf, .Unpooled, io.netty.channel.Channel, .ChannelFuture, .ChannelHandlerContext, .ChannelPromise, io.netty.handler.codec.http.DefaultFullHttpResponse, .FullHttpRequest, .FullHttpResponse, .HttpHeaderNames, .HttpHeaderValues, .HttpHeaders, .HttpMethod, .HttpResponseStatus, java.util.regex.Pattern

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

Modifier and TypeField and Description
private static final Pattern
private static final Pattern
Inherited from io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker:
loggerSUB_PROTOCOL_WILDCARD

Constructor Summary

AccessConstructor and Description
public
WebSocketServerHandshaker00(String
URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.
webSocketURL
,
String
CSV of supported protocols
subprotocols
,
int
Maximum allowable frame payload length. Setting this value to your application's requirement may reduce denial of service attacks using long data frames.
maxFramePayloadLength
)

Constructor specifying the destination web socket location

public
WebSocketServerHandshaker00(String
URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.
webSocketURL
,
String
CSV of supported protocols
subprotocols
,
WebSocketDecoderConfig
Frames decoder configuration.
decoderConfig
)

Constructor specifying the destination web socket location

Method Summary

Modifier and TypeMethod and Description
public ChannelFuture
close(Channel
the Channel to use.
channel
,
CloseWebSocketFrame
Web Socket frame that was received.
frame
,
ChannelPromise
the ChannelPromise to be notified when the closing handshake is done.
promise
)

Overrides io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker.close.

Echo back the closing frame
public ChannelFuture
close(ChannelHandlerContext ctx, CloseWebSocketFrame
Closing Frame that was received.
frame
,
ChannelPromise
the ChannelPromise to be notified when the closing handshake is done.
promise
)

Overrides io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker.close.

Echo back the closing frame
protected FullHttpResponse
newHandshakeResponse(FullHttpRequest req, HttpHeaders headers)

Implements abstract io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker.newHandshakeResponse.

Handle the web socket handshake for the web socket specification HyBi version 0 and lower.

protected WebSocketFrameDecoder
newWebsocketDecoder()

Implements abstract io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker.newWebsocketDecoder.

Returns the decoder to use after handshake is complete.
protected WebSocketFrameEncoder
newWebSocketEncoder()

Implements abstract io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker.newWebSocketEncoder.

Returns the encoder to use after the handshake is complete.
Inherited from io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker:
closeclosedecoderConfighandshakehandshakehandshakehandshakemaxFramePayloadLengthselectedSubprotocolselectSubprotocolsubprotocolsuriversion

Field Detail

BEGINNING_DIGITback to summary
private static final Pattern BEGINNING_DIGIT
BEGINNING_SPACEback to summary
private static final Pattern BEGINNING_SPACE

Constructor Detail

WebSocketServerHandshaker00back to summary
public WebSocketServerHandshaker00(String webSocketURL, String subprotocols, int maxFramePayloadLength)

Constructor specifying the destination web socket location

Parameters
webSocketURL:String

URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.

subprotocols:String

CSV of supported protocols

maxFramePayloadLength:int

Maximum allowable frame payload length. Setting this value to your application's requirement may reduce denial of service attacks using long data frames.

WebSocketServerHandshaker00back to summary
public WebSocketServerHandshaker00(String webSocketURL, String subprotocols, WebSocketDecoderConfig decoderConfig)

Constructor specifying the destination web socket location

Parameters
webSocketURL:String

URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.

subprotocols:String

CSV of supported protocols

decoderConfig:WebSocketDecoderConfig

Frames decoder configuration.

Method Detail

closeback to summary
public ChannelFuture close(Channel channel, CloseWebSocketFrame frame, ChannelPromise promise)

Overrides io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker.close.

Echo back the closing frame

Parameters
channel:Channel

the Channel to use.

frame:CloseWebSocketFrame

Web Socket frame that was received.

promise:ChannelPromise

the ChannelPromise to be notified when the closing handshake is done.

Annotations
@Override
closeback to summary
public ChannelFuture close(ChannelHandlerContext ctx, CloseWebSocketFrame frame, ChannelPromise promise)

Overrides io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker.close.

Echo back the closing frame

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext to use.

frame:CloseWebSocketFrame

Closing Frame that was received.

promise:ChannelPromise

the ChannelPromise to be notified when the closing handshake is done.

Annotations
@Override
newHandshakeResponseback to summary
protected FullHttpResponse newHandshakeResponse(FullHttpRequest req, HttpHeaders headers)

Implements abstract io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker.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-
Annotations
@Override
newWebsocketDecoderback to summary
protected WebSocketFrameDecoder newWebsocketDecoder()

Implements abstract io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker.newWebsocketDecoder.

Doc from io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker.newWebsocketDecoder.

Returns the decoder to use after handshake is complete.

Annotations
@Override
newWebSocketEncoderback to summary
protected WebSocketFrameEncoder newWebSocketEncoder()

Implements abstract io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker.newWebSocketEncoder.

Doc from io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker.newWebSocketEncoder.

Returns the encoder to use after the handshake is complete.

Annotations
@Override