Class AbstractWebSocketConnection

  • All Implemented Interfaces:
    Closeable, AutoCloseable, org.eclipse.jetty.io.Connection, org.eclipse.jetty.io.Connection.UpgradeTo, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.websocket.api.extensions.OutgoingFrames, org.eclipse.jetty.websocket.api.SuspendToken, IOState.ConnectionStateListener, LogicalConnection

    public abstract class AbstractWebSocketConnection
    extends org.eclipse.jetty.io.AbstractConnection
    implements LogicalConnection, org.eclipse.jetty.io.Connection.UpgradeTo, IOState.ConnectionStateListener, org.eclipse.jetty.util.component.Dumpable
    Provides the implementation of LogicalConnection within the framework of the new Connection framework of jetty-io.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  AbstractWebSocketConnection.Stats  
      • Nested classes/interfaces inherited from interface org.eclipse.jetty.io.Connection

        org.eclipse.jetty.io.Connection.Listener, org.eclipse.jetty.io.Connection.UpgradeFrom, org.eclipse.jetty.io.Connection.UpgradeTo
    • Field Summary

      • Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

        KEY
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractWebSocketConnection​(org.eclipse.jetty.io.EndPoint endp, Executor executor, org.eclipse.jetty.util.thread.Scheduler scheduler, org.eclipse.jetty.websocket.api.WebSocketPolicy policy, org.eclipse.jetty.io.ByteBufferPool bufferPool)  
    • Constructor Detail

      • AbstractWebSocketConnection

        public AbstractWebSocketConnection​(org.eclipse.jetty.io.EndPoint endp,
                                           Executor executor,
                                           org.eclipse.jetty.util.thread.Scheduler scheduler,
                                           org.eclipse.jetty.websocket.api.WebSocketPolicy policy,
                                           org.eclipse.jetty.io.ByteBufferPool bufferPool)
    • Method Detail

      • getExecutor

        public Executor getExecutor()
        Description copied from interface: LogicalConnection
        Get the Executor used by this connection.
        Specified by:
        getExecutor in interface LogicalConnection
        Overrides:
        getExecutor in class org.eclipse.jetty.io.AbstractConnection
        Returns:
        the executor
      • onLocalClose

        public void onLocalClose​(CloseInfo close)
        Description copied from interface: LogicalConnection
        Called to indicate a close frame was successfully sent to the remote.
        Specified by:
        onLocalClose in interface LogicalConnection
        Parameters:
        close - the close details
      • onIdleExpired

        public boolean onIdleExpired()
        Specified by:
        onIdleExpired in interface org.eclipse.jetty.io.Connection
        Overrides:
        onIdleExpired in class org.eclipse.jetty.io.AbstractConnection
      • close

        public void close()
        Jetty Connection Close
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface org.eclipse.jetty.io.Connection
        Overrides:
        close in class org.eclipse.jetty.io.AbstractConnection
      • fillInterested

        public void fillInterested()
        Overrides:
        fillInterested in class org.eclipse.jetty.io.AbstractConnection
      • getBufferPool

        public org.eclipse.jetty.io.ByteBufferPool getBufferPool()
        Description copied from interface: LogicalConnection
        Get the ByteBufferPool in use by the connection
        Specified by:
        getBufferPool in interface LogicalConnection
        Returns:
        the buffer pool
      • getExtensions

        public List<org.eclipse.jetty.websocket.api.extensions.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()
      • 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()
      • getPolicy

        public org.eclipse.jetty.websocket.api.WebSocketPolicy getPolicy()
        Description copied from interface: LogicalConnection
        The policy that the connection is running under.
        Specified by:
        getPolicy in interface LogicalConnection
        Returns:
        the policy for the connection
      • getRemoteAddress

        public 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 org.eclipse.jetty.util.thread.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.
      • onClose

        public void onClose()
        Physical connection disconnect.

        Not related to WebSocket close handshake.

        Specified by:
        onClose in interface org.eclipse.jetty.io.Connection
        Overrides:
        onClose in class org.eclipse.jetty.io.AbstractConnection
      • onFillable

        public void onFillable()
        Specified by:
        onFillable in class org.eclipse.jetty.io.AbstractConnection
      • onFillInterestedFailed

        protected void onFillInterestedFailed​(Throwable cause)
        Overrides:
        onFillInterestedFailed in class org.eclipse.jetty.io.AbstractConnection
      • setInitialBuffer

        protected void setInitialBuffer​(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
      • onOpen

        public void onOpen()
        Specified by:
        onOpen in interface org.eclipse.jetty.io.Connection
        Overrides:
        onOpen in class org.eclipse.jetty.io.AbstractConnection
      • onReadTimeout

        protected boolean onReadTimeout​(Throwable timeout)
        Event for no activity on connection (read or write)
        Overrides:
        onReadTimeout in class org.eclipse.jetty.io.AbstractConnection
        Returns:
        true to signal that the endpoint must be closed, false to keep the endpoint open
      • outgoingFrame

        public void outgoingFrame​(org.eclipse.jetty.websocket.api.extensions.Frame frame,
                                  org.eclipse.jetty.websocket.api.WriteCallback callback,
                                  org.eclipse.jetty.websocket.api.BatchMode batchMode)
        Frame from API, User, or Internal implementation destined for network.
        Specified by:
        outgoingFrame in interface org.eclipse.jetty.websocket.api.extensions.OutgoingFrames
      • resume

        public void resume()
        Specified by:
        resume in interface org.eclipse.jetty.websocket.api.SuspendToken
      • setExtensions

        public void setExtensions​(List<org.eclipse.jetty.websocket.api.extensions.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.
      • setInputBufferSize

        public void setInputBufferSize​(int inputBufferSize)
        Overrides:
        setInputBufferSize in class org.eclipse.jetty.io.AbstractConnection
      • 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
      • suspend

        public org.eclipse.jetty.websocket.api.SuspendToken suspend()
        Description copied from interface: LogicalConnection
        Suspend a the incoming read events on the connection.
        Specified by:
        suspend in interface LogicalConnection
        Returns:
        the suspend token
      • dump

        public String dump()
        Specified by:
        dump in interface org.eclipse.jetty.util.component.Dumpable
      • toConnectionString

        public String toConnectionString()
        Overrides:
        toConnectionString in class org.eclipse.jetty.io.AbstractConnection
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • onUpgradeTo

        public void onUpgradeTo​(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 org.eclipse.jetty.io.Connection.UpgradeTo