Module swim.io
Package swim.io

Interface IpModem<I,O>

All Known Implementing Classes:
AbstractIpModem, HttpClientModem, HttpServerModem, MqttSocketModem, WebSocketModem

public interface IpModem<I,O>
Network socket binding that provides asynchronous I/O decoders and encoders for a non-blocking NIO network channel.

An IpModem interfaces with the underlying asynchronous networking system via an IpModemContext. The modem context invokes I/O callbacks on the IpModem when the underlying network socket is ready to perform I/O operations permitted by the socket context's FlowControl.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Lifecycle callback invoked by the modem context after it has become a new socket implementation.
    void
    Lifecycle callback invoked by the modem context after the underlying network socket has opened a connection.
    void
    Lifecycle callback invoked by the socket context after the underlying network connection has disconnected.
    void
    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
    Lifecycle callback invoked by the modem context after the underlying network socket has established a secure connection.
    void
    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
    I/O callback invoked by the modem context asking this IpModem to provide an input Decoder by invoking the modem context's read method.
    void
    I/O callback invoked by the modem context asking this IpModem to provide an output Encoder by invoking the modem context's write method.
    long
    Returns the number of idle milliseconds after which this IpModem should be closed due to inactivity.
    Returns the socket modem context to which this IpModem is bound; returns null if this IpModem is unbound.
    void
    Sets the socket modem context to which this IpModem is bound.
    void
    Lifecycle callback invoked by the modem context before it has become a new socket implementation.
    void
    Lifecycle callback invoked by the modem context before the underlying network socket attempts to open a connection.
    void
    Lifecycle callback invoked by the modem context before the underlying network socket establishes a secure connection.
  • Method Details

    • ipModemContext

      IpModemContext<I,O> ipModemContext()
      Returns the socket modem context to which this IpModem is bound; returns null if this IpModem is unbound.
    • setIpModemContext

      void setIpModemContext(IpModemContext<I,O> context)
      Sets the socket modem context to which this IpModem is bound.
    • idleTimeout

      long idleTimeout()
      Returns the number of idle milliseconds after which this IpModem 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.
    • doRead

      void doRead()
      I/O callback invoked by the modem context asking this IpModem 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.
    • didRead

      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. May be invoked concurrently to other I/O callbacks, but never concurrently with other doRead or didRead calls.
    • doWrite

      void doWrite()
      I/O callback invoked by the modem context asking this IpModem 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.
    • didWrite

      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. May be invoked concurrently to other I/O callbacks, but never concurrently with other dodWrite or didWrite calls.
    • willConnect

      void willConnect()
      Lifecycle callback invoked by the modem context before the underlying network socket attempts to open a connection.
    • didConnect

      void didConnect()
      Lifecycle callback invoked by the modem context after the underlying network socket has opened a connection.
    • willSecure

      void willSecure()
      Lifecycle callback invoked by the modem context before the underlying network socket establishes a secure connection.
    • didSecure

      void didSecure()
      Lifecycle callback invoked by the modem context after the underlying network socket has established a secure connection.
    • willBecome

      void willBecome(IpSocket socket)
      Lifecycle callback invoked by the modem context before it has become a new socket implementation.
    • didBecome

      void didBecome(IpSocket socket)
      Lifecycle callback invoked by the modem context after it has become a new socket implementation.
    • didTimeout

      void didTimeout()
      Lifecycle callback invoked by the modem context after the underlying network connection has timed out. The modem will automatically be closed.
    • didDisconnect

      void didDisconnect()
      Lifecycle callback invoked by the socket context after the underlying network connection has disconnected.
    • didFail

      void didFail(Throwable error)
      Lifecycle callback invoked by the modem context when the underlying network socket fails by throwing an error. The modem will automatically be closed.