Class MqttAdapter

    • Field Detail

      • baseTopic

        @API(status=MAINTAINED)
        public java.lang.String baseTopic
        Otherwise known as "Channel", this is prepended to the topic for all JMRI inward and outward communications. Typically set by preferences at startup. Changing it after startup might have no or bad effect.
      • mqttClient

        org.eclipse.paho.client.mqttv3.MqttClient mqttClient
    • Constructor Detail

      • MqttAdapter

        @API(status=INTERNAL)
        public MqttAdapter()
    • Method Detail

      • getNewMqttClient

        org.eclipse.paho.client.mqttv3.MqttClient getNewMqttClient​(java.lang.String clientID,
                                                                   java.lang.String tempdirName)
                                                            throws org.eclipse.paho.client.mqttv3.MqttException
        Throws:
        org.eclipse.paho.client.mqttv3.MqttException
      • publish

        @API(status=MAINTAINED)
        public void publish​(@Nonnull
                            java.lang.String topic,
                            @Nonnull
                            byte[] payload)
        Send a message over the existing link to a broker.
        Parameters:
        topic - The topic, which follows the channel and precedes the payload in the message
        payload - The payload makes up the final part of the message
      • publish

        @API(status=MAINTAINED)
        public void publish​(@Nonnull
                            java.lang.String topic,
                            @Nonnull
                            byte[] payload,
                            boolean retain)
        Send a message over the existing link to a broker.
        Parameters:
        topic - The topic, which follows the channel and precedes the payload in the message
        payload - The payload makes up the final part of the message
        retain - Should the message be retained?
      • publish

        @API(status=MAINTAINED)
        public void publish​(@Nonnull
                            java.lang.String topic,
                            @Nonnull
                            java.lang.String payload)
        Send a message over the existing link to a broker.
        Parameters:
        topic - The topic, which follows the channel and precedes the payload in the message
        payload - The payload makes up the final part of the message
      • publish

        @API(status=MAINTAINED)
        public void publish​(@Nonnull
                            java.lang.String topic,
                            @Nonnull
                            java.lang.String payload,
                            boolean retain)
        Send a message over the existing link to a broker.
        Parameters:
        topic - The topic, which follows the channel and precedes the payload in the message
        retain - Should the message be retained?
        payload - The payload makes up the final part of the message
      • getMQttClient

        public org.eclipse.paho.client.mqttv3.MqttClient getMQttClient()
      • connectionLost

        @API(status=INTERNAL)
        public void connectionLost​(java.lang.Throwable thrwbl)
        Specified by:
        connectionLost in interface org.eclipse.paho.client.mqttv3.MqttCallback
      • messageArrived

        @API(status=INTERNAL)
        public void messageArrived​(java.lang.String topic,
                                   org.eclipse.paho.client.mqttv3.MqttMessage mm)
                            throws java.lang.Exception
        Specified by:
        messageArrived in interface org.eclipse.paho.client.mqttv3.MqttCallback
        Throws:
        java.lang.Exception
      • deliveryComplete

        @API(status=INTERNAL)
        public void deliveryComplete​(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken imdt)
        Specified by:
        deliveryComplete in interface org.eclipse.paho.client.mqttv3.MqttCallback
      • dispose

        public void dispose()
        Description copied from class: AbstractPortController
        Clean up before removal. Overriding methods must call super.dispose() or document why they are not calling the overridden implementation. In most cases, failure to call the overridden implementation will cause user-visible error.
        Specified by:
        dispose in interface PortAdapter
        Overrides:
        dispose in class AbstractPortController