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

## Class WebSocketClientHandshaker

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

- Direct Known Subclasses:
    WebSocketClientHandshaker00, WebSocketClientHandshaker08, WebSocketClientHandshaker13

      public abstract class WebSocketClientHandshaker
      extends Object

  Base class for web socket client handshake implementations

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Map<String,String>` | `customHeaders`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `WebSocketClientHandshaker(URI webSocketUrl, WebSocketVersion version, String subprotocol, Map<String,String> customHeaders)` Base constructor with default values
    `WebSocketClientHandshaker(URI webSocketUrl, WebSocketVersion version, String subprotocol, Map<String,String> customHeaders, long maxFramePayloadLength)` Base constructor

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `finishHandshake(Channel channel, HttpResponse response)` Validates and finishes the opening handshake initiated by `handshake(org.jboss.netty.channel.Channel)`}.
    `String` | `getActualSubprotocol()` Returns the subprotocol response sent by the server.
    `String` | `getExpectedSubprotocol()` Returns the CSV of requested subprotocol(s) sent to the server as specified in the constructor
    `long` | `getMaxFramePayloadLength()` Returns the max length for any frame's payload
    `WebSocketVersion` | `getVersion()` Version of the web socket specification that is being used
    `URI` | `getWebSocketUrl()` Returns the URI to the web socket. e.g.
    `abstract ChannelFuture` | `handshake(Channel channel)` Begins the opening handshake
    `boolean` | `isHandshakeComplete()` Flag to indicate if the opening handshake is complete
    `protected void` | `setActualSubprotocol(String actualSubprotocol)`
    `protected void` | `setHandshakeComplete()`

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

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

- - ### Field Detail

    - #### customHeaders

          protected final Map<String,String> customHeaders

  - ### Constructor Detail

    - #### WebSocketClientHandshaker

          public WebSocketClientHandshaker(URI webSocketUrl,
                                   WebSocketVersion version,
                                   String subprotocol,
                                   Map<String,String> customHeaders)

      Base 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

    - #### WebSocketClientHandshaker

          public WebSocketClientHandshaker(URI webSocketUrl,
                                   WebSocketVersion version,
                                   String subprotocol,
                                   Map<String,String> customHeaders,
                                   long maxFramePayloadLength)

      Base 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` - CSV of requested subprotocol(s) 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

    - #### getWebSocketUrl

          public URI getWebSocketUrl()

      Returns the URI to the web socket. e.g. "ws://myhost.com/path"

    - #### getVersion

          public WebSocketVersion getVersion()

      Version of the web socket specification that is being used

    - #### getMaxFramePayloadLength

          public long getMaxFramePayloadLength()

      Returns the max length for any frame's payload

    - #### isHandshakeComplete

          public boolean isHandshakeComplete()

      Flag to indicate if the opening handshake is complete

    - #### setHandshakeComplete

          protected void setHandshakeComplete()

    - #### getExpectedSubprotocol

          public String getExpectedSubprotocol()

      Returns the CSV of requested subprotocol(s) sent to the server as specified in the constructor

    - #### getActualSubprotocol

          public String getActualSubprotocol()

      Returns the subprotocol response sent by the server. Only available after end of handshake. Null if no subprotocol was requested or confirmed by the server.

    - #### setActualSubprotocol

          protected void setActualSubprotocol(String actualSubprotocol)

    - #### handshake

          public abstract ChannelFuture handshake(Channel channel)
                                           throws Exception

      Begins the opening handshake
      Parameters:
        `channel` - Channel
      Throws:
        `Exception`

    - #### finishHandshake

          public abstract void finishHandshake(Channel channel,
                             HttpResponse response)

      Validates and finishes the opening handshake initiated by `handshake(org.jboss.netty.channel.Channel)`}.
      Parameters:
        `channel` - Channel
        `response` - HTTP response containing the closing handshake details

Copyright © 2008-2012 The Netty Project. All Rights Reserved.