Interface Channel

  • All Superinterfaces:
    Attachable, AutoCloseable, Closeable, org.xnio.channels.Configurable, HandleableCloseable<Channel>

    public interface Channel
    extends Attachable, HandleableCloseable<Channel>, org.xnio.channels.Configurable
    The most basic level of communications in a Remoting connection. A channel simply sends and receives messages. No request/reply correlation is performed. Messages are received in the order that they are written; however, multiple messages may flow in or out concurrently on a single channel. In particular, a later message may complete before an earlier message does.
    Author:
    David M. Lloyd
    • Method Detail

      • getConnection

        Connection getConnection()
        Get the connection associated with this channel.
        Returns:
        the connection
      • writeMessage

        MessageOutputStream writeMessage()
                                  throws IOException
        Write a new message on to this channel, blocking if necessary.
        Returns:
        the outbound message to send
        Throws:
        IOException - if a new message cannot be written
      • writeShutdown

        void writeShutdown()
                    throws IOException
        Send an end-of-messages signal to the remote side. No more messages may be written after this method is called; however, more incoming messages may be received.
        Throws:
        IOException - if the message could not be written
      • receiveMessage

        void receiveMessage​(Channel.Receiver handler)
        Initiate processing of the next message, when it comes in. This method does not block; instead the handler is called asynchronously (possibly in another thread) if/when the next message arrives.
        Parameters:
        handler - the handler for the next incoming message
      • supportsOption

        boolean supportsOption​(org.xnio.Option<?> option)
        Determine whether an option is supported on this channel.
        Specified by:
        supportsOption in interface org.xnio.channels.Configurable
        Parameters:
        option - the option
        Returns:
        true if it is supported
      • getOption

        <T> T getOption​(org.xnio.Option<T> option)
        Get the value of a channel option.
        Specified by:
        getOption in interface org.xnio.channels.Configurable
        Type Parameters:
        T - the type of the option value
        Parameters:
        option - the option to get
        Returns:
        the value of the option, or null if it is not set
      • setOption

        <T> T setOption​(org.xnio.Option<T> option,
                        T value)
                 throws IllegalArgumentException
        Set an option for this channel. Unsupported options are ignored.
        Specified by:
        setOption in interface org.xnio.channels.Configurable
        Type Parameters:
        T - the type of the option value
        Parameters:
        option - the option to set
        value - the value of the option to set
        Returns:
        the previous option value, if any
        Throws:
        IllegalArgumentException - if the value is not acceptable for this option