tigase.server.websocket

## Interface WebSocketProtocolIfc

- All Known Implementing Classes:
    WebSocketHixie76, WebSocketHybi

      public interface WebSocketProtocolIfc

  Interface which needs to be implemented by any implemention of version of WebSocket protocol.
  Currently we have stable version but there were older not compatible with current so it may be that new will come in future - also not compatible.
  Author:
    andrzej

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `WS_PROTOCOL_KEY` HTTP header which contains name of subprotocol which should be used over established WebSocket connection
    `static String` | `WS_VERSION_KEY` HTTP header used by WebSocket to pass used version of WebSocket protocol from client to server

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `closeConnection(WebSocketXMPPIOService service)` Method closes connection by sending close frame
    `ByteBuffer` | `decodeFrame(WebSocketXMPPIOService service, ByteBuffer buf)` Method responsible for decoding data received from socket and returning data after extracting it from WebSocket frame.
    `void` | `encodeFrameAndWrite(WebSocketXMPPIOService service, ByteBuffer buf)` Method encodes data into WebSocket frame and writes it to passed service
    `String` | `getId()` Method to retrieve string identifier of implementation of protcol version
    `boolean` | `handshake(WebSocketXMPPIOService service, Map<String,String> headers, byte[] buf)` Method responsible for handshaking of WebSocket using proper version of protocol.

- - ### Field Detail

    - #### WS_VERSION_KEY

          static final String WS_VERSION_KEY

      HTTP header used by WebSocket to pass used version of WebSocket protocol from client to server
      See Also:
        Constant Field Values

    - #### WS_PROTOCOL_KEY

          static final String WS_PROTOCOL_KEY

      HTTP header which contains name of subprotocol which should be used over established WebSocket connection
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getId

          String getId()

      Method to retrieve string identifier of implementation of protcol version

    - #### handshake

          boolean handshake(WebSocketXMPPIOService service,
                            Map<String,String> headers,
                            byte[] buf)
                     throws NoSuchAlgorithmException,
                            IOException

      Method responsible for handshaking of WebSocket using proper version of protocol.
      Returns:
        false - if implementation is not able to handshake using this version of protocol, in other case return true
      Throws:
        `NoSuchAlgorithmException`
        `IOException`

    - #### decodeFrame

          ByteBuffer decodeFrame(WebSocketXMPPIOService service,
                                 ByteBuffer buf)

      Method responsible for decoding data received from socket and returning data after extracting it from WebSocket frame.
      Returns:
        decoded data or null if not full frame is available in input buffer

    - #### encodeFrameAndWrite

          void encodeFrameAndWrite(WebSocketXMPPIOService service,
                                   ByteBuffer buf)
                            throws IOException

      Method encodes data into WebSocket frame and writes it to passed service
      Throws:
        `IOException`

    - #### closeConnection

          void closeConnection(WebSocketXMPPIOService service)

      Method closes connection by sending close frame

Copyright © 2004–2021 "Tigase, Inc.". All rights reserved.