org.jboss.netty.handler.codec.http.websocketx

## Class WebSocketClientHandshaker00

- java.lang.Object
- - org.jboss.netty.handler.codec.http.websocketx.WebSocketClientHandshaker
  - - org.jboss.netty.handler.codec.http.websocketx.WebSocketClientHandshaker00

    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.

### Field Summary

### Fields inherited from class org.jboss.netty.handler.codec.http.websocketx.WebSocketClientHandshaker

`customHeaders`

### Constructor Summary

Constructors
Constructor and Description
`WebSocketClientHandshaker00(URI webSocketURL, WebSocketVersion version, String subprotocol, Map<String,String> customHeaders)` Constructor with default values
`WebSocketClientHandshaker00(URI webSocketURL, WebSocketVersion version, String subprotocol, Map<String,String> customHeaders, long maxFramePayloadLength)` Constructor

### Method Summary

Methods
`void` `finishHandshake(Channel channel, HttpResponse 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-
`ChannelFuture` `handshake(Channel channel)` 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

### Methods inherited from class org.jboss.netty.handler.codec.http.websocketx.WebSocketClientHandshaker

`getActualSubprotocol, getExpectedSubprotocol, getMaxFramePayloadLength, getVersion, getWebSocketUrl, isHandshakeComplete, setActualSubprotocol, setHandshakeComplete`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### WebSocketClientHandshaker00

    public WebSocketClientHandshaker00(URI webSocketURL,
                               WebSocketVersion version,
                               String subprotocol,
                               Map<String,String> customHeaders)

Constructor with default values

Parameters:
  `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 server
  `subprotocol` - Sub protocol request sent to the server.
  `customHeaders` - Map of custom headers to add to the client request

#### WebSocketClientHandshaker00

    public WebSocketClientHandshaker00(URI webSocketURL,
                               WebSocketVersion version,
                               String subprotocol,
                               Map<String,String> customHeaders,
                               long maxFramePayloadLength)

Constructor

Parameters:
  `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 server
  `subprotocol` - Sub protocol request sent to the server.
  `customHeaders` - Map of custom headers to add to the client request
  `maxFramePayloadLength` - Maximum length of a frame's payload

### Method Detail

#### handshake

    public ChannelFuture handshake(Channel channel)

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

Specified by:
  `handshake` in class `WebSocketClientHandshaker`
Parameters:
  `channel` - Channel into which we can write our request

#### finishHandshake

    public void finishHandshake(Channel channel,
                       HttpResponse response)
                         throws WebSocketHandshakeException

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-

Specified by:
  `finishHandshake` in class `WebSocketClientHandshaker`
Parameters:
  `channel` - Channel
  `response` - HTTP response returned from the server for the request sent by beginOpeningHandshake00().
Throws:
  `WebSocketHandshakeException`