Class MqttServer

java.lang.Object
io.vertx.mutiny.mqtt.MqttServer
All Implemented Interfaces:
MutinyDelegate

public class MqttServer extends Object implements MutinyDelegate
An MQTT server

You can accept incoming MQTT connection requests providing a endpointHandler(java.util.function.Consumer<io.vertx.mutiny.mqtt.MqttEndpoint>). As the requests arrive, the handler will be called with an instance of MqttEndpoint in order to manage the communication with the remote MQTT client.

NOTE: This class has been automatically generated from the original non Mutiny-ified interface using Vert.x codegen.

  • Field Details

  • Constructor Details

    • MqttServer

      public MqttServer(io.vertx.mqtt.MqttServer delegate)
    • MqttServer

      public MqttServer(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.mqtt.MqttServer getDelegate()
      Specified by:
      getDelegate in interface MutinyDelegate
      Returns:
      the delegate used by this Mutiny object of generated type
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • create

      public static MqttServer create(Vertx vertx, io.vertx.mqtt.MqttServerOptions options)
      Parameters:
      vertx - Vert.x instance
      options - MQTT server options
      Returns:
      MQTT server instance
    • create

      public static MqttServer create(Vertx vertx)
      Parameters:
      vertx - Vert.x instance
      Returns:
      MQTT server instance
    • listen

      @CheckReturnValue public io.smallrye.mutiny.Uni<MqttServer> listen(int port, String host)
      Start the server listening for incoming connections on the port and host specified It ignores any options specified through the constructor

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      port - the port to listen on
      host - the host to listen on
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • listenAndAwait

      public MqttServer listenAndAwait(int port, String host)
      Blocking variant of listen(int,String).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      port - the port to listen on
      host - the host to listen on
      Returns:
      the MqttServer instance produced by the operation.
    • listenAndForget

      public MqttServer listenAndForget(int port, String host)
      Variant of listen(int,String) that ignores the result of the operation.

      This method subscribes on the result of listen(int,String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from listen(int,String) but you don't need to compose it with other operations.

      Parameters:
      port - the port to listen on
      host - the host to listen on
      Returns:
      the instance of MqttServer to chain method calls.
    • listen

      @CheckReturnValue public io.smallrye.mutiny.Uni<MqttServer> listen(int port)
      Start the server listening for incoming connections on the port specified but on "0.0.0.0" as host. It ignores any options specified through the constructor

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      port - the port to listen on
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • listenAndAwait

      public MqttServer listenAndAwait(int port)
      Blocking variant of listen(int).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      port - the port to listen on
      Returns:
      the MqttServer instance produced by the operation.
    • listenAndForget

      public MqttServer listenAndForget(int port)
      Variant of listen(int) that ignores the result of the operation.

      This method subscribes on the result of listen(int), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from listen(int) but you don't need to compose it with other operations.

      Parameters:
      port - the port to listen on
      Returns:
      the instance of MqttServer to chain method calls.
    • listen

      @CheckReturnValue public io.smallrye.mutiny.Uni<MqttServer> listen()
      Start the server listening for incoming connections using the specified options through the constructor

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • listenAndAwait

      public MqttServer listenAndAwait()
      Blocking variant of listen(int, java.lang.String).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Returns:
      the MqttServer instance produced by the operation.
    • listenAndForget

      public MqttServer listenAndForget()
      Variant of listen(int, java.lang.String) that ignores the result of the operation.

      This method subscribes on the result of listen(int, java.lang.String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from listen(int, java.lang.String) but you don't need to compose it with other operations.

      Returns:
      the instance of MqttServer to chain method calls.
    • endpointHandler

      public MqttServer endpointHandler(Consumer<MqttEndpoint> handler)
      Parameters:
      handler - the endpoint handler
      Returns:
    • exceptionHandler

      public MqttServer exceptionHandler(Consumer<Throwable> handler)
      Parameters:
      handler - the exception handler
      Returns:
    • actualPort

      public int actualPort()
      Returns:
      the actual port the server is listening on.
    • close

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> close()
      Close the server supplying an handler that will be called when the server is actually closed (or has failed).

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • closeAndAwait

      public Void closeAndAwait()
      Blocking variant of close().

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Returns:
      the Void instance produced by the operation.
    • closeAndForget

      public void closeAndForget()
      Variant of close() that ignores the result of the operation.

      This method subscribes on the result of close(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from close() but you don't need to compose it with other operations.

    • newInstance

      public static MqttServer newInstance(io.vertx.mqtt.MqttServer arg)