public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker
Performs client 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.
customHeaders
Constructor and Description |
---|
WebSocketClientHandshaker00(java.net.URI webSocketURL,
WebSocketVersion version,
java.lang.String subprotocol,
HttpHeaders customHeaders,
int maxFramePayloadLength)
Constructor specifying the destination web socket location and version to initiate
|
Modifier and Type | Method and Description |
---|---|
protected FullHttpRequest |
newHandshakeRequest()
Sends the opening request to the server:
GET /demo HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Host: example.com
Origin: http://example.com
Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5
Sec-WebSocket-Key2: 12998 5 Y3 1 .P00
^n:ds[4U
|
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.
|
protected void |
verify(FullHttpResponse response)
Process 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-
|
actualSubprotocol, close, close, expectedSubprotocol, finishHandshake, handshake, handshake, isHandshakeComplete, maxFramePayloadLength, processHandshake, processHandshake, uri, version
public WebSocketClientHandshaker00(java.net.URI webSocketURL, WebSocketVersion version, java.lang.String subprotocol, 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.customHeaders
- Map of custom headers to add to the client requestmaxFramePayloadLength
- Maximum length of a frame's payloadprotected FullHttpRequest newHandshakeRequest()
Sends the opening request to the server:
GET /demo HTTP/1.1 Upgrade: WebSocket Connection: Upgrade Host: example.com Origin: http://example.com Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5 Sec-WebSocket-Key2: 12998 5 Y3 1 .P00 ^n:ds[4U
newHandshakeRequest
in class WebSocketClientHandshaker
protected void verify(FullHttpResponse response)
Process 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-
verify
in class WebSocketClientHandshaker
response
- HTTP response returned from the server for the request sent by beginOpeningHandshake00().WebSocketHandshakeException
protected WebSocketFrameDecoder newWebsocketDecoder()
WebSocketClientHandshaker
newWebsocketDecoder
in class WebSocketClientHandshaker
protected WebSocketFrameEncoder newWebSocketEncoder()
WebSocketClientHandshaker
newWebSocketEncoder
in class WebSocketClientHandshaker
Copyright © 2008–2018 The Netty Project. All rights reserved.