Module swim.io
Package swim.io

Class AbstractModem<I,​O>

    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractModem()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void become​(Socket socket)  
      String cipherSuite()
      Returns the cryptographic cipher suite used by the underlying network connection.
      void close()  
      void didBecome​(Socket socket)
      Lifecycle callback invoked by the modem context after it has become a new socket implementation.
      void didConnect()
      Lifecycle callback invoked by the modem context after the underlying network socket has opened a connection.
      void didDisconnect()
      Lifecycle callback invoked by the socket context after the underlying network connection has disconnected.
      void didFail​(Throwable error)
      Lifecycle callback invoked by the modem context when the underlying network socket fails by throwing an error.
      void didRead​(I input)
      I/O callback invoked by the modem context with the completed value of the current read Decoder after it has transitioned to the done state.
      void didSecure()
      Lifecycle callback invoked by the modem context after the underlying network socket has established a secure connection.
      void didTimeout()
      Lifecycle callback invoked by the modem context after the underlying network connection has timed out.
      void didWrite​(O output)
      I/O callback invoked by the modem context with the completed value of the current write Encoder after it has transitioned to the done state.
      void doRead()
      I/O callback invoked by the modem context asking this Modem to provide an input Decoder by invoking the modem context's read method.
      void doWrite()
      I/O callback invoked by the modem context asking this Modem to provide an output Encoder by invoking the modem context's write method.
      FlowControl flowControl()
      Returns the current FlowControl state of the underlying network channel.
      void flowControl​(FlowControl flowControl)
      Enqueues an atomic replacement of the underlying network channel's flow control state with a new flowControl.
      FlowControl flowControl​(FlowModifier flowModifier)
      Enqueues an atomic modification to the underlying network channel's flow control state by applying a flowModifier delta.
      long idleTimeout()
      Returns the number of idle milliseconds after which this Modem should be closed due to inactivity.
      boolean isClient()
      Returns true if the underlying network channel initiated an outgoing connection.
      boolean isConnected()
      Returns true if the underlying network channel is currently connected.
      boolean isSecure()
      Returns true if the underlying network transport is encrypted.
      boolean isServer()
      Returns true if the underlying network channel accepted an incoming connection.
      InetSocketAddress localAddress()
      Returns the IP address and port of the local endpoint of the underlying network connection.
      Collection<Certificate> localCertificates()
      Returns the certificate chain used to authenticate the local endpoint of the underlying network connection.
      Principal localPrincipal()
      Returns the authenticated identity of the local endpoint of the underlying network connection.
      ModemContext<I,​O> modemContext()
      Returns the socket modem context to which this Modem is bound; returns null if this Modem is unbound.
      <I2 extends I>
      void
      read​(Decoder<I2> decoder)  
      InetSocketAddress remoteAddress()
      Returns the IP address and port of the remote endpoint of the underlying network connection.
      Collection<Certificate> remoteCertificates()
      Returns the certificate chain used to authenticate the remote endpoint of the underlying network connection.
      Principal remotePrincipal()
      Returns the authenticated identity of the remote endpoint of the underlying network connection.
      String securityProtocol()
      Returns the name of the transport-layer security protocol used by the underlying network connection.
      void setModemContext​(ModemContext<I,​O> context)
      Sets the socket modem context to which this Modem is bound.
      SocketSettings socketSettings()  
      void willBecome​(Socket socket)
      Lifecycle callback invoked by the modem context before it has become a new socket implementation.
      void willConnect()
      Lifecycle callback invoked by the modem context before the underlying network socket attempts to open a connection.
      void willSecure()
      Lifecycle callback invoked by the modem context before the underlying network socket establishes a secure connection.
      <O2 extends O>
      void
      write​(Encoder<?,​O2> encoder)  
    • Constructor Detail

      • AbstractModem

        public AbstractModem()
    • Method Detail

      • modemContext

        public ModemContext<I,​O> modemContext()
        Description copied from interface: Modem
        Returns the socket modem context to which this Modem is bound; returns null if this Modem is unbound.
        Specified by:
        modemContext in interface Modem<I,​O>
      • setModemContext

        public void setModemContext​(ModemContext<I,​O> context)
        Description copied from interface: Modem
        Sets the socket modem context to which this Modem is bound.
        Specified by:
        setModemContext in interface Modem<I,​O>
      • idleTimeout

        public long idleTimeout()
        Description copied from interface: Modem
        Returns the number of idle milliseconds after which this Modem should be closed due to inactivity. Returns -1 if a default idle timeout should be used. Returns 0 if the underlying network socket should not time out.
        Specified by:
        idleTimeout in interface Modem<I,​O>
      • doRead

        public void doRead()
        Description copied from interface: Modem
        I/O callback invoked by the modem context asking this Modem to provide an input Decoder by invoking the modem context's read method. The modem context will asynchronously feed input data to the provided read Decoder until it transitions out of the cont state. The read flow control of the underlying network socket is automatically managed by the modem context using the state of the read Decoder. May be invoked concurrently to other I/O callbacks, but never concurrently with other doRead or didRead calls.
        Specified by:
        doRead in interface Modem<I,​O>
      • didRead

        public void didRead​(I input)
        Description copied from interface: Modem
        I/O callback invoked by the modem context with the completed value of the current read Decoder after it has transitioned to the done state. May be invoked concurrently to other I/O callbacks, but never concurrently with other doRead or didRead calls.
        Specified by:
        didRead in interface Modem<I,​O>
      • doWrite

        public void doWrite()
        Description copied from interface: Modem
        I/O callback invoked by the modem context asking this Modem to provide an output Encoder by invoking the modem context's write method. The modem context will asynchronously pull output data from the provided write Encoder until it transitions out of the cont state. The write flow control of the underlying network socket is automatically managed by the modem context using the state of the write Encoder. May be invoked concurrently to other I/O callbacks, but never concurrently with other doWrite or didWrite calls.
        Specified by:
        doWrite in interface Modem<I,​O>
      • didWrite

        public void didWrite​(O output)
        Description copied from interface: Modem
        I/O callback invoked by the modem context with the completed value of the current write Encoder after it has transitioned to the done state. May be invoked concurrently to other I/O callbacks, but never concurrently with other dodWrite or didWrite calls.
        Specified by:
        didWrite in interface Modem<I,​O>
      • willConnect

        public void willConnect()
        Description copied from interface: Modem
        Lifecycle callback invoked by the modem context before the underlying network socket attempts to open a connection.
        Specified by:
        willConnect in interface Modem<I,​O>
      • didConnect

        public void didConnect()
        Description copied from interface: Modem
        Lifecycle callback invoked by the modem context after the underlying network socket has opened a connection.
        Specified by:
        didConnect in interface Modem<I,​O>
      • willSecure

        public void willSecure()
        Description copied from interface: Modem
        Lifecycle callback invoked by the modem context before the underlying network socket establishes a secure connection.
        Specified by:
        willSecure in interface Modem<I,​O>
      • didSecure

        public void didSecure()
        Description copied from interface: Modem
        Lifecycle callback invoked by the modem context after the underlying network socket has established a secure connection.
        Specified by:
        didSecure in interface Modem<I,​O>
      • willBecome

        public void willBecome​(Socket socket)
        Description copied from interface: Modem
        Lifecycle callback invoked by the modem context before it has become a new socket implementation.
        Specified by:
        willBecome in interface Modem<I,​O>
      • didBecome

        public void didBecome​(Socket socket)
        Description copied from interface: Modem
        Lifecycle callback invoked by the modem context after it has become a new socket implementation.
        Specified by:
        didBecome in interface Modem<I,​O>
      • didTimeout

        public void didTimeout()
        Description copied from interface: Modem
        Lifecycle callback invoked by the modem context after the underlying network connection has timed out. The modem will automatically be closed.
        Specified by:
        didTimeout in interface Modem<I,​O>
      • didDisconnect

        public void didDisconnect()
        Description copied from interface: Modem
        Lifecycle callback invoked by the socket context after the underlying network connection has disconnected.
        Specified by:
        didDisconnect in interface Modem<I,​O>
      • didFail

        public void didFail​(Throwable error)
        Description copied from interface: Modem
        Lifecycle callback invoked by the modem context when the underlying network socket fails by throwing an error. The modem will automatically be closed.
        Specified by:
        didFail in interface Modem<I,​O>
      • isConnected

        public boolean isConnected()
        Description copied from interface: ConnectionContext
        Returns true if the underlying network channel is currently connected.
        Specified by:
        isConnected in interface ConnectionContext
      • isClient

        public boolean isClient()
        Description copied from interface: ConnectionContext
        Returns true if the underlying network channel initiated an outgoing connection.
        Specified by:
        isClient in interface ConnectionContext
      • isServer

        public boolean isServer()
        Description copied from interface: ConnectionContext
        Returns true if the underlying network channel accepted an incoming connection.
        Specified by:
        isServer in interface ConnectionContext
      • isSecure

        public boolean isSecure()
        Description copied from interface: ConnectionContext
        Returns true if the underlying network transport is encrypted.
        Specified by:
        isSecure in interface ConnectionContext
      • securityProtocol

        public String securityProtocol()
        Description copied from interface: ConnectionContext
        Returns the name of the transport-layer security protocol used by the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not secure.
        Specified by:
        securityProtocol in interface ConnectionContext
      • cipherSuite

        public String cipherSuite()
        Description copied from interface: ConnectionContext
        Returns the cryptographic cipher suite used by the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not secure.
        Specified by:
        cipherSuite in interface ConnectionContext
      • localAddress

        public InetSocketAddress localAddress()
        Description copied from interface: ConnectionContext
        Returns the IP address and port of the local endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected.
        Specified by:
        localAddress in interface ConnectionContext
      • localPrincipal

        public Principal localPrincipal()
        Description copied from interface: ConnectionContext
        Returns the authenticated identity of the local endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.
        Specified by:
        localPrincipal in interface ConnectionContext
      • localCertificates

        public Collection<Certificate> localCertificates()
        Description copied from interface: ConnectionContext
        Returns the certificate chain used to authenticate the local endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.
        Specified by:
        localCertificates in interface ConnectionContext
      • remoteAddress

        public InetSocketAddress remoteAddress()
        Description copied from interface: ConnectionContext
        Returns the IP address and port of the remote endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected.
        Specified by:
        remoteAddress in interface ConnectionContext
      • remotePrincipal

        public Principal remotePrincipal()
        Description copied from interface: ConnectionContext
        Returns the authenticated identity of the remote endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.
        Specified by:
        remotePrincipal in interface ConnectionContext
      • remoteCertificates

        public Collection<Certificate> remoteCertificates()
        Description copied from interface: ConnectionContext
        Returns the certificate chain used to authenticate the remote endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.
        Specified by:
        remoteCertificates in interface ConnectionContext
      • flowControl

        public FlowControl flowControl()
        Description copied from interface: FlowContext
        Returns the current FlowControl state of the underlying network channel.
        Specified by:
        flowControl in interface FlowContext
      • flowControl

        public void flowControl​(FlowControl flowControl)
        Description copied from interface: FlowContext
        Enqueues an atomic replacement of the underlying network channel's flow control state with a new flowControl.
        Specified by:
        flowControl in interface FlowContext
      • flowControl

        public FlowControl flowControl​(FlowModifier flowModifier)
        Description copied from interface: FlowContext
        Enqueues an atomic modification to the underlying network channel's flow control state by applying a flowModifier delta.
        Specified by:
        flowControl in interface FlowContext
      • read

        public <I2 extends I> void read​(Decoder<I2> decoder)
      • write

        public <O2 extends O> void write​(Encoder<?,​O2> encoder)
      • become

        public void become​(Socket socket)
      • close

        public void close()