Module swim.io
Package swim.io

Interface ModemContext<I,​O>

  • All Superinterfaces:
    ConnectionContext, FlowContext
    All Known Implementing Classes:
    SocketModem

    public interface ModemContext<I,​O>
    extends ConnectionContext, FlowContext
    Network socket context that manages asynchronous I/O decoders and encoders for a non-blocking NIO network channel. A ModemContext is implicitly bound to a Modem, providing the Modem with the ability to modify its FlowControl state, enqueue read decoders and write encoders, to become a different kind of Socket, and to close the socket.
    • Method Detail

      • socketSettings

        SocketSettings socketSettings()
        Returns the configuration parameters that govern the underlying network socket.
      • read

        <I2 extends I> void read​(Decoder<I2> decoder)
        Enqueues a read decoder to which input data will be asynchronously fed. The read flow control of the underlying network socket is automatically managed using the state of the read decoder. When the read decoder transitions into the done state, the didRead callback of the bound Modem will be invoked with the decoded result. If the read decoder transitions into the error state, then the didFail callback of the bound Modem will be invoked with the decode error.
      • write

        <O2 extends O> void write​(Encoder<?,​O2> encoder)
        Enqueues a write encoder from which output data will be asynchronously pulled. The write flow control of the underlying network socket is automatically managed using the state of the write encoder. When the write encoder transitions into the done state, the didWrite callback of the bound Modem will be invoked with the encoded result. If the write encoder transitions into the error state, then the didFail callback of the bound Modem will be invoked with the encode error.
      • become

        void become​(Socket socket)
        Rebinds the underlying SocketContext to a new socket implementation, thereby changing the Socket handler that receives network I/O callbacks.
      • close

        void close()
        Closes the underlying network socket.