Interface WebSocketHandler

  • All Known Implementing Classes:
    WebSocketHandlerImpl

    public interface WebSocketHandler
    Handles states for the web socket.
    • Method Detail

      • createUpgradeRequest

        String createUpgradeRequest​(String hostName,
                                    String webSocketPath,
                                    String webSocketQuery,
                                    int webSocketPort,
                                    String webSocketProtocol,
                                    Map<String,​String> additionalHeaders)
        Creates an HTTP request to upgrade to use web sockets.
        Parameters:
        hostName - Name of the host.
        webSocketPath - Path for the websocket.
        webSocketQuery - Query for the web socket.
        webSocketPort - Port for web socket.
        webSocketProtocol - Protocol to use for web sockets.
        additionalHeaders - Any additional headers to add to the HTTP upgrade request.
        Returns:
        Represents the HTTP request.
      • validateUpgradeReply

        Boolean validateUpgradeReply​(ByteBuffer buffer)
        Validates the response.
        Parameters:
        buffer - ByteBuffer to read from.
        Returns:
        True if the response is valid, otherwise, false.
      • wrapBuffer

        void wrapBuffer​(ByteBuffer srcBuffer,
                        ByteBuffer dstBuffer)
        Wraps the source buffer with additional contents from the web socket.
        Parameters:
        srcBuffer - Source buffer to wrap input.
        dstBuffer - Output buffer that bytes are written to.
      • unwrapBuffer

        WebSocketHandler.WebsocketTuple unwrapBuffer​(ByteBuffer srcBuffer)
        Unwraps the layer from the buffer.
        Parameters:
        srcBuffer - The source buffer.
        Returns:
        The current chunk for the web socket when reading.
      • createPong

        void createPong​(ByteBuffer srcBuffer,
                        ByteBuffer dstBuffer)
        Creates the pong for the "keep-alive", heart beat, network status probing when connecting in a web socket.
        Parameters:
        srcBuffer - The source buffer to read from.
        dstBuffer - The destination buffer with the pong.
        See Also:
        Ping and pong
      • calculateHeaderSize

        int calculateHeaderSize​(int payloadSize)
        Gets the size of the header.
        Parameters:
        payloadSize - Size of the payload.
        Returns:
        The size of the header.