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 MqttServer#endpointHandler(Handler). 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.

See Also:
  • MqttServer
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final TypeArg<MqttServer>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    MqttServer(io.vertx.mqtt.MqttServer delegate)
    Create a new instance of MqttServer delegating to the given (non-null) instance of MqttServer.
    MqttServer(Object delegate)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    The actual port the server is listening on.
    io.smallrye.mutiny.Uni<Void>
    Close the server.
    void
    Close the server.
    Close the server.
    static MqttServer
    create(Vertx vertx)
    Return an MQTT server instance using default options
    static MqttServer
    create(Vertx vertx, io.vertx.mqtt.MqttServerOptions options)
    Return an MQTT server instance
    Set the endpoint handler for the server.
    boolean
     
    Set an exception handler for the server, that will be called when an error happens independantly of an accepted MqttEndpoint, like a rejected connection
    io.vertx.mqtt.MqttServer
    Get the delegate instance.
    int
     
    io.smallrye.mutiny.Uni<MqttServer>
    Start the server listening for incoming connections using the specified options through the constructor
    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.
    io.smallrye.mutiny.Uni<MqttServer>
    listen(int port, String host)
    Start the server listening for incoming connections on the port and host specified
    Start the server listening for incoming connections using the specified options through the constructor
    listenAndAwait(int port)
    Start the server listening for incoming connections on the port specified but on "0.0.0.0" as host.
    listenAndAwait(int port, String host)
    Start the server listening for incoming connections on the port and host specified
    Start the server listening for incoming connections using the specified options through the constructor
    listenAndForget(int port)
    Start the server listening for incoming connections on the port specified but on "0.0.0.0" as host.
    listenAndForget(int port, String host)
    Start the server listening for incoming connections on the port and host specified
    static MqttServer
    newInstance(io.vertx.mqtt.MqttServer delegate)
    Creates a new instance of the MqttServer.
     
    io.smallrye.mutiny.Uni<Boolean>
    updateSSLOptions(io.vertx.core.net.ServerSSLOptions options)
    Update the server with new SSL options, the update happens if the options object is valid and different from the existing options object.
    io.smallrye.mutiny.Uni<Boolean>
    updateSSLOptions(io.vertx.core.net.ServerSSLOptions options, boolean force)
    Update the server with new SSL options, the update happens if the options object is valid and different from the existing options object.
    updateSSLOptionsAndAwait(io.vertx.core.net.ServerSSLOptions options)
    Update the server with new SSL options, the update happens if the options object is valid and different from the existing options object.
    updateSSLOptionsAndAwait(io.vertx.core.net.ServerSSLOptions options, boolean force)
    Update the server with new SSL options, the update happens if the options object is valid and different from the existing options object.
    updateSSLOptionsAndForget(io.vertx.core.net.ServerSSLOptions options)
    Update the server with new SSL options, the update happens if the options object is valid and different from the existing options object.
    updateSSLOptionsAndForget(io.vertx.core.net.ServerSSLOptions options, boolean force)
    Update the server with new SSL options, the update happens if the options object is valid and different from the existing options object.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • MqttServer

      public MqttServer(io.vertx.mqtt.MqttServer delegate)
      Create a new instance of MqttServer delegating to the given (non-null) instance of MqttServer.
    • MqttServer

      public MqttServer(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.mqtt.MqttServer getDelegate()
      Get the delegate instance.

      This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.

      Specified by:
      getDelegate in interface MutinyDelegate
      Returns:
      the delegate instance
    • 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. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttServer.listen()
    • listenAndAwait

      public MqttServer listenAndAwait()
      Start the server listening for incoming connections using the specified options through the constructor

      Unlike the bare Vert.x variant, this method returns a MqttServer. This method awaits indefinitely 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 operation result
      See Also:
      • MqttServer.listen()
    • listenAndForget

      public MqttServer listenAndForget()
      Start the server listening for incoming connections using the specified options through the constructor

      Unlike the bare Vert.x variant, this method ignores the MqttServer result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttServer.listen()
    • 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

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      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:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttServer.listen(int, String)
    • listenAndAwait

      public MqttServer listenAndAwait(int port, String host)
      Start the server listening for incoming connections on the port and host specified

      Unlike the bare Vert.x variant, this method returns a MqttServer. This method awaits indefinitely 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 operation result
      See Also:
      • MqttServer.listen(int, String)
    • listenAndForget

      public MqttServer listenAndForget(int port, String host)
      Start the server listening for incoming connections on the port and host specified

      Unlike the bare Vert.x variant, this method ignores the MqttServer result or any failure.

      Parameters:
      port - the port to listen on
      host - the host to listen on
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttServer.listen(int, String)
    • 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. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      port - the port to listen on
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttServer.listen(int)
    • listenAndAwait

      public MqttServer listenAndAwait(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 MqttServer. This method awaits indefinitely 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 operation result
      See Also:
      • MqttServer.listen(int)
    • listenAndForget

      public MqttServer listenAndForget(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 ignores the MqttServer result or any failure.

      Parameters:
      port - the port to listen on
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttServer.listen(int)
    • updateSSLOptions

      @CheckReturnValue public io.smallrye.mutiny.Uni<Boolean> updateSSLOptions(io.vertx.core.net.ServerSSLOptions options)
      Update the server with new SSL options, the update happens if the options object is valid and different from the existing options object.

      This is equivalent to calling updateSSLOptions(ServerSSLOptions, boolean) with force set to false.

      The boolean succeeded uni result indicates whether the update occurred.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      options - the new SSL options
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttServer.updateSSLOptions(ServerSSLOptions)
    • updateSSLOptionsAndAwait

      public Boolean updateSSLOptionsAndAwait(io.vertx.core.net.ServerSSLOptions options)
      Update the server with new SSL options, the update happens if the options object is valid and different from the existing options object.

      This is equivalent to calling updateSSLOptions(ServerSSLOptions, boolean) with force set to false.

      The boolean succeeded underlying uni result indicates whether the update occurred.

      Unlike the bare Vert.x variant, this method returns a Boolean. This method awaits indefinitely 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:
      options - the new SSL options
      Returns:
      The operation result
      See Also:
      • MqttServer.updateSSLOptions(ServerSSLOptions)
    • updateSSLOptionsAndForget

      public MqttServer updateSSLOptionsAndForget(io.vertx.core.net.ServerSSLOptions options)
      Update the server with new SSL options, the update happens if the options object is valid and different from the existing options object.

      This is equivalent to calling updateSSLOptions(ServerSSLOptions, boolean) with force set to false.

      The boolean succeeded underlying uni result indicates whether the update occurred.

      Unlike the bare Vert.x variant, this method ignores the Boolean result or any failure.

      Parameters:
      options - the new SSL options
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttServer.updateSSLOptions(ServerSSLOptions)
    • updateSSLOptions

      @CheckReturnValue public io.smallrye.mutiny.Uni<Boolean> updateSSLOptions(io.vertx.core.net.ServerSSLOptions options, boolean force)
      Update the server with new SSL options, the update happens if the options object is valid and different from the existing options object.

      The options object is compared using its equals method against the existing options to prevent an update when the objects are equal since loading options can be costly. When options are equal, setting force to true forces the update.

      The boolean succeeded uni result indicates whether the update occurred.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      options - the new SSL options
      force - force the update when options are equal
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttServer.updateSSLOptions(ServerSSLOptions, boolean)
    • updateSSLOptionsAndAwait

      public Boolean updateSSLOptionsAndAwait(io.vertx.core.net.ServerSSLOptions options, boolean force)
      Update the server with new SSL options, the update happens if the options object is valid and different from the existing options object.

      The options object is compared using its equals method against the existing options to prevent an update when the objects are equal since loading options can be costly. When options are equal, setting force to true forces the update.

      The boolean succeeded underlying uni result indicates whether the update occurred.

      Unlike the bare Vert.x variant, this method returns a Boolean. This method awaits indefinitely 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:
      options - the new SSL options
      force - force the update when options are equal
      Returns:
      The operation result
      See Also:
      • MqttServer.updateSSLOptions(ServerSSLOptions, boolean)
    • updateSSLOptionsAndForget

      public MqttServer updateSSLOptionsAndForget(io.vertx.core.net.ServerSSLOptions options, boolean force)
      Update the server with new SSL options, the update happens if the options object is valid and different from the existing options object.

      The options object is compared using its equals method against the existing options to prevent an update when the objects are equal since loading options can be costly. When options are equal, setting force to true forces the update.

      The boolean succeeded underlying uni result indicates whether the update occurred.

      Unlike the bare Vert.x variant, this method ignores the Boolean result or any failure.

      Parameters:
      options - the new SSL options
      force - force the update when options are equal
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttServer.updateSSLOptions(ServerSSLOptions, boolean)
    • close

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> close()
      Close the server.

      The close happens asynchronously and the server may not be closed until some time after the call has returned.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttServer.close()
    • closeAndAwait

      public void closeAndAwait()
      Close the server.

      The close happens asynchronously and the server may not be closed until some time after the call has returned.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely 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).

      See Also:
      • MqttServer.close()
    • closeAndForget

      public MqttServer closeAndForget()
      Close the server.

      The close happens asynchronously and the server may not be closed until some time after the call has returned.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttServer.close()
    • create

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

      public static MqttServer create(Vertx vertx)
      Return an MQTT server instance using default options
      Parameters:
      vertx - Vert.x instance
      Returns:
      MQTT server instance
    • endpointHandler

      public MqttServer endpointHandler(Consumer<MqttEndpoint> handler)
      Set the endpoint handler for the server. If an MQTT client connect to the server a new MqttEndpoint instance will be created and passed to the handler
      Parameters:
      handler - the endpoint handler
      Returns:
      a reference to this, so the API can be used fluently
    • exceptionHandler

      public MqttServer exceptionHandler(Consumer<Throwable> handler)
      Set an exception handler for the server, that will be called when an error happens independantly of an accepted MqttEndpoint, like a rejected connection
      Parameters:
      handler - the exception handler
      Returns:
      a reference to this, so the API can be used fluently
    • actualPort

      public int actualPort()
      The actual port the server is listening on. This is useful if you bound the server specifying 0 as port number signifying an ephemeral port
      Returns:
      the actual port the server is listening on.
    • newInstance

      public static MqttServer newInstance(io.vertx.mqtt.MqttServer delegate)
      Creates a new instance of the MqttServer.
    • hashCode

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

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

      public String toString()
      Overrides:
      toString in class Object