public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker
Performs server side opening and closing handshakes for web socket specification version draft-ietf-hybi-thewebsocketprotocol- 10
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
WEBSOCKET_08_ACCEPT_GUID |
HANDSHAKE_LISTENER, SUB_PROTOCOL_WILDCARD
构造器和说明 |
---|
WebSocketServerHandshaker08(java.lang.String webSocketURL,
java.lang.String subprotocols,
boolean allowExtensions)
Constructor using defaults
|
WebSocketServerHandshaker08(java.lang.String webSocketURL,
java.lang.String subprotocols,
boolean allowExtensions,
long maxFramePayloadLength)
Constructor
|
限定符和类型 | 方法和说明 |
---|---|
ChannelFuture |
close(Channel channel,
CloseWebSocketFrame frame)
Echo back the closing frame and close the connection
|
ChannelFuture |
handshake(Channel channel,
HttpRequest req)
Handle the web socket handshake for the web socket specification HyBi version 8 to 10.
|
getMaxFramePayloadLength, getSelectedSubprotocol, getSubprotocols, getVersion, getWebSocketUrl, selectSubprotocol, setSelectedSubprotocol, writeHandshakeResponse
public static final java.lang.String WEBSOCKET_08_ACCEPT_GUID
public WebSocketServerHandshaker08(java.lang.String webSocketURL, java.lang.String subprotocols, boolean allowExtensions)
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 protocolsallowExtensions
- Allow extensions to be used in the reserved bits of the web socket framepublic WebSocketServerHandshaker08(java.lang.String webSocketURL, java.lang.String subprotocols, boolean allowExtensions, long 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 protocolsallowExtensions
- 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.public ChannelFuture handshake(Channel channel, HttpRequest req)
Handle the web socket handshake for the web socket specification HyBi version 8 to 10. Version 8, 9 and 10 share the same wire protocol.
Browser request to the server:
GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== Sec-WebSocket-Origin: http://example.com Sec-WebSocket-Protocol: chat, superchat Sec-WebSocket-Version: 8
Server response:
HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= Sec-WebSocket-Protocol: chat
handshake
在类中 WebSocketServerHandshaker
channel
- Channelreq
- HTTP requestpublic ChannelFuture close(Channel channel, CloseWebSocketFrame frame)
close
在类中 WebSocketServerHandshaker
channel
- Channelframe
- Web Socket frame that was received