public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker
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.
logger, SUB_PROTOCOL_WILDCARD| 构造器和说明 |
|---|
WebSocketServerHandshaker00(java.lang.String webSocketURL,
java.lang.String subprotocols,
int maxFramePayloadLength)
Constructor specifying the destination web socket location
|
WebSocketServerHandshaker00(java.lang.String webSocketURL,
java.lang.String subprotocols,
WebSocketDecoderConfig decoderConfig)
Constructor specifying the destination web socket location
|
| 限定符和类型 | 方法和说明 |
|---|---|
ChannelFuture |
close(Channel channel,
CloseWebSocketFrame frame,
ChannelPromise promise)
Echo back the closing frame
|
ChannelFuture |
close(ChannelHandlerContext ctx,
CloseWebSocketFrame frame,
ChannelPromise promise)
Echo back the closing frame
|
protected FullHttpResponse |
newHandshakeResponse(FullHttpRequest req,
HttpHeaders headers)
Handle the web socket handshake for the web socket specification HyBi version 0 and lower.
|
protected WebSocketFrameDecoder |
newWebsocketDecoder()
Returns the decoder to use after handshake is complete.
|
protected WebSocketFrameEncoder |
newWebSocketEncoder()
Returns the encoder to use after the handshake is complete.
|
close, close, decoderConfig, handshake, handshake, handshake, handshake, maxFramePayloadLength, selectedSubprotocol, selectSubprotocol, subprotocols, uri, versionpublic WebSocketServerHandshaker00(java.lang.String webSocketURL,
java.lang.String subprotocols,
int maxFramePayloadLength)
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.public WebSocketServerHandshaker00(java.lang.String webSocketURL,
java.lang.String subprotocols,
WebSocketDecoderConfig decoderConfig)
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.protected FullHttpResponse newHandshakeResponse(FullHttpRequest req, HttpHeaders headers)
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-
public ChannelFuture close(Channel channel, CloseWebSocketFrame frame, ChannelPromise promise)
close 在类中 WebSocketServerHandshakerchannel - the Channel to use.frame - Web Socket frame that was received.promise - the ChannelPromise to be notified when the closing handshake is done.public ChannelFuture close(ChannelHandlerContext ctx, CloseWebSocketFrame frame, ChannelPromise promise)
close 在类中 WebSocketServerHandshakerctx - the ChannelHandlerContext to use.frame - Closing Frame that was received.promise - the ChannelPromise to be notified when the closing handshake is done.protected WebSocketFrameDecoder newWebsocketDecoder()
WebSocketServerHandshakerprotected WebSocketFrameEncoder newWebSocketEncoder()
WebSocketServerHandshaker