Class AbstractWebSocketConnection

    • Method Detail

      • close

        public void close​(java.lang.Throwable cause)
        Close the connection based on the throwable
        Specified by:
        close in interface LogicalConnection
        Parameters:
        cause - the cause
      • canWriteWebSocketFrames

        public boolean canWriteWebSocketFrames()
        Description copied from interface: LogicalConnection
        Test if Connection State allows for writing frames.
        Specified by:
        canWriteWebSocketFrames in interface LogicalConnection
        Returns:
        true if able to write, false otherwise.
      • canReadWebSocketFrames

        public boolean canReadWebSocketFrames()
        Description copied from interface: LogicalConnection
        Test if Connection State allows for reading of frames.
        Specified by:
        canReadWebSocketFrames in interface LogicalConnection
        Returns:
        true if able to read, false otherwise.
      • toStateString

        public java.lang.String toStateString()
        Description copied from interface: LogicalConnection
        Get the Connection State as a String
        Specified by:
        toStateString in interface LogicalConnection
        Returns:
        the Connection State string
      • opening

        public boolean opening()
        Description copied from interface: LogicalConnection
        Set the state to upgrade/opening handshake has completed.
        Specified by:
        opening in interface LogicalConnection
        Returns:
        true if state is OPENING, false otherwise
      • opened

        public boolean opened()
        Description copied from interface: LogicalConnection
        Set the state to opened (the application onOpen() method has been called successfully).

        Reads from network begin here.

        Specified by:
        opened in interface LogicalConnection
        Returns:
        true if state is OPENED, false otherwise
      • remoteClose

        public void remoteClose​(CloseInfo close)
        Description copied from interface: LogicalConnection
        Report that the Remote Endpoint CLOSE Frame has been received
        Specified by:
        remoteClose in interface LogicalConnection
        Parameters:
        close - the close frame details
      • 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.
      • close

        public void close()
        Jetty Connection Close
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface Connection
        Overrides:
        close in class AbstractConnection
      • getExtensions

        public java.util.List<ExtensionConfig> getExtensions()
        Get the list of extensions in use.

        This list is negotiated during the WebSocket Upgrade Request/Response handshake.

        Returns:
        the list of negotiated extensions in use.
      • getGenerator

        public Generator getGenerator()
      • getId

        public java.lang.String getId()
        Description copied from interface: LogicalConnection
        Get Unique ID for the Connection
        Specified by:
        getId in interface LogicalConnection
        Returns:
        the unique ID for the connection
      • getMaxIdleTimeout

        public long getMaxIdleTimeout()
        Description copied from interface: LogicalConnection
        Set the maximum number of milliseconds of idleness before the connection is closed/disconnected, (ie no frames are either sent or received)
        Specified by:
        getMaxIdleTimeout in interface LogicalConnection
        Returns:
        the idle timeout in milliseconds
      • getParser

        public Parser getParser()
      • getRemoteAddress

        public java.net.InetSocketAddress getRemoteAddress()
        Description copied from interface: LogicalConnection
        Get the remote Address in use for this connection.

        Note: Non-physical connections, like during the Mux extensions, or during unit testing can result in a InetSocketAddress on port 0 and/or on localhost.

        Specified by:
        getRemoteAddress in interface LogicalConnection
        Returns:
        the remote address.
      • getScheduler

        public Scheduler getScheduler()
      • isOpen

        public boolean isOpen()
        Description copied from interface: LogicalConnection
        Test if logical connection is still open
        Specified by:
        isOpen in interface LogicalConnection
        Returns:
        true if connection is open
      • isReading

        public boolean isReading()
        Description copied from interface: LogicalConnection
        Tests if the connection is actively reading.
        Specified by:
        isReading in interface LogicalConnection
        Returns:
        true if connection is actively attempting to read.
      • onFillInterestedFailed

        protected void onFillInterestedFailed​(java.lang.Throwable cause)
        Description copied from class: AbstractConnection

        Callback method invoked when the endpoint failed to be ready to be read.

        Overrides:
        onFillInterestedFailed in class AbstractConnection
        Parameters:
        cause - the exception that caused the failure
      • setInitialBuffer

        protected void setInitialBuffer​(java.nio.ByteBuffer prefilled)
        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:
        prefilled - the bytes of prefilled content encountered during upgrade
      • 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
      • outgoingFrame

        public void outgoingFrame​(Frame frame,
                                  WriteCallback callback,
                                  BatchMode batchMode)
        Frame from API, User, or Internal implementation destined for network.
        Specified by:
        outgoingFrame in interface OutgoingFrames
        Parameters:
        frame - the frame to eventually write to the network layer.
        callback - the callback to notify when the frame is written.
        batchMode - the batch mode requested by the sender.
      • resume

        public void resume()
        Description copied from interface: SuspendToken
        Resume a previously suspended connection.
        Specified by:
        resume in interface SuspendToken
      • setExtensions

        public void setExtensions​(java.util.List<ExtensionConfig> extensions)
        Get the list of extensions in use.

        This list is negotiated during the WebSocket Upgrade Request/Response handshake.

        Parameters:
        extensions - the list of negotiated extensions in use.
      • setMaxIdleTimeout

        public void setMaxIdleTimeout​(long ms)
        Description copied from interface: LogicalConnection
        Set the maximum number of milliseconds of idleness before the connection is closed/disconnected, (ie no frames are either sent or received)

        This idle timeout cannot be garunteed to take immediate effect for any active read/write actions. New read/write actions will have this new idle timeout.

        Specified by:
        setMaxIdleTimeout in interface LogicalConnection
        Parameters:
        ms - the number of milliseconds of idle timeout
      • dumpSelf

        public java.lang.String dumpSelf()
        Description copied from interface: Dumpable
        The description of this/self found in the dump. Allows for alternative representation of Object other then .toString() where the long form output of toString() is represented in a cleaner way within the dump infrastructure.
        Specified by:
        dumpSelf in interface Dumpable
        Returns:
        the representation of self
      • 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 prefilled)
        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:
        prefilled - An optional buffer that can contain prefilled data. Typically this results from an upgrade of one protocol to the other where the old connection has buffered data destined for the new connection. The new connection must take ownership of the buffer and is responsible for returning it to the buffer pool