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

## Class WebSocketServerHandshaker08

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

-     public class WebSocketServerHandshaker08
      extends WebSocketServerHandshaker

  Performs server side opening and closing handshakes for web socket specification version draft-ietf-hybi-thewebsocketprotocol- 10

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `WEBSOCKET_08_ACCEPT_GUID`

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

      `HANDSHAKE_LISTENER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `WebSocketServerHandshaker08(String webSocketURL, String subprotocols, boolean allowExtensions)` Constructor using defaults
    `WebSocketServerHandshaker08(String webSocketURL, String subprotocols, boolean allowExtensions, long maxFramePayloadLength)` Constructor

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `ChannelFuture` | `close(Channel channel, CloseWebSocketFrame frame)` Echo back the closing frame and close the connection
    `ChannelFuture` | `handshake(Channel channel, HttpRequest req)` Handle the web socket handshake for the web socket specification HyBi version 8 to 10.

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

      `getMaxFramePayloadLength, getSelectedSubprotocol, getSubprotocols, getVersion, getWebSocketUrl, selectSubprotocol, setSelectedSubprotocol`

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

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

- - ### Field Detail

    - #### WEBSOCKET_08_ACCEPT_GUID

          public static final String WEBSOCKET_08_ACCEPT_GUID

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### WebSocketServerHandshaker08

          public WebSocketServerHandshaker08(String webSocketURL,
                                     String subprotocols,
                                     boolean allowExtensions)

      Constructor using defaults
      Parameters:
        `webSocketURL` - URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.
        `subprotocols` - CSV of supported protocols
        `allowExtensions` - Allow extensions to be used in the reserved bits of the web socket frame

    - #### WebSocketServerHandshaker08

          public WebSocketServerHandshaker08(String webSocketURL,
                                     String subprotocols,
                                     boolean allowExtensions,
                                     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.
        `subprotocols` - CSV of supported protocols
        `allowExtensions` - Allow extensions to be used in the reserved bits of the web socket frame
        `maxFramePayloadLength` - Maximum allowable frame payload length. Setting this value to your application's requirement may reduce denial of service attacks using long data frames.

  - ### Method Detail

    - #### handshake

          public ChannelFuture handshake(Channel channel,
                                HttpRequest req)

      Handle the web socket handshake for the web socket specification HyBi version 8 to 10. Version 8, 9 and 10 share the same wire protocol.

      Browser 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

      Server response:

           HTTP/1.1 101 Switching Protocols
           Upgrade: websocket
           Connection: Upgrade
           Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
           Sec-WebSocket-Protocol: chat

      Specified by:
        `handshake` in class `WebSocketServerHandshaker`
      Parameters:
        `channel` - Channel
        `req` - HTTP request

    - #### close

          public ChannelFuture close(Channel channel,
                            CloseWebSocketFrame frame)

      Echo back the closing frame and close the connection
      Specified by:
        `close` in class `WebSocketServerHandshaker`
      Parameters:
        `channel` - Channel
        `frame` - Web Socket frame that was received

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