public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker
Performs client side opening and closing handshakes for web socket specification version draft-ietf-hybi-thewebsocketprotocol- 17
Modifier and Type | Field and Description |
---|---|
static String |
MAGIC_GUID |
customHeaders, DEFAULT_FORCE_CLOSE_TIMEOUT_MILLIS, generateOriginHeader
Constructor and Description |
---|
WebSocketClientHandshaker13(URI webSocketURL,
WebSocketVersion version,
String subprotocol,
boolean allowExtensions,
HttpHeaders customHeaders,
int maxFramePayloadLength)
Creates a new instance.
|
WebSocketClientHandshaker13(URI webSocketURL,
WebSocketVersion version,
String subprotocol,
boolean allowExtensions,
HttpHeaders customHeaders,
int maxFramePayloadLength,
boolean performMasking,
boolean allowMaskMismatch)
Creates a new instance.
|
WebSocketClientHandshaker13(URI webSocketURL,
WebSocketVersion version,
String subprotocol,
boolean allowExtensions,
HttpHeaders customHeaders,
int maxFramePayloadLength,
boolean performMasking,
boolean allowMaskMismatch,
long forceCloseTimeoutMillis)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isAllowExtensions() |
boolean |
isAllowMaskMismatch() |
boolean |
isPerformMasking() |
protected FullHttpRequest |
newHandshakeRequest()
/**
Sends the opening request to the server:
GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 13
|
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.
|
WebSocketClientHandshaker13 |
setForceCloseTimeoutMillis(long forceCloseTimeoutMillis)
Sets timeout to close the connection if it was not closed by the server.
|
protected void |
verify(FullHttpResponse response)
Process server response:
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Sec-WebSocket-Protocol: chat
|
actualSubprotocol, close, close, close, close, expectedSubprotocol, finishHandshake, forceCloseTimeoutMillis, handshake, handshake, isForceCloseComplete, isHandshakeComplete, maxFramePayloadLength, processHandshake, processHandshake, upgradeUrl, uri, version
public static final String MAGIC_GUID
public WebSocketClientHandshaker13(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength)
webSocketURL
- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be
sent to this URL.version
- Version of web socket specification to use to connect to the serversubprotocol
- Sub protocol request sent to the server.allowExtensions
- Allow extensions to be used in the reserved bits of the web socket framecustomHeaders
- Map of custom headers to add to the client requestmaxFramePayloadLength
- Maximum length of a frame's payloadpublic WebSocketClientHandshaker13(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength, boolean performMasking, boolean allowMaskMismatch)
webSocketURL
- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be
sent to this URL.version
- Version of web socket specification to use to connect to the serversubprotocol
- Sub protocol request sent to the server.allowExtensions
- Allow extensions to be used in the reserved bits of the web socket framecustomHeaders
- Map of custom headers to add to the client requestmaxFramePayloadLength
- Maximum length of a frame's payloadperformMasking
- Whether to mask all written websocket frames. This must be set to true in order to be fully compatible
with the websocket specifications. Client applications that communicate with a non-standard server
which doesn't require masking might set this to false to achieve a higher performance.allowMaskMismatch
- When set to true, frames which are not masked properly according to the standard will still be
accepted.public WebSocketClientHandshaker13(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength, boolean performMasking, boolean allowMaskMismatch, long forceCloseTimeoutMillis)
webSocketURL
- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be
sent to this URL.version
- Version of web socket specification to use to connect to the serversubprotocol
- Sub protocol request sent to the server.allowExtensions
- Allow extensions to be used in the reserved bits of the web socket framecustomHeaders
- Map of custom headers to add to the client requestmaxFramePayloadLength
- Maximum length of a frame's payloadperformMasking
- Whether to mask all written websocket frames. This must be set to true in order to be fully compatible
with the websocket specifications. Client applications that communicate with a non-standard server
which doesn't require masking might set this to false to achieve a higher performance.allowMaskMismatch
- When set to true, frames which are not masked properly according to the standard will still be
acceptedforceCloseTimeoutMillis
- Close the connection if it was not closed by the server after timeout specified.protected FullHttpRequest newHandshakeRequest()
Sends the opening request to the server:
GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== Sec-WebSocket-Protocol: chat, superchat Sec-WebSocket-Version: 13
newHandshakeRequest
in class WebSocketClientHandshaker
protected void verify(FullHttpResponse response)
Process server response:
HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= Sec-WebSocket-Protocol: chat
verify
in class WebSocketClientHandshaker
response
- HTTP response returned from the server for the request sent by beginOpeningHandshake00().WebSocketHandshakeException
- if handshake response is invalid.protected WebSocketFrameDecoder newWebsocketDecoder()
WebSocketClientHandshaker
newWebsocketDecoder
in class WebSocketClientHandshaker
protected WebSocketFrameEncoder newWebSocketEncoder()
WebSocketClientHandshaker
newWebSocketEncoder
in class WebSocketClientHandshaker
public WebSocketClientHandshaker13 setForceCloseTimeoutMillis(long forceCloseTimeoutMillis)
WebSocketClientHandshaker
setForceCloseTimeoutMillis
in class WebSocketClientHandshaker
forceCloseTimeoutMillis
- Close the connection if it was not closed by the server after timeout specifiedpublic boolean isAllowExtensions()
public boolean isPerformMasking()
public boolean isAllowMaskMismatch()
Copyright © 2008–2024 The Netty Project. All rights reserved.