public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker
Performs client side opening and closing handshakes for web socket specification version draft-ietf-hybi-thewebsocketprotocol- 10
Modifier and Type | Field and Description |
---|---|
static String |
MAGIC_GUID |
customHeaders
Constructor and Description |
---|
WebSocketClientHandshaker08(URI webSocketURL,
WebSocketVersion version,
String subprotocol,
boolean allowExtensions,
Map<String,String> customHeaders)
Constructor with default values
|
WebSocketClientHandshaker08(URI webSocketURL,
WebSocketVersion version,
String subprotocol,
boolean allowExtensions,
Map<String,String> customHeaders,
long maxFramePayloadLength)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
finishHandshake(Channel channel,
HttpResponse response)
Process server response:
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Sec-WebSocket-Protocol: chat
|
ChannelFuture |
handshake(Channel channel)
/**
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-Origin: http://example.com
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 8
|
getActualSubprotocol, getExpectedSubprotocol, getMaxFramePayloadLength, getVersion, getWebSocketUrl, isHandshakeComplete, setActualSubprotocol, setHandshakeComplete
public static final String MAGIC_GUID
public WebSocketClientHandshaker08(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, Map<String,String> customHeaders)
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 requestpublic WebSocketClientHandshaker08(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, Map<String,String> customHeaders, long 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 ChannelFuture handshake(Channel channel) throws Exception
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-Origin: http://example.com Sec-WebSocket-Protocol: chat, superchat Sec-WebSocket-Version: 8
handshake
in class WebSocketClientHandshaker
channel
- Channel into which we can write our requestException
public void finishHandshake(Channel channel, HttpResponse response)
Process server response:
HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= Sec-WebSocket-Protocol: chat
finishHandshake
in class WebSocketClientHandshaker
channel
- Channelresponse
- HTTP response returned from the server for the request sent by beginOpeningHandshake00().WebSocketHandshakeException
Copyright © 2008-2013 The Netty Project. All Rights Reserved.