Interface RxTransport<M,​S extends RxSocket<M>>

  • Type Parameters:
    M - The type of messages transferred by the transport.
    S - The type of reactive sockets exposed by the transport.
    All Superinterfaces:
    AutoCloseable, Closeable

    public interface RxTransport<M,​S extends RxSocket<M>>
    extends Closeable
    Factory interface for creating reactive client and server sockets.
    • Method Detail

      • connect

        @CheckReturnValue
        io.reactivex.rxjava3.core.Single<S> connect​(String host,
                                                    int port,
                                                    Options options)
        Returns a Single which will connect to the server at the provided address each time it is subscribed. It is the responsibility of the application to enforce timeouts by cancelling the subscription once the timeout is reached. Application layers may return exceptions which are more closely aligned to their APIs. In addition, any initial protocol handshakes should be performed before returning the connected socket.
        Parameters:
        host - The hostname of the server to connect to.
        port - The port number of the server to connect to.
        options - The connection options.
        Returns:
        A Single which will connect to the server at the provided address each time it is subscribed.
      • listen

        @CheckReturnValue
        RxServerSocket<M,​S> listen​(InetSocketAddress address,
                                         Options options)
                                  throws IOException
        Starts listening on the provided address and returns an RxServerSocket which will publish incoming connections via the RxServerSocket.accept() method. The following example shows how it is possible to listen on multiple addresses:
        
             Flowable<S> acceptAll(List<RxServerSocket<M, S>> listeners) {
                 return Flowable.fromIterable(listeners).flatMap(RxServerSocket::accept);
             }
         
        Parameters:
        address - The address to listen on.
        options - The acceptor options.
        Returns:
        An RxServerSocket representing the network listener.
        Throws:
        IOException - If an error occurred while trying to listen on the provided address.
      • close

        default void close()
        Releases any resources, such as thread pools, associated with this transport.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable