Class WebSocketConnection

    • Constructor Detail

      • WebSocketConnection

        public WebSocketConnection​(EndPoint endp,
                                   java.util.concurrent.Executor executor,
                                   Scheduler scheduler,
                                   ByteBufferPool bufferPool,
                                   RetainableByteBufferPool retainableByteBufferPool,
                                   WebSocketCoreSession coreSession)
        Create a WSConnection.

        It is assumed that the WebSocket Upgrade Handshake has already completed successfully before creating this connection.

      • WebSocketConnection

        public WebSocketConnection​(EndPoint endp,
                                   java.util.concurrent.Executor executor,
                                   Scheduler scheduler,
                                   ByteBufferPool bufferPool,
                                   RetainableByteBufferPool retainableByteBufferPool,
                                   WebSocketCoreSession coreSession,
                                   java.util.Random randomMask)
        Create a WSConnection.

        It is assumed that the WebSocket Upgrade Handshake has already completed successfully before creating this connection.

        Parameters:
        endp - The endpoint ever which Websockot is sent/received
        executor - A thread executor to use for WS callbacks.
        scheduler - A scheduler to use for timeouts
        bufferPool - A pool of buffers to use.
        retainableByteBufferPool - A pool of retainable buffers to use.
        coreSession - The WC core session to which frames are delivered.
        randomMask - A Random used to mask frames. If null then SecureRandom will be created if needed.
    • Method Detail

      • getGenerator

        public Generator getGenerator()
      • getParser

        public Parser getParser()
      • getLocalAddress

        @Deprecated
        public java.net.InetSocketAddress getLocalAddress()
        Deprecated.
        Returns:
        the local InetSocketAddress
      • getLocalSocketAddress

        public java.net.SocketAddress getLocalSocketAddress()
      • getRemoteAddress

        @Deprecated
        public java.net.InetSocketAddress getRemoteAddress()
        Deprecated.
        Returns:
        the remote InetSocketAddress
      • getRemoteSocketAddress

        public java.net.SocketAddress getRemoteSocketAddress()
      • isUseInputDirectByteBuffers

        public boolean isUseInputDirectByteBuffers()
      • setUseInputDirectByteBuffers

        public void setUseInputDirectByteBuffers​(boolean useInputDirectByteBuffers)
      • isUseOutputDirectByteBuffers

        public boolean isUseOutputDirectByteBuffers()
      • setUseOutputDirectByteBuffers

        public void setUseOutputDirectByteBuffers​(boolean useOutputDirectByteBuffers)
      • onClose

        public void onClose​(java.lang.Throwable cause)
        Physical connection disconnect.

        Not related to WebSocket close handshake.

        Specified by:
        onClose in interface Connection
        Overrides:
        onClose in class AbstractConnection
        Parameters:
        cause - The cause of the close or null for a normal close
      • onIdleExpired

        public boolean onIdleExpired()
        Description copied from interface: Connection

        Callback method invoked upon an idle timeout event.

        Implementations of this method may return true to indicate that the idle timeout handling should proceed normally, typically failing the EndPoint and causing it to be closed.

        When false is returned, the handling of the idle timeout event is halted immediately and the EndPoint left in the state it was before the idle timeout event.

        Specified by:
        onIdleExpired in interface Connection
        Overrides:
        onIdleExpired in class AbstractConnection
        Returns:
        true to let the EndPoint handle the idle timeout, false to tell the EndPoint to halt the handling of the idle timeout.
      • onReadTimeout

        protected boolean onReadTimeout​(java.lang.Throwable timeout)
        Event for no activity on connection (read or write)
        Overrides:
        onReadTimeout in class AbstractConnection
        Parameters:
        timeout - the cause of the read timeout
        Returns:
        true to signal that the endpoint must be closed, false to keep the endpoint open
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • demand

        public void demand​(long n)
      • moreDemand

        public boolean moreDemand()
      • meetDemand

        public boolean meetDemand()
      • cancelDemand

        public void cancelDemand()
      • setInitialBuffer

        protected void setInitialBuffer​(java.nio.ByteBuffer initialBuffer)
        Extra bytes from the initial HTTP upgrade that need to be processed by the websocket parser before starting to read bytes from the connection
        Parameters:
        initialBuffer - the bytes of extra content encountered during upgrade
      • dump

        public java.lang.String dump()
        Specified by:
        dump in interface Dumpable
      • dump

        public void dump​(java.lang.Appendable out,
                         java.lang.String indent)
                  throws java.io.IOException
        Description copied from interface: Dumpable
        Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.
        Specified by:
        dump in interface Dumpable
        Parameters:
        out - The appendable to dump to
        indent - The indent to apply after any new lines.
        Throws:
        java.io.IOException - if unable to write to Appendable
      • onUpgradeTo

        public void onUpgradeTo​(java.nio.ByteBuffer buffer)
        Extra bytes from the initial HTTP upgrade that need to be processed by the websocket parser before starting to read bytes from the connection
        Specified by:
        onUpgradeTo in interface Connection.UpgradeTo
        Parameters:
        buffer - a non-null buffer of extra bytes