Class WebSocketHandlerImpl

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int calculateHeaderSize​(int payloadSize)
      Gets the size of the header.
      void createPong​(java.nio.ByteBuffer ping, java.nio.ByteBuffer pong)
      Creates the pong for the "keep-alive", heart beat, network status probing when connecting in a web socket.
      protected byte[] createRandomMaskingKey()  
      java.lang.String createUpgradeRequest​(java.lang.String hostName, java.lang.String webSocketPath, java.lang.String webSocketQuery, int webSocketPort, java.lang.String webSocketProtocol, java.util.Map<java.lang.String,​java.lang.String> additionalHeaders)
      Creates an HTTP request to upgrade to use web sockets.
      protected WebSocketUpgrade createWebSocketUpgrade​(java.lang.String hostName, java.lang.String webSocketPath, java.lang.String webSocketQuery, int webSocketPort, java.lang.String webSocketProtocol, java.util.Map<java.lang.String,​java.lang.String> additionalHeaders)  
      WebSocketHandler.WebsocketTuple unwrapBuffer​(java.nio.ByteBuffer srcBuffer)
      Unwraps the layer from the buffer.
      java.lang.Boolean validateUpgradeReply​(java.nio.ByteBuffer buffer)
      Validates the response.
      void wrapBuffer​(java.nio.ByteBuffer srcBuffer, java.nio.ByteBuffer dstBuffer)
      Wraps the source buffer with additional contents from the web socket.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WebSocketHandlerImpl

        public WebSocketHandlerImpl()
    • Method Detail

      • createUpgradeRequest

        public java.lang.String createUpgradeRequest​(java.lang.String hostName,
                                                     java.lang.String webSocketPath,
                                                     java.lang.String webSocketQuery,
                                                     int webSocketPort,
                                                     java.lang.String webSocketProtocol,
                                                     java.util.Map<java.lang.String,​java.lang.String> additionalHeaders)
        Description copied from interface: WebSocketHandler
        Creates an HTTP request to upgrade to use web sockets.
        Specified by:
        createUpgradeRequest in interface WebSocketHandler
        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.
      • createPong

        public void createPong​(java.nio.ByteBuffer ping,
                               java.nio.ByteBuffer pong)
        Description copied from interface: WebSocketHandler
        Creates the pong for the "keep-alive", heart beat, network status probing when connecting in a web socket.
        Specified by:
        createPong in interface WebSocketHandler
        Parameters:
        ping - The source buffer to read from.
        pong - The destination buffer with the pong.
        See Also:
        Ping and pong
      • validateUpgradeReply

        public java.lang.Boolean validateUpgradeReply​(java.nio.ByteBuffer buffer)
        Description copied from interface: WebSocketHandler
        Validates the response.
        Specified by:
        validateUpgradeReply in interface WebSocketHandler
        Parameters:
        buffer - ByteBuffer to read from.
        Returns:
        True if the response is valid, otherwise, false.
      • wrapBuffer

        public void wrapBuffer​(java.nio.ByteBuffer srcBuffer,
                               java.nio.ByteBuffer dstBuffer)
        Description copied from interface: WebSocketHandler
        Wraps the source buffer with additional contents from the web socket.
        Specified by:
        wrapBuffer in interface WebSocketHandler
        Parameters:
        srcBuffer - Source buffer to wrap input.
        dstBuffer - Output buffer that bytes are written to.
      • createWebSocketUpgrade

        protected WebSocketUpgrade createWebSocketUpgrade​(java.lang.String hostName,
                                                          java.lang.String webSocketPath,
                                                          java.lang.String webSocketQuery,
                                                          int webSocketPort,
                                                          java.lang.String webSocketProtocol,
                                                          java.util.Map<java.lang.String,​java.lang.String> additionalHeaders)
      • createRandomMaskingKey

        protected byte[] createRandomMaskingKey()
      • calculateHeaderSize

        public int calculateHeaderSize​(int payloadSize)
        Description copied from interface: WebSocketHandler
        Gets the size of the header.
        Specified by:
        calculateHeaderSize in interface WebSocketHandler
        Parameters:
        payloadSize - Size of the payload.
        Returns:
        The size of the header.