Class AbstractReconnectStrategy
java.lang.Object
org.openhab.core.io.transport.mqtt.reconnect.AbstractReconnectStrategy
- Direct Known Subclasses:
PeriodicReconnectStrategy
Implement this class to provide a strategy for (re)establishing a lost
broker connection.
- Author:
- David Graeff - Initial contribution
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidTheMqttConnectionObserverwill call this method if a broker connection has been successfully established.@Nullable MqttBrokerConnectionReturn the brokerConnection object that this reconnect policy is assigned to.abstract booleanReturn true if your implementation is trying to establish a connection, false otherwise.abstract voidTheMqttConnectionObserverwill call this method if a broker connection has been lost or couldn't be established.voidsetBrokerConnection(MqttBrokerConnection mqttBrokerConnectionImpl) Will be called by .abstract voidstart()Start the reconnect strategy handling.abstract voidstop()Stop the reconnect strategy handling.
-
Field Details
-
brokerConnection
-
-
Constructor Details
-
AbstractReconnectStrategy
public AbstractReconnectStrategy()
-
-
Method Details
-
setBrokerConnection
Will be called by .- Parameters:
mqttBrokerConnectionImpl- The broker connection
-
getBrokerConnection
Return the brokerConnection object that this reconnect policy is assigned to. -
isReconnecting
public abstract boolean isReconnecting()Return true if your implementation is trying to establish a connection, false otherwise. -
lostConnection
public abstract void lostConnection()TheMqttConnectionObserverwill call this method if a broker connection has been lost or couldn't be established. Your implementation should start trying to reestablish a connection. -
connectionEstablished
public abstract void connectionEstablished()TheMqttConnectionObserverwill call this method if a broker connection has been successfully established. Your implementation should stop reconnection attempts and release resources. -
start
public abstract void start()Start the reconnect strategy handling. -
stop
public abstract void stop()Stop the reconnect strategy handling.It must be possible to restart a reconnect strategy again after it has been stopped.
-