Interface RxServerSocket<M,S extends RxSocket<M>>

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

public interface RxServerSocket<M,S extends RxSocket<M>> extends Closeable
A reactive server socket listens for incoming connections and binds them to a RxSocket.
  • Method Summary

    Modifier and Type
    Method
    Description
    io.reactivex.rxjava3.core.Single<S>
    Returns a "cold" Single which will accept the next client connection each time it is subscribed.
    void
    Closes this server socket causing the Subscriber to complete if currently subscribed.
    Returns a copy of the options currently used by this server socket.
    Returns the address that this server socket is listening on.
    boolean
    setOptions(Options newOptions)
    Updates the options of this server socket.
  • Method Details

    • accept

      @CheckReturnValue io.reactivex.rxjava3.core.Single<S> accept()
      Returns a "cold" Single which will accept the next client connection each time it is subscribed. Accept operations cannot be cancelled: cancelling/disposing a subscription has no effect, and will not close the underlying server socket.

      Note that invoking this method multiple times returns the same Single instance. The returned Single will not allow multiple concurrent subscriptions as this will result in non-deterministic behavior. Attempts to have multiple concurrent subscriptions will result in an IllegalStateException.

      Subscribers will be notified when the socket is closed through SingleObserver.onError(Throwable) with the corresponding IOException providing the reason for the disconnection. In particular, if the socket is closed locally via close() then it will be notified with RxSocket.LOCAL_CLOSE.

      Returns:
      A "cold" Single which will be signalled once the accept operation completes or fails.
    • getSocketAddress

      InetSocketAddress getSocketAddress()
      Returns the address that this server socket is listening on.
      Returns:
      The address that this server socket is listening on.
    • setOptions

      boolean setOptions(Options newOptions)
      Updates the options of this server socket. Most of the options will be applied only for next incoming connections, current connections will not be impacted by this operation. Some options are not modifiable and will be ignored by this operation.
      Parameters:
      newOptions - The socket options.
      Returns:
      true if some or all options have been applied, false if options cannot be changed.
    • getOptions

      Options getOptions()
      Returns a copy of the options currently used by this server socket. Modifying the returned options will have no impact until applied with setOptions(Options).
      Returns:
      The server socket options.
    • close

      void close()
      Closes this server socket causing the Subscriber to complete if currently subscribed. Calling this method on a server socket that is already closed has no effect.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable