Interface MqttServer


public interface MqttServer
An MQTT server

You can accept incoming MQTT connection requests providing a 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.

  • Method Details

    • create

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

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

      Future<MqttServer> listen()
      Start the server listening for incoming connections using the specified options through the constructor
      Returns:
      a Future completed with this server instance
    • listen

      Future<MqttServer> listen(int port, String host)
      Start the server listening for incoming connections on the port and host specified
      Parameters:
      port - the port to listen on
      host - the host to listen on
      Returns:
      a Future completed with this server instance
    • listen

      Future<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
      Parameters:
      port - the port to listen on
      Returns:
      a Future completed with this server instance
    • endpointHandler

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

      MqttServer exceptionHandler(Handler<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
    • updateSSLOptions

      default Future<Boolean> updateSSLOptions(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 future result indicates whether the update occurred.

      Parameters:
      options - the new SSL options
      Returns:
      a future signaling the update success
    • updateSSLOptions

      Future<Boolean> updateSSLOptions(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 future result indicates whether the update occurred.

      Parameters:
      options - the new SSL options
      force - force the update when options are equal
      Returns:
      a future signaling the update success
    • actualPort

      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.
    • close

      Future<Void> close()
      Close the server.

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

      Returns:
      a Future completed with this server is closed